From 7718a96a9992a8bf826c0c4daef82ad60dbd2e87 Mon Sep 17 00:00:00 2001 From: GCHQDeveloper314 <94527357+GCHQDeveloper314@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:44:32 +0000 Subject: [PATCH] Refactor test suite to use tox and pytest, and have separate directories for unit and integration tests. Update READMEs, and fishbowl scripts and jinja templates. Refactor fishbowl to generate import strings. --- README.md | 58 +- setup.py | 23 +- src/fishbowl/README.md | 17 +- src/fishbowl/fishbowl.py | 175 +- src/fishbowl/templates/base.py.j2 | 2 +- src/fishbowl/templates/config.py.j2 | 5 +- src/fishbowl/templates/functions.py.j2 | 18 +- src/fishbowl/templates/operations.py.j2 | 22 +- src/gafferpy/gaffer_binaryoperators.py | 45 +- src/gafferpy/gaffer_core.py | 104 +- src/gafferpy/gaffer_functions.py | 46 +- src/gafferpy/gaffer_predicates.py | 38 +- src/gafferpy/gaffer_types.py | 172 +- ...binary_operators.py => binaryoperators.py} | 60 +- src/gafferpy/generated_api/config.py | 54 +- src/gafferpy/generated_api/functions.py | 556 +++-- src/gafferpy/generated_api/operations.py | 1175 +++++----- src/gafferpy/generated_api/predicates.py | 358 +-- src/gafferpy_examples/example.py | 4 +- src/generate.py | 15 +- src/test/test_connector.py | 197 -- src/test/test_gaffer_functions_it.py | 64 - src/test/test_gaffer_operations_it.py | 91 - src/test/test_gaffer_predicates_it.py | 56 - src/test/test_json_converter.py | 57 - {src/test => tests}/__init__.py | 2 +- tests/integration/__init__.py | 11 + tests/integration/conftest.py | 119 + tests/integration/test_connector.py | 186 ++ .../integration}/test_example.py | 13 +- .../integration}/test_example_map.py | 13 +- tests/integration/test_gaffer_functions_it.py | 32 + .../integration/test_gaffer_operations_it.py | 83 + .../integration/test_gaffer_predicates_it.py | 32 + .../addOperationsToChain.json | 0 .../federatedGraphConfig.json | 0 .../federatedStore.properties | 0 .../road-traffic-example/graphConfig.json | 0 .../roadTrafficSampleData.csv | 0 .../road-traffic-example/schema/elements.json | 0 .../road-traffic-example/schema/types.json | 0 .../road-traffic-example/store.properties | 0 tests/unit/__init__.py | 11 + tests/unit/conftest.py | 32 + .../unit}/test_gaffer_functions.py | 28 +- .../unit}/test_gaffer_operations.py | 1924 +++++++++-------- .../unit}/test_gaffer_predicates.py | 27 +- tests/unit/test_json_converter.py | 45 + tox.ini | 22 + 49 files changed, 3332 insertions(+), 2660 deletions(-) rename src/gafferpy/generated_api/{binary_operators.py => binaryoperators.py} (92%) delete mode 100755 src/test/test_connector.py delete mode 100755 src/test/test_gaffer_functions_it.py delete mode 100755 src/test/test_gaffer_operations_it.py delete mode 100755 src/test/test_gaffer_predicates_it.py delete mode 100644 src/test/test_json_converter.py rename {src/test => tests}/__init__.py (82%) create mode 100644 tests/integration/__init__.py create mode 100644 tests/integration/conftest.py create mode 100755 tests/integration/test_connector.py rename {src/test => tests/integration}/test_example.py (71%) rename {src/test => tests/integration}/test_example_map.py (70%) create mode 100755 tests/integration/test_gaffer_functions_it.py create mode 100755 tests/integration/test_gaffer_operations_it.py create mode 100755 tests/integration/test_gaffer_predicates_it.py rename {src/test => tests}/road-traffic-example/addOperationsToChain.json (100%) rename {src/test => tests}/road-traffic-example/federatedGraphConfig.json (100%) rename {src/test => tests}/road-traffic-example/federatedStore.properties (100%) rename {src/test => tests}/road-traffic-example/graphConfig.json (100%) rename {src/test => tests}/road-traffic-example/roadTrafficSampleData.csv (100%) rename {src/test => tests}/road-traffic-example/schema/elements.json (100%) rename {src/test => tests}/road-traffic-example/schema/types.json (100%) rename {src/test => tests}/road-traffic-example/store.properties (100%) create mode 100644 tests/unit/__init__.py create mode 100644 tests/unit/conftest.py rename {src/test => tests/unit}/test_gaffer_functions.py (98%) rename {src/test => tests/unit}/test_gaffer_operations.py (79%) rename {src/test => tests/unit}/test_gaffer_predicates.py (97%) create mode 100644 tests/unit/test_json_converter.py create mode 100644 tox.ini diff --git a/README.md b/README.md index 2da37b02..6333e61d 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## Installation -Gafferpy requires Python 3.6+. We don't currently release gafferpy on pypi, but you can install it over ssh with: +`gafferpy` requires Python 3.6+. We do not currently release `gafferpy` on PyPI, but you can install it over ssh with: ```bash pip install git+https://github.com/gchq/gafferpy.git @@ -28,13 +28,13 @@ pip install -e . ## Quick Start -The python shell connects to a running Gaffer REST API. -You can start the Gaffer road-traffic-demo rest server from the Gaffer repository, using the command: +The Python shell connects to a running Gaffer REST API. +You can start the Gaffer [`road-traffic-demo`](https://github.com/gchq/Gaffer/blob/master/example/road-traffic/README.md) REST server from the Gaffer repository, using the command: ```bash mvn clean install -pl :road-traffic-demo -Proad-traffic-demo,quick ``` - +To connect to the running Gaffer API from Python (more information on the Python shell can be found [here](https://gchq.github.io/gaffer-doc/latest/user-guide/apis/python-api/)): ```python # Import the client library and connector from gafferpy import gaffer as g @@ -42,8 +42,10 @@ from gafferpy import gaffer_connector # Instantiate a connector gc = gaffer_connector.GafferConnector("http://localhost:8080/rest/latest") - -# You can use the connector to perform get requests +``` +Then perform requests against it: +```python +# You can use the connector to perform GET requests schema = gc.execute_get(g.GetSchema()) # And also run operations @@ -73,38 +75,50 @@ elements = gc.execute_operation_chain( ) ``` -See [operation examples](https://gchq.github.io/gaffer-doc/v1docs/getting-started/operations/contents) for more examples of operations in python. +See [Operations Guide](https://gchq.github.io/gaffer-doc/latest/reference/operations-guide/operations) for more examples of operations in Python. -## Coding Style -Please ensure that your coding style is consistent with the rest of the Gaffer project. Guides on the coding style for Gaffer can be found [here](https://gchq.github.io/gaffer-doc/latest/ways-of-working/#coding-style) +## Developer Guide -## Testing +### Coding Style +Please ensure that your coding style is consistent with the rest of the Gaffer project. Guides on the coding style for `gafferpy` and Gaffer can be found [here](https://gchq.github.io/gaffer-doc/latest/development-guide/ways-of-working). -```bash -# To run all of the tests, first deploy the road traffic example -# This needs to be done from the Gaffer java repository -mvn clean install -pl :road-traffic-demo -Proad-traffic-demo,quick +### Testing -# Then run -python -m unittest discover +The `gafferpy` tests are implemented using `tox` and `pytest`. +To run the tests, install the `gafferpy` 'dev' extra: +```bash +pip install -e ".[dev]" # the quotes ensure compatibilty with zsh ``` +This will install extra development dependecies for running tests and building documentation. -## Building the documentation +`gafferpy` has both unit tests and integration tests - the integration tests use the Road Traffic Example to test the Python API. If this is not running, the integration tests are skipped. It is advisable that the integration tests are run prior to any code commits to ensure they do not fail due to any code changes. -To build the docs locally, assuming you have Python installed, install the docs dependencies: +*For help starting the Road Traffic Example, see the [Quick Start](#quick-start) section above.* + +To run the tests, execute the below from the root directory of `gafferpy`: ```bash -cd docs -pip install -r requirements.txt +tox +``` +By default, `tox` will and try run the tests in multiple test envs (different Python versions) - if they do not exist then they are skipped. +To run the test for a specifc test env e.g. Python3.9, run: +```bash +tox -e py39 ``` -Then use the sphinx Makefile: +### Building the documentation + +To build the docs locally, assuming you have Make and Python installed, and `gafferpy` installed with the 'dev' extra: ```bash +cd docs make html ``` +### Generating the Python API +`gafferpy` has the ability to regenerate the Python API based upon the Gaffer REST API that a `GafferConnector` object is pointing at - a more detailed description and examples of how to do this can be found [here](./src/fishbowl/README.md). + ## License -Copyright 2016-2022 Crown Copyright +Copyright 2016-2023 Crown Copyright Licensed under the Apache License, Version 2.0 \(the "License"\); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/setup.py b/setup.py index c15dbaa1..56517d67 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ import re from codecs import open -from os import path +from pathlib import Path from setuptools import setup, find_packages ############################################################################### name = "gafferpy" packages = find_packages(where="src") -meta_path = path.join("src", "gafferpy", "__init__.py") +meta_path = Path("src", "gafferpy", "__init__.py") keywords = ["class", "attribute", "boilerplate"] classifiers = [ "Development Status :: 4 - Beta", @@ -24,20 +24,27 @@ python_requires = ">3.6" install_requires = [] extras_require = { - "requests": ["requests>=2.4.0"] + "requests": ["requests>=2.4.0"], + "dev": [ + "tox", + "pytest", + "requests>=2.4.0", + "sphinx~=7.2.6", + "sphinx-rtd-theme~=1.3.0" + ] } ############################################################################### -here = path.abspath(path.dirname(__file__)) +here = Path(__file__).parent -def read(*parts): +def read(parts): """ Build an absolute path from *parts* and and return the contents of the resulting file. Assume UTF-8 encoding. """ - with open(path.join(here, *parts), "rb", "utf-8") as f: + with open(here / parts, "rb", "utf-8") as f: return f.read() @@ -54,14 +61,14 @@ def find_meta(meta): ) if meta_match: return meta_match.group(1) - raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta)) + raise RuntimeError(f"Unable to find __{meta}__ string.") version = find_meta("version") uri = find_meta("uri") # Get the long description from the README.md file -with open(path.join(here, "README.md"), encoding="utf-8") as f: +with open(here / "README.md", encoding="utf-8") as f: long = f.read() setup( diff --git a/src/fishbowl/README.md b/src/fishbowl/README.md index 6b24c0ec..f187db32 100644 --- a/src/fishbowl/README.md +++ b/src/fishbowl/README.md @@ -1,7 +1,7 @@ # Fishbowl ## Features -Fishbowl generates code for the core gafferpy classes by pointing to a running Gaffer rest api. +Fishbowl generates code for the core `gafferpy` classes by pointing to a running Gaffer REST API. It generates the classes for: - [Operations](../gafferpy/generated_api/operations.py) @@ -10,12 +10,17 @@ It generates the classes for: - [Binary Operators](../gafferpy/generated_api/binary_operators.py) - [Config Endpoints](../gafferpy/generated_api/config.py) -This is done automatically on every Gaffer release from a standard spring-rest api and placed into gafferpy's [generated_api](../gafferpy/generated_api) directory. +This is done automatically on every Gaffer release from a standard spring-rest API and placed into `gafferpy`'s [generated_api](../gafferpy/generated_api) directory. -If you have custom Gaffer Java classes from the list above, fishbowl can generate the gafferpy classes for them. +If you have custom Gaffer Java classes from the list above, `fishbowl` can generate the `gafferpy` classes for them. ## Quick Start +To regenerate the core `gafferpy` library from a spring-rest Gaffer API, first start the Gaffer API from the root directory of the Gaffer repository: +```bash +mvn spring-boot:run -pl :spring-rest -Pdemo +``` +You can then use `fishbowl` to generate the Python API: ```python from gafferpy.gaffer_connector import GafferConnector from fishbowl.fishbowl import Fishbowl @@ -23,9 +28,9 @@ from fishbowl.fishbowl import Fishbowl gc = GafferConnector("http://localhost:8080/rest") fb = Fishbowl(gaffer_connector=gc) ``` -Your python files will be appear in a folder called `generated`. +Your Python files will be appear in a folder called `generated`. -You can then use these classes in normal gafferpy operations: +You can then use these classes in normal `gafferpy` operations: ```python import generated gc.execute(generated.operations.YourCustomOperation(custom_field=True)) @@ -39,7 +44,7 @@ gc.execute(generated.operations.OperationChain( ## License -Copyright 2019-2022 Crown Copyright +Copyright 2019-2023 Crown Copyright Licensed under the Apache License, Version 2.0 \(the "License"\); you may not use this file except in compliance with the License. You may obtain a copy of the License at diff --git a/src/fishbowl/fishbowl.py b/src/fishbowl/fishbowl.py index 341d62bc..5dd269d1 100644 --- a/src/fishbowl/fishbowl.py +++ b/src/fishbowl/fishbowl.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,30 +14,40 @@ # limitations under the License. # -import os +from pathlib import Path import re import shutil from jinja2 import Environment, FileSystemLoader +from gafferpy.gaffer_connector import GafferConnector from gafferpy.gaffer_core import JsonConverter from gafferpy.gaffer_types import parse_java_type_to_string +from collections import defaultdict +from typing import Any, Callable, Dict, List, Set class Fishbowl: - def __init__(self, gaffer_connector, generated_directory_path="generated"): + def __init__( + self, + gaffer_connector: GafferConnector, + generated_directory_path: str = "generated" + ): self._gaffer_connector = gaffer_connector self.generated_directory_path = generated_directory_path - print("Generating python Library from REST service") + print("Generating Python API from REST service...") self._generate_library() - print("done") - print("To import operations, predicates and functions, use the following command:") - print("from " + generated_directory_path + " import *") + print( + "Successfully generated Python API! To import operations, predicates and " + "functions, use the following command: " + f"\n`from {str(generated_directory_path)} import *`" + ) - def _write_to_file(self, file_path, data): + def _write_to_file(self, file_path: Path, data: str) -> None: if data: + file_path.unlink() # removes file with open(file_path, "w+") as file: file.write(data) - def _get_config_name(self, url): + def _get_config_name(self, url: str) -> str: name = url.replace("/graph", "").replace("/config", "") # Remove parameter name = re.sub(r"\/\{.*\}", "", name) @@ -46,20 +56,24 @@ def _get_config_name(self, url): name = "Get" + "".join([name[0].upper() + name[1:] for name in name.split("/")]) return name - def _get_function_dict(self): + def _get_function_dict(self) -> Dict[str, Callable]: return { "short_name": lambda n: n.rsplit(".", 1)[1].replace("$", ""), "snake_case": JsonConverter.to_snake_case, "get_fields": lambda f: self._gaffer_connector.get( - f"/graph/config/serialisedFields/{f}", json_result=True), + f"/graph/config/serialisedFields/{f}", json_result=True + ), + "get_field_types": lambda f: self._gaffer_connector.get( + f"/graph/config/serialisedFields/{f}/classes", json_result=True + ), "config_name": self._get_config_name, "get_config_parameter": lambda n: re.sub(r".*\{", "", re.sub(r"\}.*", "", n)), "parse_java_type": parse_java_type_to_string } def _generate_library(self): - parent_dir = os.path.dirname(__file__) - templates_dir = os.path.join(parent_dir, "templates") + parent_dir = Path(__file__).parent + templates_dir = parent_dir / "templates" file_loader = FileSystemLoader(templates_dir) self.env = Environment(loader=file_loader) @@ -69,46 +83,60 @@ def _generate_library(self): binary_operators_python = self._generate_aggregation_functions() config_python = self._generate_config() - if os.path.exists(self.generated_directory_path): - shutil.rmtree(self.generated_directory_path) - - os.mkdir(self.generated_directory_path) + if not self.generated_directory_path.exists(): + self.generated_directory_path.mkdir() self._write_to_file( - os.path.join(self.generated_directory_path, "functions.py"), functions_python) + self.generated_directory_path / "functions.py", + functions_python + ) self._write_to_file( - os.path.join(self.generated_directory_path, "predicates.py"), predicates_python) + self.generated_directory_path / "predicates.py", + predicates_python + ) self._write_to_file( - os.path.join( - self.generated_directory_path, "binary_operators.py"), binary_operators_python) + self.generated_directory_path / "binaryoperators.py", + binary_operators_python + ) self._write_to_file( - os.path.join(self.generated_directory_path, "operations.py"), operations_python) + self.generated_directory_path / "config.py", + config_python + ) self._write_to_file( - os.path.join(self.generated_directory_path, "config.py"), config_python) + self.generated_directory_path / "operations.py", + operations_python + ) self._write_to_file( - os.path.join(self.generated_directory_path, "__init__.py"), - "__all__ = [\"operations\", \"predicates\", \"functions\", \"binary_operators\", \"config\"]\n") + self.generated_directory_path / "__init__.py", + "__all__ = [\"operations\", \"predicates\", \"functions\", " + "\"binary_operators\", \"config\"]\n" + ) - def _generate_transform_functions(self): + def _generate_transform_functions(self) -> str: return self._generate_functions( "transformFunctions", - "gaffer_functions", - "AbstractFunction") + "AbstractFunction" + ) - def _generate_filter_functions(self): + def _generate_filter_functions(self) -> str: return self._generate_functions( "filterFunctions", - "gaffer_predicates", - "AbstractPredicate") + "AbstractPredicate" + ) - def _generate_aggregation_functions(self): + def _generate_aggregation_functions(self) -> str: return self._generate_functions( "aggregationFunctions", - "gaffer_binaryoperators", - "AbstractBinaryOperator") + "AbstractBinaryOperator" + ) - def _generate_functions(self, path, import_path, base_class): - # Older Gaffer versions may be missing some function end points + def _generate_functions( + self, + path: str, + base_class: str, + base_class_import_path: str = "gafferpy.gaffer_core" + ) -> str: + # Older Gaffer versions may be missing some function endpoints try: functions = self._gaffer_connector.get(f"/graph/config/{path}", json_result=True) except ConnectionError: @@ -116,15 +144,19 @@ def _generate_functions(self, path, import_path, base_class): return "" functions = sorted(functions) + manual_imports = {base_class_import_path: {base_class}} + imports = self._generate_import_strings(functions, manual_imports) function_template = self.env.get_template("functions.py.j2") function_template.globals.update(self._get_function_dict()) return function_template.render( functions=functions, - import_path=import_path, - base_class=base_class) + import_path=base_class_import_path, + base_class=base_class, + imports=imports + ) - def _generate_operations(self): + def _generate_operations(self) -> str: # spring-rest has an endpoint for every store operation, even ones unsupported by the store # Check if this is supported: 2.0.0+, 1.23.0+ try: @@ -140,11 +172,18 @@ def _generate_operations(self): operation_summaries = sorted(operation_summaries, key=lambda op: op["name"]) + op_names = [op['name'] for op in operation_summaries] + + imports = self._generate_import_strings(op_names) + template = self.env.get_template("operations.py.j2") template.globals.update(self._get_function_dict()) - return template.render(operations=operation_summaries) + return template.render( + operations=operation_summaries, + imports=imports + ) - def _generate_config(self): + def _generate_config(self) -> str: # Gaffer 2 spring-rest uses openapi3 rather than swagger2 try: api_summaries = self._gaffer_connector.get("/v3/api-docs", json_result=True) @@ -155,15 +194,61 @@ def _generate_config(self): print(f"swagger information not present, skipping config") return "" - configs = [] - for path, data in api_summaries["paths"].items(): - if path.startswith("/graph/") and "get" in data: - configs.append(path) + configs = [ + path for path, data in api_summaries["paths"].items() + if path.startswith("/graph/") and "get" in data + ] template = self.env.get_template("config.py.j2") template.globals.update(self._get_function_dict()) return template.render(configs=configs) + def _generate_import_strings(self, + funcs: List[Any], + manual_imports: Dict[str, + Set] = dict()) -> List[str]: + """ + To stop circular import issues during generation, we only want to import the specific class names we need. + I.e. rather than `from gafferpy.gaffer_binaroperators import *`, we want + `from gafferpy.gaffer_binaryoperators import BinaryOperator, ...` + + Args: + funcs: List of Gaffer Functions, Predicates or BinaryOperators for which to generate import strings. + manual_imports: Dictionary of manual imports to add, where the keys are manual import paths and values are + the class to import. + + Returns: + List of import strings e.g. `from gafferpy.gaffer_binaryoperators import BinaryOperator` + + """ + get_field_types = self._get_function_dict()['get_field_types'] + + class_names = [func.split(".")[-1] for func in funcs] + + import_map = defaultdict(set) + #  add the manual imports first + import_map.update(manual_imports) + + for func in funcs: + for java_type in get_field_types(func).values(): + python_type = parse_java_type_to_string(java_type) + if 'gafferpy' not in python_type: + continue + + gafferpy_import = re.findall("gafferpy[\\w+ \\.]*", python_type)[0] + gafferpy_import = gafferpy_import.replace("generated_api.", "gaffer_") + import_parts = gafferpy_import.split('.') + module = ".".join(import_parts[:-1]) + _class = import_parts[-1] + # only import classes not already defined in the file in question + if _class not in class_names: + import_map[module].add(_class) + + return [ + f"from {import_path} import {', '.join(sorted(classes))}" for import_path, + classes in import_map.items() + ] + def get_connector(self): return self._gaffer_connector diff --git a/src/fishbowl/templates/base.py.j2 b/src/fishbowl/templates/base.py.j2 index 635c183a..60833964 100644 --- a/src/fishbowl/templates/base.py.j2 +++ b/src/fishbowl/templates/base.py.j2 @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. diff --git a/src/fishbowl/templates/config.py.j2 b/src/fishbowl/templates/config.py.j2 index a37556a7..550f9e37 100644 --- a/src/fishbowl/templates/config.py.j2 +++ b/src/fishbowl/templates/config.py.j2 @@ -12,10 +12,9 @@ class {{ config_name(conf) }}(GetGraph): def __init__(self): {%- endif %} {%- if '{' in conf %} - super().__init__( - '{{ conf }}'.format({{ get_config_parameter(conf) }}={{ snake_case(get_config_parameter(conf)) }})) + super().__init__(f"{{ conf | replace(get_config_parameter(conf), snake_case(get_config_parameter(conf))) }}") {%- else %} - super().__init__('{{ conf }}') + super().__init__("{{ conf }}") {%- endif %} {%- endfor %} diff --git a/src/fishbowl/templates/functions.py.j2 b/src/fishbowl/templates/functions.py.j2 index f905d088..0021e109 100644 --- a/src/fishbowl/templates/functions.py.j2 +++ b/src/fishbowl/templates/functions.py.j2 @@ -1,9 +1,15 @@ {% extends 'base.py.j2' %} {% block content %} -from gafferpy.{{ import_path }} import {{ base_class }} +import typing + +{%- for import in imports %} +{{ import }} +{%- endfor %} + {%- for func in functions %} {%- set fields = get_fields(func) %} +{%- set field_types_dict = get_field_types(func) %} class {{ short_name(func) }}({{ base_class }}): @@ -11,11 +17,11 @@ class {{ short_name(func) }}({{ base_class }}): {%- if fields|length > 0 %} def __init__( - self, - {%- for field in (fields[:-1]) %} - {{ snake_case(field) }}=None, - {%- endfor %} - {{ snake_case(fields[-1]) }}=None): + self, + {%- for field in (fields) %} + {{ snake_case(field) }}: typing.Optional[{{ parse_java_type(field_types_dict.get(field), False) }}] = None, + {%- endfor %} + ): {%- else %} def __init__(self): diff --git a/src/fishbowl/templates/operations.py.j2 b/src/fishbowl/templates/operations.py.j2 index fa8a5946..9e7c2210 100644 --- a/src/fishbowl/templates/operations.py.j2 +++ b/src/fishbowl/templates/operations.py.j2 @@ -3,9 +3,9 @@ {% block content %} import typing -import gafferpy.gaffer_core -import gafferpy.gaffer_functions -from gafferpy.gaffer_operations import Operation, View, Conditional, AggregatePair +{%- for import in imports %} +{{ import }} +{%- endfor %} {% for op in operations %} {%- if op.name != "uk.gov.gchq.gaffer.operation.OperationChainDAO" %} @@ -26,13 +26,15 @@ class {{ short_name(op.name) }}(Operation): CLASS = "{{ op.name }}" def __init__( - self, - {%- for field in op.fields|sort(reverse=true, attribute="required") %} - {%- if field.name != "options" %} - {{ snake_case(field.name) }}: {{ parse_java_type(field.className) }}{% if not field.required %} = None{% endif %}, - {%- endif %} - {%- endfor %} - options: typing.Dict[str, str] = None): + self, + {%- for field in op.fields|sort(reverse=true, attribute="required") %} + {%- if field.name != "options" %} + {{ snake_case(field.name) }}: {% if field.required %}{{ parse_java_type(field.className, False) }}{% else %}typing.Optional[{{ parse_java_type(field.className, False) }}] = None{% endif %}, + {%- endif %} + {%- endfor %} + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) {%- for field in op.fields %} {%- if field.name != "options" %} diff --git a/src/gafferpy/gaffer_binaryoperators.py b/src/gafferpy/gaffer_binaryoperators.py index 8d88bab1..ad263a9f 100755 --- a/src/gafferpy/gaffer_binaryoperators.py +++ b/src/gafferpy/gaffer_binaryoperators.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,45 +21,6 @@ from gafferpy.gaffer_core import * -class BinaryOperator(ToJson, ToCodeString): - CLASS = "java.util.function.BinaryOperator" - - def __init__(self, class_name=None, fields=None): - self.class_name = class_name - self.fields = fields - - def to_json(self): - if self.fields is not None: - function_json = dict(self.fields) - else: - function_json = {} - - if self.class_name is not None: - function_json['class'] = self.class_name - - return function_json - - -class AbstractBinaryOperator(BinaryOperator): - CLASS = "java.util.function.BinaryOperator" - - def __init__(self, _class_name=None): - super().__init__() - self._class_name = _class_name - - def to_json(self): - function_json = {} - - if self._class_name is not None: - function_json['class'] = self._class_name - - return function_json - - -# Import generated binary operator implementations from fishbowl -from gafferpy.generated_api.binary_operators import * - - class BinaryOperatorContext(ToJson, ToCodeString): CLASS = "gaffer.AggregatorContext" @@ -80,6 +41,10 @@ def to_json(self): return function_json +# Import generated binary operator implementations from fishbowl +from gafferpy.generated_api.binaryoperators import * + + def binary_operator_context_converter(obj): if 'class' in obj: binary_operator = dict(obj) diff --git a/src/gafferpy/gaffer_core.py b/src/gafferpy/gaffer_core.py index 97f90e11..2714e5de 100755 --- a/src/gafferpy/gaffer_core.py +++ b/src/gafferpy/gaffer_core.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -532,3 +532,105 @@ def load_core_json_map(): load_core_json_map() + + +class BinaryOperator(ToJson, ToCodeString): + CLASS = "java.util.function.BinaryOperator" + + def __init__(self, class_name=None, fields=None): + self.class_name = class_name + self.fields = fields + + def to_json(self): + if self.fields is not None: + function_json = dict(self.fields) + else: + function_json = {} + + if self.class_name is not None: + function_json['class'] = self.class_name + + return function_json + + +class AbstractBinaryOperator(BinaryOperator): + CLASS = "java.util.function.BinaryOperator" + + def __init__(self, _class_name=None): + super().__init__() + self._class_name = _class_name + + def to_json(self): + function_json = {} + + if self._class_name is not None: + function_json['class'] = self._class_name + + return function_json + + +class Predicate(ToJson, ToCodeString): + CLASS = "java.util.function.Predicate" + + def __init__(self, class_name=None, fields=None): + self.class_name = class_name + self.fields = fields + + def to_json(self): + if self.fields is not None: + predicate_json = dict(self.fields) + else: + predicate_json = {} + + if self.class_name is not None: + predicate_json['class'] = self.class_name + + return predicate_json + + +class AbstractPredicate(Predicate): + def __init__(self, _class_name=None): + super().__init__() + self._class_name = _class_name + + def to_json(self): + predicate_json = {} + + if self._class_name is not None: + predicate_json['class'] = self._class_name + + return predicate_json + + +class Function(ToJson, ToCodeString): + CLASS = "java.util.function.Function" + + def __init__(self, class_name=None, fields=None): + self.class_name = class_name + self.fields = fields + + def to_json(self): + if self.fields is not None: + function_json = dict(self.fields) + else: + function_json = {} + + if self.class_name is not None: + function_json['class'] = self.class_name + + return function_json + + +class AbstractFunction(Function): + CLASS = "java.util.function.Function" + + def __init__(self, _class_name=None): + super().__init__() + self._class_name = _class_name + + def to_json(self): + function_json = {} + if self._class_name is not None: + function_json['class'] = self._class_name + + return function_json diff --git a/src/gafferpy/gaffer_functions.py b/src/gafferpy/gaffer_functions.py index 68bc7dd8..c4bdbd0e 100755 --- a/src/gafferpy/gaffer_functions.py +++ b/src/gafferpy/gaffer_functions.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,50 +20,16 @@ """ from gafferpy.gaffer_core import * -import gafferpy.gaffer_predicates as pred -import gafferpy.gaffer_binaryoperators as bop - - -class Function(ToJson, ToCodeString): - CLASS = "java.util.function.Function" - - def __init__(self, class_name=None, fields=None): - self.class_name = class_name - self.fields = fields - - def to_json(self): - if self.fields is not None: - function_json = dict(self.fields) - else: - function_json = {} - - if self.class_name is not None: - function_json['class'] = self.class_name - - return function_json - - -class AbstractFunction(Function): - CLASS = "java.util.function.Function" - - def __init__(self, _class_name=None): - super().__init__() - self._class_name = _class_name - - def to_json(self): - function_json = {} - if self._class_name is not None: - function_json['class'] = self._class_name - - return function_json class ElementGenerator(Function): CLASS = 'uk.gov.gchq.gaffer.data.generator.ElementGenerator' - def __init__(self, - class_name, - fields=None): + def __init__( + self, + class_name, + fields=None + ): super().__init__(class_name=class_name, fields=fields) diff --git a/src/gafferpy/gaffer_predicates.py b/src/gafferpy/gaffer_predicates.py index 8ca68d24..d9e5140a 100755 --- a/src/gafferpy/gaffer_predicates.py +++ b/src/gafferpy/gaffer_predicates.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -41,39 +41,6 @@ def to_json(self): return predicate_json -class Predicate(ToJson, ToCodeString): - CLASS = "java.util.function.Predicate" - - def __init__(self, class_name=None, fields=None): - self.class_name = class_name - self.fields = fields - - def to_json(self): - if self.fields is not None: - predicate_json = dict(self.fields) - else: - predicate_json = {} - - if self.class_name is not None: - predicate_json['class'] = self.class_name - - return predicate_json - - -class AbstractPredicate(Predicate): - def __init__(self, _class_name=None): - super().__init__() - self._class_name = _class_name - - def to_json(self): - predicate_json = {} - - if self._class_name is not None: - predicate_json['class'] = self._class_name - - return predicate_json - - class TimeUnit: DAY = 'DAY' HOUR = 'HOUR' @@ -86,9 +53,8 @@ class TimeUnit: # Import generated predicate implementations from fishbowl from gafferpy.generated_api.predicates import * -# Add an alternative name for IntegerTupleAdaptedPredicate - +# Add an alternative name for IntegerTupleAdaptedPredicate class NestedPredicate(IntegerTupleAdaptedPredicate): pass diff --git a/src/gafferpy/gaffer_types.py b/src/gafferpy/gaffer_types.py index 3c597059..80567d5d 100755 --- a/src/gafferpy/gaffer_types.py +++ b/src/gafferpy/gaffer_types.py @@ -19,19 +19,39 @@ This module contains Python copies of common Gaffer java types. """ -from typing import List, Dict, Any, Tuple, Set +from typing import Any, Dict, List, Optional, Set, Tuple +import logging +import re -from gafferpy.gaffer_core import ElementSeed, EntitySeed, EdgeSeed, Element, JsonConverter +from gafferpy.gaffer_core import ElementSeed, EntitySeed, EdgeSeed, Element, JsonConverter, Function, BinaryOperator, Predicate from gafferpy.gaffer_operations import Operation -anys = "T", "Object", "Object[]", "?", "OBJ", "java.lang.Object", "I", "I_ITEM", "java.lang.Class", "uk.gov.gchq.gaffer.access.predicate.AccessPredicate", "java.util.function.Function" -lists = "java.lang.Iterable", "java.util.List" +logging.basicConfig(level=logging.WARNING) +logger = logging.getLogger(__name__) + +anys = ( + "T", "Object", "Object[]", "?", "OBJ", "java.lang.Object", "I", "I_ITEM", + "java.lang.Class", "uk.gov.gchq.gaffer.access.predicate.AccessPredicate" +) +lists = "java.lang.Iterable", "java.util.List", "java.util.Collection" dicts = "java.util.Map", "java.util.LinkedHashMap", "java.util.Properties", "uk.gov.gchq.gaffer.store.schema.Schema" strings = "java.lang.String", "char" ints = "java.lang.Integer", "java.lang.Long", "int" -def parse_java_type_to_string(java_type: str) -> str: +def parse_java_type_to_string(java_type: str, return_full_path: bool = True) -> str: + """ + Parse a Java type into a Python type and return as a string. + + Args: + java_type: String of a Java type + return_full_path: Whether to return the full `gafferpy` path to a class i.e. + `gafferpy.gaffer_core.Function`, or just the class i.e. `Function` + + Returns: + String of Python type + """ + python_type = parse_java_type(java_type) if isinstance(python_type, type): if python_type.__module__ == "builtins": @@ -40,12 +60,24 @@ def parse_java_type_to_string(java_type: str) -> str: else: type_name = str(python_type) - type_name = type_name.replace("gafferpy.gaffer_operations.", "") - type_name = type_name.replace("gafferpy.generated_api.operations.", "") + if return_full_path is False and 'gafferpy' in type_name: + gafferpy_class = re.findall("gafferpy[\\w+ \\.]*", type_name)[0] + # replace the full gafferpy path with just class name + type_name = type_name.replace(gafferpy_class, gafferpy_class.split('.')[-1]) + return type_name def parse_java_type(java_type: str) -> type: + """ + Parse a Java type into a Python type object. + + Args: + java_type: String of a Java type + + Returns: + Python type + """ if "[]" in java_type: array_type = java_type.split("[]")[0] return List[parse_java_type(array_type)] @@ -57,7 +89,18 @@ def parse_java_type(java_type: str) -> type: return Any if inner_type in anys: return parse_java_type(outter_type) - return parse_java_type(outter_type)[parse_java_type(inner_type)] + try: + return parse_java_type(outter_type)[parse_java_type(inner_type)] + except BaseException: + if "java.util.function.BinaryOperator" in java_type: + return BinaryOperator + if "java.util.function.Function" in java_type: + return Function + if "java.util.function.Predicate" in java_type: + return Predicate + logger.warning( + f"Unable to determine Python type for Java type {java_type}, using typing.Any") + return Any if "," in java_type: split = java_type.split(",") first_type = split[0] @@ -98,18 +141,71 @@ def parse_java_type(java_type: str) -> type: def long(value: int) -> Dict[str, int]: + """ + Convert integer value to an object that Gaffer can serialise into a Java Long type. + + Args: + value: Integer value to convert + + Returns: + Dictionary that can be serialised to a Java Long. + """ return {"java.lang.Long": value} def date(value: int) -> Dict[str, int]: + """ + Convert integer value to an object that Gaffer can serialise into a Java Date type. + + Args: + value: Integer value to convert + + Returns: + Dictionary that can be serialised to a Java Date. + """ return {"java.util.Date": value} def freq_map(map_value: Dict[Any, int]) -> Dict[str, Dict[Any, int]]: + """ + Convert {k:v} dict to an object that Gaffer can serialise into a Gaffer FreqMap type. + + Args: + value: Dictionary to convert + + Returns: + Dictionary that can be serialised to a Gaffer FreqMap. + """ return {"uk.gov.gchq.gaffer.types.FreqMap": map_value} -def type_value(type: Any = None, value: Any = None) -> Dict[str, Dict[str, Any]]: +def tree_set(set: Set[Any]) -> Dict[str, Set[Any]]: + """ + Convert set to an object that Gaffer can serialise into a Java TreeSet type. + + Args: + set: Set to convert + + Returns: + Dictionary that can be serialised to a Java TreeSet. + """ + return {"java.util.TreeSet": set} + + +def type_value( + type: Optional[Any] = None, + value: Optional[Any] = None +) -> Dict[str, Dict[str, Any]]: + """ + Convert a type and value to an object that Gaffer can serialise into a Gaffer TypeSubTypeValue type. + + Args: + type: Populates `type` field in a Gaffer TypeSubTypeValue object + value: Populates `value` field in a Gaffer TypeSubTypeValue object + + Returns: + Dictionary that can be serialised to a Gaffer TypeSubTypeValue. + """ map = {} if type is not None: map["type"] = type @@ -118,8 +214,22 @@ def type_value(type: Any = None, value: Any = None) -> Dict[str, Dict[str, Any]] return {"uk.gov.gchq.gaffer.types.TypeSubTypeValue": map} -def type_subtype_value(type: Any = None, subType: Any = None, - value: Any = None) -> Dict[str, Dict[str, Any]]: +def type_subtype_value( + type: Optional[Any] = None, + subType: Optional[Any] = None, + value: Optional[Any] = None +) -> Dict[str, Dict[str, Any]]: + """ + Convert a type, subType and value to an object that Gaffer can serialise into a Gaffer TypeSubTypeValue type. + + Args: + type: Populates `type` field in a Gaffer TypeSubTypeValue object + subType: Populates `subType` field in a Gaffer TypeSubTypeValue object + value: Populates `value` field in a Gaffer TypeSubTypeValue object + + Returns: + Dictionary that can be serialised to a Gaffer TypeSubTypeValue. + """ map = {} if type is not None: map["type"] = type @@ -130,11 +240,43 @@ def type_subtype_value(type: Any = None, subType: Any = None, return {"uk.gov.gchq.gaffer.types.TypeSubTypeValue": map} -def tree_set(set: Set[Any]) -> Dict[str, Set[Any]]: - return {"java.util.TreeSet": set} +def hyper_log_log_plus( + offers: List[Any], + p: int = 5, + sp: int = 5 +) -> Dict[str, Dict[str, Dict[str, Any]]]: + """ + Convert a list of objects to an object that Gaffer can serialise into a HyperLogLogPlus Sketch. + Args: + offers: Objects to add to the Sketch + p: Defines the accuracy and ultimately the size of Sketch. + sp: Defines the error properties of the Sketch sparse mode. -def hyper_log_log_plus(offers: List[Any], p: int = 5, - sp: int = 5) -> Dict[str, Dict[str, Dict[str, Any]]]: + Returns: + Dictionary that can be serialised to a clearspring HyperLogLogPlus Sketch. + """ return {"com.clearspring.analytics.stream.cardinality.HyperLogLogPlus": { "hyperLogLogPlus": {"p": p, "sp": sp, "offers": offers}}} + + +def hll_sketch( + values: List[Any], + log_k: int = 10 +) -> Dict[str, Dict[str, Any]]: + """ + Convert a list of objects to an object that Gaffer can serialise into a HyperLogLog Sketch. + + Args: + values: Objects to add to the Sketch + log_k: Defines the accuracy and ultimately the size of Sketch. + + Returns: + Dictionary that can be serialised to a clearspring HyperLogLog Sketch. + """ + return { + "org.apache.datasketches.hll.HllSketch": { + "logK": log_k, + "values": values + } + } diff --git a/src/gafferpy/generated_api/binary_operators.py b/src/gafferpy/generated_api/binaryoperators.py similarity index 92% rename from src/gafferpy/generated_api/binary_operators.py rename to src/gafferpy/generated_api/binaryoperators.py index c73a9285..25cf37c5 100644 --- a/src/gafferpy/generated_api/binary_operators.py +++ b/src/gafferpy/generated_api/binaryoperators.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -19,7 +19,8 @@ To make changes, either extend these classes or change fishbowl. """ -from gafferpy.gaffer_binaryoperators import AbstractBinaryOperator +import typing +from gafferpy.gaffer_core import AbstractBinaryOperator, BinaryOperator, Function class RoaringBitmapAggregator(AbstractBinaryOperator): @@ -36,8 +37,9 @@ class ElementAggregator(AbstractBinaryOperator): CLASS = "uk.gov.gchq.gaffer.data.element.function.ElementAggregator" def __init__( - self, - operators=None): + self, + operators: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.operators = operators @@ -282,8 +284,9 @@ class CustomMapAggregator(AbstractBinaryOperator): CLASS = "uk.gov.gchq.gaffer.types.binaryoperator.CustomMapAggregator" def __init__( - self, - binary_operator=None): + self, + binary_operator: typing.Optional[BinaryOperator] = None, + ): super().__init__(_class_name=self.CLASS) self.binary_operator = binary_operator @@ -308,10 +311,11 @@ class AdaptedBinaryOperator(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.binaryoperator.AdaptedBinaryOperator" def __init__( - self, - input_adapter=None, - binary_operator=None, - output_adapter=None): + self, + input_adapter: typing.Optional[Function] = None, + binary_operator: typing.Optional[BinaryOperator] = None, + output_adapter: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.input_adapter = input_adapter self.binary_operator = binary_operator @@ -332,8 +336,9 @@ class BinaryOperatorComposite(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.binaryoperator.BinaryOperatorComposite" def __init__( - self, - operators=None): + self, + operators: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.operators = operators @@ -348,8 +353,9 @@ class BinaryOperatorMap(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.binaryoperator.BinaryOperatorMap" def __init__( - self, - binary_operator=None): + self, + binary_operator: typing.Optional[BinaryOperator] = None, + ): super().__init__(_class_name=self.CLASS) self.binary_operator = binary_operator @@ -454,8 +460,9 @@ class StringConcat(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat" def __init__( - self, - separator=None): + self, + separator: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.separator = separator @@ -470,8 +477,9 @@ class StringDeduplicateConcat(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.impl.binaryoperator.StringDeduplicateConcat" def __init__( - self, - separator=None): + self, + separator: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.separator = separator @@ -496,11 +504,12 @@ class TupleAdaptedBinaryOperator(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperator" def __init__( - self, - input_adapter=None, - selection=None, - binary_operator=None, - output_adapter=None): + self, + input_adapter: typing.Optional[Function] = None, + selection: typing.Optional[typing.List[typing.Any]] = None, + binary_operator: typing.Optional[BinaryOperator] = None, + output_adapter: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.input_adapter = input_adapter self.selection = selection @@ -524,8 +533,9 @@ class TupleAdaptedBinaryOperatorComposite(AbstractBinaryOperator): CLASS = "uk.gov.gchq.koryphe.tuple.binaryoperator.TupleAdaptedBinaryOperatorComposite" def __init__( - self, - operators=None): + self, + operators: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.operators = operators diff --git a/src/gafferpy/generated_api/config.py b/src/gafferpy/generated_api/config.py index 61b7fc38..a7307834 100644 --- a/src/gafferpy/generated_api/config.py +++ b/src/gafferpy/generated_api/config.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -24,117 +24,109 @@ class GetJobs(GetGraph): def __init__(self): - super().__init__('/graph/jobs') + super().__init__("/graph/jobs") class GetStatus(GetGraph): def __init__(self): - super().__init__('/graph/status') + super().__init__("/graph/status") class GetOperations(GetGraph): def __init__(self): - super().__init__('/graph/operations') + super().__init__("/graph/operations") class GetOperations(GetGraph): def __init__(self, class_name=""): - super().__init__( - '/graph/operations/{className}'.format(className=class_name)) + super().__init__(f"/graph/operations/{class_name}") class GetOperationsNext(GetGraph): def __init__(self, class_name=""): - super().__init__( - '/graph/operations/{className}/next'.format(className=class_name)) + super().__init__(f"/graph/operations/{class_name}/next") class GetOperationsExample(GetGraph): def __init__(self, class_name=""): - super().__init__( - '/graph/operations/{className}/example'.format(className=class_name)) + super().__init__(f"/graph/operations/{class_name}/example") class GetOperationsDetails(GetGraph): def __init__(self): - super().__init__('/graph/operations/details') + super().__init__("/graph/operations/details") class GetOperationsDetailsAll(GetGraph): def __init__(self): - super().__init__('/graph/operations/details/all') + super().__init__("/graph/operations/details/all") class GetJobs(GetGraph): def __init__(self, id=""): - super().__init__( - '/graph/jobs/{id}'.format(id=id)) + super().__init__(f"/graph/jobs/{id}") class GetJobsResults(GetGraph): def __init__(self, id=""): - super().__init__( - '/graph/jobs/{id}/results'.format(id=id)) + super().__init__(f"/graph/jobs/{id}/results") class GetTransformFunctions(GetGraph): def __init__(self): - super().__init__('/graph/config/transformFunctions') + super().__init__("/graph/config/transformFunctions") class GetStoreTraits(GetGraph): def __init__(self): - super().__init__('/graph/config/storeTraits') + super().__init__("/graph/config/storeTraits") class GetSerialisedFields(GetGraph): def __init__(self, class_name=""): - super().__init__( - '/graph/config/serialisedFields/{className}'.format(className=class_name)) + super().__init__(f"/graph/config/serialisedFields/{class_name}") class GetSerialisedFieldsClasses(GetGraph): def __init__(self, class_name=""): - super().__init__( - '/graph/config/serialisedFields/{className}/classes'.format(className=class_name)) + super().__init__(f"/graph/config/serialisedFields/{class_name}/classes") class GetSchema(GetGraph): def __init__(self): - super().__init__('/graph/config/schema') + super().__init__("/graph/config/schema") class GetObjectGenerators(GetGraph): def __init__(self): - super().__init__('/graph/config/objectGenerators') + super().__init__("/graph/config/objectGenerators") class GetId(GetGraph): def __init__(self): - super().__init__('/graph/config/graphId') + super().__init__("/graph/config/graphId") class GetFilterFunctions(GetGraph): def __init__(self): - super().__init__('/graph/config/filterFunctions') + super().__init__("/graph/config/filterFunctions") class GetFilterFunctions(GetGraph): def __init__(self, input_class=""): - super().__init__( - '/graph/config/filterFunctions/{inputClass}'.format(inputClass=input_class)) + super().__init__(f"/graph/config/filterFunctions/{input_class}") class GetElementGenerators(GetGraph): def __init__(self): - super().__init__('/graph/config/elementGenerators') + super().__init__("/graph/config/elementGenerators") class GetDescription(GetGraph): def __init__(self): - super().__init__('/graph/config/description') + super().__init__("/graph/config/description") class GetAggregationFunctions(GetGraph): def __init__(self): - super().__init__('/graph/config/aggregationFunctions') + super().__init__("/graph/config/aggregationFunctions") diff --git a/src/gafferpy/generated_api/functions.py b/src/gafferpy/generated_api/functions.py index cd40e51a..99e0904d 100644 --- a/src/gafferpy/generated_api/functions.py +++ b/src/gafferpy/generated_api/functions.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -19,15 +19,17 @@ To make changes, either extend these classes or change fishbowl. """ -from gafferpy.gaffer_functions import AbstractFunction +import typing +from gafferpy.gaffer_core import AbstractFunction, BinaryOperator, Function, Predicate class ElementTransformer(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.ElementTransformer" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions @@ -52,8 +54,9 @@ class ExtractId(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.ExtractId" def __init__( - self, - id=None): + self, + id: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.id = id @@ -68,8 +71,9 @@ class ExtractProperty(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.ExtractProperty" def __init__( - self, - name=None): + self, + name: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.name = name @@ -84,8 +88,9 @@ class PropertiesTransformer(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.PropertiesTransformer" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions @@ -100,11 +105,12 @@ class ReduceRelatedElements(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.ReduceRelatedElements" def __init__( - self, - visibility_aggregator=None, - vertex_aggregator=None, - related_vertex_groups=None, - visibility_property=None): + self, + visibility_aggregator: typing.Optional[BinaryOperator] = None, + vertex_aggregator: typing.Optional[BinaryOperator] = None, + related_vertex_groups: typing.Optional[typing.Set[str]] = None, + visibility_property: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.visibility_aggregator = visibility_aggregator self.vertex_aggregator = vertex_aggregator @@ -148,9 +154,10 @@ class TupleToElements(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.TupleToElements" def __init__( - self, - elements=None, - use_group_mapping=None): + self, + elements: typing.Optional[typing.List[typing.Any]] = None, + use_group_mapping: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.elements = elements self.use_group_mapping = use_group_mapping @@ -168,9 +175,10 @@ class TuplesToElements(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.element.function.TuplesToElements" def __init__( - self, - elements=None, - use_group_mapping=None): + self, + elements: typing.Optional[typing.List[typing.Any]] = None, + use_group_mapping: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.elements = elements self.use_group_mapping = use_group_mapping @@ -218,13 +226,14 @@ class CsvGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.CsvGenerator" def __init__( - self, - quoted=None, - comma_replacement=None, - include_default_fields=None, - include_schema_properties=None, - constants=None, - fields=None): + self, + quoted: typing.Optional[bool] = None, + comma_replacement: typing.Optional[str] = None, + include_default_fields: typing.Optional[bool] = None, + include_schema_properties: typing.Optional[bool] = None, + constants: typing.Optional[typing.Dict[str, str]] = None, + fields: typing.Optional[typing.Dict[str, str]] = None, + ): super().__init__(_class_name=self.CLASS) self.quoted = quoted self.comma_replacement = comma_replacement @@ -264,9 +273,10 @@ class MapGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.MapGenerator" def __init__( - self, - constants=None, - fields=None): + self, + constants: typing.Optional[typing.Dict[str, str]] = None, + fields: typing.Optional[typing.Dict[str, str]] = None, + ): super().__init__(_class_name=self.CLASS) self.constants = constants self.fields = fields @@ -284,11 +294,12 @@ class Neo4jCsvElementGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.Neo4jCsvElementGenerator" def __init__( - self, - first_row=None, - trim=None, - delimiter=None, - null_string=None): + self, + first_row: typing.Optional[int] = None, + trim: typing.Optional[bool] = None, + delimiter: typing.Optional[str] = None, + null_string: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.first_row = first_row self.trim = trim @@ -312,13 +323,14 @@ class Neo4jCsvGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.Neo4jCsvGenerator" def __init__( - self, - quoted=None, - comma_replacement=None, - include_default_fields=None, - include_schema_properties=None, - constants=None, - fields=None): + self, + quoted: typing.Optional[bool] = None, + comma_replacement: typing.Optional[str] = None, + include_default_fields: typing.Optional[bool] = None, + include_schema_properties: typing.Optional[bool] = None, + constants: typing.Optional[typing.Dict[str, str]] = None, + fields: typing.Optional[typing.Dict[str, str]] = None, + ): super().__init__(_class_name=self.CLASS) self.quoted = quoted self.comma_replacement = comma_replacement @@ -348,11 +360,12 @@ class NeptuneCsvElementGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.NeptuneCsvElementGenerator" def __init__( - self, - first_row=None, - trim=None, - delimiter=None, - null_string=None): + self, + first_row: typing.Optional[int] = None, + trim: typing.Optional[bool] = None, + delimiter: typing.Optional[str] = None, + null_string: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.first_row = first_row self.trim = trim @@ -376,13 +389,14 @@ class NeptuneCsvGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.generator.NeptuneCsvGenerator" def __init__( - self, - quoted=None, - comma_replacement=None, - include_default_fields=None, - include_schema_properties=None, - constants=None, - fields=None): + self, + quoted: typing.Optional[bool] = None, + comma_replacement: typing.Optional[str] = None, + include_default_fields: typing.Optional[bool] = None, + include_schema_properties: typing.Optional[bool] = None, + constants: typing.Optional[typing.Dict[str, str]] = None, + fields: typing.Optional[typing.Dict[str, str]] = None, + ): super().__init__(_class_name=self.CLASS) self.quoted = quoted self.comma_replacement = comma_replacement @@ -422,8 +436,9 @@ class ExtractWalkEdgesFromHop(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop" def __init__( - self, - hop=None): + self, + hop: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.hop = hop @@ -448,8 +463,9 @@ class ExtractWalkEntitiesFromHop(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEntitiesFromHop" def __init__( - self, - hop=None): + self, + hop: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.hop = hop @@ -484,8 +500,9 @@ class EntityIdExtractor(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor" def __init__( - self, - edge_identifier_to_extract=None): + self, + edge_identifier_to_extract: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.edge_identifier_to_extract = edge_identifier_to_extract @@ -540,8 +557,9 @@ class ToTrailingWildcardPair(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.operation.function.ToTrailingWildcardPair" def __init__( - self, - end_of_range=None): + self, + end_of_range: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.end_of_range = end_of_range @@ -586,15 +604,18 @@ class HyperLogLogPlusEntityGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.HyperLogLogPlusEntityGenerator" def __init__( - self, - properties_to_copy=None, - count_property=None, - cardinality_property_name=None, - edge_group_property=None, - vertex_value_converter=None, - group=None): + self, + properties_to_copy: typing.Optional[typing.List[str]] = None, + to_sketch_function: typing.Optional[typing.Any] = None, + count_property: typing.Optional[str] = None, + cardinality_property_name: typing.Optional[str] = None, + edge_group_property: typing.Optional[str] = None, + vertex_value_converter: typing.Optional[Function] = None, + group: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.properties_to_copy = properties_to_copy + self.to_sketch_function = to_sketch_function self.count_property = count_property self.cardinality_property_name = cardinality_property_name self.edge_group_property = edge_group_property @@ -605,6 +626,8 @@ def to_json(self): function_json = super().to_json() if self.properties_to_copy is not None: function_json["propertiesToCopy"] = self.properties_to_copy + if self.to_sketch_function is not None: + function_json["toSketchFunction"] = self.to_sketch_function if self.count_property is not None: function_json["countProperty"] = self.count_property if self.cardinality_property_name is not None: @@ -622,9 +645,10 @@ class IterableToHyperLogLogPlus(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.function.IterableToHyperLogLogPlus" def __init__( - self, - p=None, - sp=None): + self, + p: typing.Optional[int] = None, + sp: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.p = p self.sp = sp @@ -642,9 +666,10 @@ class ToHyperLogLogPlus(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.function.ToHyperLogLogPlus" def __init__( - self, - p=None, - sp=None): + self, + p: typing.Optional[int] = None, + sp: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.p = p self.sp = sp @@ -662,15 +687,18 @@ class HllSketchEntityGenerator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.datasketches.cardinality.HllSketchEntityGenerator" def __init__( - self, - properties_to_copy=None, - count_property=None, - cardinality_property_name=None, - edge_group_property=None, - vertex_value_converter=None, - group=None): + self, + properties_to_copy: typing.Optional[typing.List[str]] = None, + to_sketch_function: typing.Optional[typing.Any] = None, + count_property: typing.Optional[str] = None, + cardinality_property_name: typing.Optional[str] = None, + edge_group_property: typing.Optional[str] = None, + vertex_value_converter: typing.Optional[Function] = None, + group: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.properties_to_copy = properties_to_copy + self.to_sketch_function = to_sketch_function self.count_property = count_property self.cardinality_property_name = cardinality_property_name self.edge_group_property = edge_group_property @@ -681,6 +709,8 @@ def to_json(self): function_json = super().to_json() if self.properties_to_copy is not None: function_json["propertiesToCopy"] = self.properties_to_copy + if self.to_sketch_function is not None: + function_json["toSketchFunction"] = self.to_sketch_function if self.count_property is not None: function_json["countProperty"] = self.count_property if self.cardinality_property_name is not None: @@ -698,15 +728,20 @@ class IterableToHllSketch(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.datasketches.cardinality.function.IterableToHllSketch" def __init__( - self, - log_k=None): + self, + log_k: typing.Optional[int] = None, + hll_sketch: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.log_k = log_k + self.hll_sketch = hll_sketch def to_json(self): function_json = super().to_json() if self.log_k is not None: function_json["logK"] = self.log_k + if self.hll_sketch is not None: + function_json["hllSketch"] = self.hll_sketch return function_json @@ -714,15 +749,20 @@ class ToHllSketch(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.sketches.datasketches.cardinality.function.ToHllSketch" def __init__( - self, - log_k=None): + self, + log_k: typing.Optional[int] = None, + hll_sketch: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.log_k = log_k + self.hll_sketch = hll_sketch def to_json(self): function_json = super().to_json() if self.log_k is not None: function_json["logK"] = self.log_k + if self.hll_sketch is not None: + function_json["hllSketch"] = self.hll_sketch return function_json @@ -760,8 +800,9 @@ class DateToTimeBucketEnd(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.DateToTimeBucketEnd" def __init__( - self, - bucket=None): + self, + bucket: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket @@ -776,8 +817,9 @@ class DateToTimeBucketStart(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.DateToTimeBucketStart" def __init__( - self, - bucket=None): + self, + bucket: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket @@ -792,10 +834,11 @@ class MaskTimestampSetByTimeRange(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange" def __init__( - self, - start_time=None, - end_time=None, - time_unit=None): + self, + start_time: typing.Optional[int] = None, + end_time: typing.Optional[int] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.start_time = start_time self.end_time = end_time @@ -826,8 +869,9 @@ class ToTimeBucket(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.ToTimeBucket" def __init__( - self, - bucket=None): + self, + bucket: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket @@ -842,8 +886,9 @@ class ToTimeBucketEnd(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.ToTimeBucketEnd" def __init__( - self, - bucket=None): + self, + bucket: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket @@ -858,8 +903,9 @@ class ToTimeBucketStart(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.ToTimeBucketStart" def __init__( - self, - bucket=None): + self, + bucket: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket @@ -874,10 +920,11 @@ class ToTimestampSet(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.time.function.ToTimestampSet" def __init__( - self, - bucket=None, - max_size=None, - millis_correction=None): + self, + bucket: typing.Optional[str] = None, + max_size: typing.Optional[int] = None, + millis_correction: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.bucket = bucket self.max_size = max_size @@ -898,8 +945,9 @@ class FreqMapExtractor(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.types.function.FreqMapExtractor" def __init__( - self, - key=None): + self, + key: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.key = key @@ -914,8 +962,9 @@ class FreqMapPredicator(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.types.function.FreqMapPredicator" def __init__( - self, - predicate=None): + self, + predicate: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate @@ -970,9 +1019,10 @@ class ToTypeSubTypeValue(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.types.function.ToTypeSubTypeValue" def __init__( - self, - sub_type=None, - type=None): + self, + sub_type: typing.Optional[str] = None, + type: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.sub_type = sub_type self.type = type @@ -990,8 +1040,9 @@ class ToTypeValue(AbstractFunction): CLASS = "uk.gov.gchq.gaffer.types.function.ToTypeValue" def __init__( - self, - type=None): + self, + type: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.type = type @@ -1006,8 +1057,9 @@ class FunctionComposite(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.function.FunctionComposite" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions @@ -1022,8 +1074,9 @@ class FunctionMap(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.function.FunctionMap" def __init__( - self, - function=None): + self, + function: typing.Optional[Function] = None, + ): super().__init__(_class_name=self.CLASS) self.function = function @@ -1038,8 +1091,9 @@ class ApplyBiFunction(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ApplyBiFunction" def __init__( - self, - function=None): + self, + function: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.function = function @@ -1064,8 +1118,9 @@ class CallMethod(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.CallMethod" def __init__( - self, - method=None): + self, + method: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.method = method @@ -1080,8 +1135,9 @@ class Cast(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.Cast" def __init__( - self, - output_class=None): + self, + output_class: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.output_class = output_class @@ -1096,8 +1152,9 @@ class Concat(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.Concat" def __init__( - self, - separator=None): + self, + separator: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.separator = separator @@ -1112,8 +1169,9 @@ class CreateObject(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.CreateObject" def __init__( - self, - object_class=None): + self, + object_class: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.object_class = object_class @@ -1128,14 +1186,15 @@ class CsvLinesToMaps(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.CsvLinesToMaps" def __init__( - self, - quoted=None, - quote_char=None, - first_row=None, - trim=None, - delimiter=None, - null_string=None, - header=None): + self, + quoted: typing.Optional[bool] = None, + quote_char: typing.Optional[str] = None, + first_row: typing.Optional[int] = None, + trim: typing.Optional[bool] = None, + delimiter: typing.Optional[str] = None, + null_string: typing.Optional[str] = None, + header: typing.Optional[typing.List[str]] = None, + ): super().__init__(_class_name=self.CLASS) self.quoted = quoted self.quote_char = quote_char @@ -1168,12 +1227,13 @@ class CsvToMaps(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.CsvToMaps" def __init__( - self, - quoted=None, - quote_char=None, - first_row=None, - delimiter=None, - header=None): + self, + quoted: typing.Optional[bool] = None, + quote_char: typing.Optional[str] = None, + first_row: typing.Optional[int] = None, + delimiter: typing.Optional[str] = None, + header: typing.Optional[typing.List[str]] = None, + ): super().__init__(_class_name=self.CLASS) self.quoted = quoted self.quote_char = quote_char @@ -1220,8 +1280,9 @@ class DefaultIfEmpty(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.DefaultIfEmpty" def __init__( - self, - default_value=None): + self, + default_value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.default_value = default_value @@ -1236,8 +1297,9 @@ class DefaultIfNull(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.DefaultIfNull" def __init__( - self, - default_value=None): + self, + default_value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.default_value = default_value @@ -1252,8 +1314,9 @@ class DeserialiseJson(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.DeserialiseJson" def __init__( - self, - output_class=None): + self, + output_class: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.output_class = output_class @@ -1278,8 +1341,9 @@ class DictionaryLookup(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.DictionaryLookup" def __init__( - self, - dictionary=None): + self, + dictionary: typing.Optional[typing.Dict[typing.Any, typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.dictionary = dictionary @@ -1304,8 +1368,9 @@ class DivideBy(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.DivideBy" def __init__( - self, - by=None): + self, + by: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.by = by @@ -1330,8 +1395,9 @@ class ExtractValue(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ExtractValue" def __init__( - self, - key=None): + self, + key: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.key = key @@ -1366,8 +1432,9 @@ class FirstValid(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.FirstValid" def __init__( - self, - predicate=None): + self, + predicate: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate @@ -1382,8 +1449,9 @@ class FunctionChain(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.FunctionChain" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions @@ -1418,11 +1486,12 @@ class If(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.If" def __init__( - self, - otherwise=None, - predicate=None, - condition=None, - then=None): + self, + otherwise: typing.Optional[Function] = None, + predicate: typing.Optional[Predicate] = None, + condition: typing.Optional[bool] = None, + then: typing.Optional[Function] = None, + ): super().__init__(_class_name=self.CLASS) self.otherwise = otherwise self.predicate = predicate @@ -1446,8 +1515,9 @@ class Increment(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.Increment" def __init__( - self, - increment=None): + self, + increment: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.increment = increment @@ -1482,8 +1552,9 @@ class IterableFilter(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.IterableFilter" def __init__( - self, - predicate=None): + self, + predicate: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate @@ -1498,8 +1569,9 @@ class IterableFlatten(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.IterableFlatten" def __init__( - self, - operator=None): + self, + operator: typing.Optional[BinaryOperator] = None, + ): super().__init__(_class_name=self.CLASS) self.operator = operator @@ -1514,8 +1586,9 @@ class IterableFunction(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.IterableFunction" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[Function]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions @@ -1550,8 +1623,9 @@ class Length(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.Length" def __init__( - self, - max_length=None): + self, + max_length: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.max_length = max_length @@ -1576,10 +1650,11 @@ class MapFilter(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.MapFilter" def __init__( - self, - key_predicate=None, - key_value_predicate=None, - value_predicate=None): + self, + key_predicate: typing.Optional[Predicate] = None, + key_value_predicate: typing.Optional[typing.Any] = None, + value_predicate: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.key_predicate = key_predicate self.key_value_predicate = key_value_predicate @@ -1620,8 +1695,9 @@ class MultiplyBy(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.MultiplyBy" def __init__( - self, - by=None): + self, + by: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.by = by @@ -1636,8 +1712,9 @@ class MultiplyLongBy(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.MultiplyLongBy" def __init__( - self, - by=None): + self, + by: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.by = by @@ -1652,8 +1729,9 @@ class NthItem(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.NthItem" def __init__( - self, - selection=None): + self, + selection: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.selection = selection @@ -1668,10 +1746,11 @@ class ParseDate(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ParseDate" def __init__( - self, - format=None, - time_zone=None, - microseconds=None): + self, + format: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + microseconds: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.format = format self.time_zone = time_zone @@ -1692,10 +1771,11 @@ class ParseTime(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ParseTime" def __init__( - self, - format=None, - time_zone=None, - time_unit=None): + self, + format: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.format = format self.time_zone = time_zone @@ -1726,8 +1806,9 @@ class SetValue(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.SetValue" def __init__( - self, - value=None): + self, + value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value @@ -1752,8 +1833,9 @@ class StringAppend(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringAppend" def __init__( - self, - suffix=None): + self, + suffix: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.suffix = suffix @@ -1768,8 +1850,9 @@ class StringJoin(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringJoin" def __init__( - self, - delimiter=None): + self, + delimiter: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.delimiter = delimiter @@ -1784,8 +1867,9 @@ class StringPrepend(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringPrepend" def __init__( - self, - prefix=None): + self, + prefix: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.prefix = prefix @@ -1800,9 +1884,10 @@ class StringRegexReplace(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringRegexReplace" def __init__( - self, - regex=None, - replacement=None): + self, + regex: typing.Optional[str] = None, + replacement: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.regex = regex self.replacement = replacement @@ -1820,8 +1905,9 @@ class StringRegexSplit(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringRegexSplit" def __init__( - self, - regex=None): + self, + regex: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.regex = regex @@ -1836,9 +1922,10 @@ class StringReplace(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringReplace" def __init__( - self, - search_string=None, - replacement=None): + self, + search_string: typing.Optional[str] = None, + replacement: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.search_string = search_string self.replacement = replacement @@ -1856,8 +1943,9 @@ class StringSplit(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringSplit" def __init__( - self, - delimiter=None): + self, + delimiter: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.delimiter = delimiter @@ -1882,9 +1970,10 @@ class StringTruncate(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.StringTruncate" def __init__( - self, - length=None, - ellipses=None): + self, + length: typing.Optional[int] = None, + ellipses: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.length = length self.ellipses = ellipses @@ -1922,8 +2011,9 @@ class ToBytes(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ToBytes" def __init__( - self, - charset=None): + self, + charset: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.charset = charset @@ -1938,8 +2028,9 @@ class ToDateString(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ToDateString" def __init__( - self, - format=None): + self, + format: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.format = format @@ -2024,8 +2115,9 @@ class ToSet(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ToSet" def __init__( - self, - implementation=None): + self, + implementation: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.implementation = implementation @@ -2040,8 +2132,9 @@ class ToString(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.impl.function.ToString" def __init__( - self, - charset=None): + self, + charset: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.charset = charset @@ -2076,8 +2169,9 @@ class TupleInputAdapter(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.tuple.TupleInputAdapter" def __init__( - self, - selection=None): + self, + selection: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.selection = selection @@ -2092,12 +2186,13 @@ class TupleAdaptedFunction(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunction" def __init__( - self, - input_adapter=None, - selection=None, - function=None, - output_adapter=None, - projection=None): + self, + input_adapter: typing.Optional[Function] = None, + selection: typing.Optional[typing.List[typing.Any]] = None, + function: typing.Optional[Function] = None, + output_adapter: typing.Optional[typing.Any] = None, + projection: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.input_adapter = input_adapter self.selection = selection @@ -2124,8 +2219,9 @@ class TupleAdaptedFunctionComposite(AbstractFunction): CLASS = "uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite" def __init__( - self, - functions=None): + self, + functions: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.functions = functions diff --git a/src/gafferpy/generated_api/operations.py b/src/gafferpy/generated_api/operations.py index 312a74a8..3a7b4584 100644 --- a/src/gafferpy/generated_api/operations.py +++ b/src/gafferpy/generated_api/operations.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -20,10 +20,10 @@ """ import typing - -import gafferpy.gaffer_core -import gafferpy.gaffer_functions -from gafferpy.gaffer_operations import Operation, View, Conditional, AggregatePair +from gafferpy.gaffer_operations import AggregatePair, Conditional, Operation, View +from gafferpy.gaffer_core import BinaryOperator, Element, ElementSeed, Function +from gafferpy.gaffer_predicates import ElementFilter +from gafferpy.gaffer_functions import CsvGenerator, ElementTransformer, MapGenerator class ImportAccumuloKeyValueFiles(Operation): @@ -40,10 +40,12 @@ class ImportAccumuloKeyValueFiles(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.hdfs.operation.ImportAccumuloKeyValueFiles" def __init__( - self, - input_path: str, - failure_path: str, - options: typing.Dict[str, str] = None): + self, + input_path: str, + failure_path: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input_path = input_path self.failure_path = failure_path @@ -75,14 +77,16 @@ class GetElementsBetweenSets(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSets" def __init__( - self, - input: typing.List[typing.Any] = None, - view: View = None, - include_incoming_out_going: str = None, - input_b: typing.List[typing.Any] = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + input_b: typing.Optional[typing.List[typing.Any]] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -117,7 +121,6 @@ class GetElementsBetweenSetsPairs(Operation): view: include_incoming_out_going: Should the edges point towards, or away from your seeds directed_type: Is the Edge directed? - backwards_compatible_operation: views: options: Additional map of options Returns: @@ -126,20 +129,20 @@ class GetElementsBetweenSetsPairs(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsBetweenSetsPairs" def __init__( - self, - input: typing.Tuple[typing.Any] = None, - view: View = None, - include_incoming_out_going: str = None, - directed_type: str = None, - backwards_compatible_operation: typing.Any = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Tuple[typing.Any]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view self.include_incoming_out_going = include_incoming_out_going self.directed_type = directed_type - self.backwards_compatible_operation = backwards_compatible_operation self.views = views def to_json(self): @@ -152,8 +155,6 @@ def to_json(self): operation_json["includeIncomingOutGoing"] = self.include_incoming_out_going if self.directed_type is not None: operation_json["directedType"] = self.directed_type - if self.backwards_compatible_operation is not None: - operation_json["backwardsCompatibleOperation"] = self.backwards_compatible_operation if self.views is not None: operation_json["views"] = self.views return operation_json @@ -176,13 +177,15 @@ class GetElementsInRanges(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsInRanges" def __init__( - self, - input: typing.List[typing.Tuple[gafferpy.gaffer_core.ElementSeed, gafferpy.gaffer_core.ElementSeed]] = None, - view: View = None, - include_incoming_out_going: str = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Tuple[ElementSeed, ElementSeed]]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -221,12 +224,14 @@ class GetElementsWithinSet(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.impl.GetElementsWithinSet" def __init__( - self, - input: typing.List[typing.Any] = None, - view: View = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + view: typing.Optional[View] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -263,13 +268,15 @@ class SummariseGroupOverRanges(Operation): CLASS = "uk.gov.gchq.gaffer.accumulostore.operation.impl.SummariseGroupOverRanges" def __init__( - self, - input: typing.List[typing.Tuple[gafferpy.gaffer_core.ElementSeed, gafferpy.gaffer_core.ElementSeed]] = None, - view: View = None, - include_incoming_out_going: str = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Tuple[ElementSeed, ElementSeed]]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -314,18 +321,20 @@ class AddGraph(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.AddGraph" def __init__( - self, - graph_id: str, - schema: typing.Dict = None, - write_access_predicate: typing.Any = None, - store_properties: typing.Dict = None, - parent_properties_id: str = None, - read_access_predicate: typing.Any = None, - graph_auths: typing.Set[str] = None, - is_public: bool = None, - parent_schema_ids: typing.List[str] = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + schema: typing.Optional[typing.Dict] = None, + write_access_predicate: typing.Optional[typing.Any] = None, + store_properties: typing.Optional[typing.Dict] = None, + parent_properties_id: typing.Optional[str] = None, + read_access_predicate: typing.Optional[typing.Any] = None, + graph_auths: typing.Optional[typing.Set[str]] = None, + is_public: typing.Optional[bool] = None, + parent_schema_ids: typing.Optional[typing.List[str]] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.schema = schema self.write_access_predicate = write_access_predicate @@ -386,19 +395,21 @@ class AddGraphWithHooks(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks" def __init__( - self, - schema: typing.Dict = None, - write_access_predicate: typing.Any = None, - store_properties: typing.Dict = None, - parent_properties_id: str = None, - read_access_predicate: typing.Any = None, - graph_auths: typing.Set[str] = None, - is_public: bool = None, - parent_schema_ids: typing.List[str] = None, - graph_id: str = None, - hooks: typing.List[typing.Any] = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + schema: typing.Optional[typing.Dict] = None, + write_access_predicate: typing.Optional[typing.Any] = None, + store_properties: typing.Optional[typing.Dict] = None, + parent_properties_id: typing.Optional[str] = None, + read_access_predicate: typing.Optional[typing.Any] = None, + graph_auths: typing.Optional[typing.Set[str]] = None, + is_public: typing.Optional[bool] = None, + parent_schema_ids: typing.Optional[typing.List[str]] = None, + graph_id: typing.Optional[str] = None, + hooks: typing.Optional[typing.List[typing.Any]] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.schema = schema self.write_access_predicate = write_access_predicate @@ -456,13 +467,15 @@ class ChangeGraphAccess(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess" def __init__( - self, - graph_id: str, - owner_user_id: str = None, - graph_auths: typing.Set[str] = None, - is_public: bool = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + owner_user_id: typing.Optional[str] = None, + graph_auths: typing.Optional[typing.Set[str]] = None, + is_public: typing.Optional[bool] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.owner_user_id = owner_user_id self.graph_auths = graph_auths @@ -500,11 +513,13 @@ class ChangeGraphId(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId" def __init__( - self, - graph_id: str, - new_graph_id: str = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + new_graph_id: typing.Optional[str] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.new_graph_id = new_graph_id self.graph_id = graph_id @@ -539,14 +554,16 @@ class FederatedOperation(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation" def __init__( - self, - skip_failed_federated_execution: typing.Any = None, - input: typing.Any = None, - graph_ids: typing.List[str] = None, - operation: Operation = None, - merge_function: typing.Any = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + skip_failed_federated_execution: typing.Optional[typing.Any] = None, + input: typing.Optional[typing.Any] = None, + graph_ids: typing.Optional[typing.List[str]] = None, + operation: typing.Optional[Operation] = None, + merge_function: typing.Optional[typing.Any] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.skip_failed_federated_execution = skip_failed_federated_execution self.input = input @@ -585,9 +602,11 @@ class GetAllGraphIds(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds" def __init__( - self, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.user_requesting_admin_usage = user_requesting_admin_usage @@ -612,10 +631,12 @@ class GetAllGraphInfo(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo" def __init__( - self, - graph_ids: typing.List[str] = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + graph_ids: typing.Optional[typing.List[str]] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.graph_ids = graph_ids self.user_requesting_admin_usage = user_requesting_admin_usage @@ -644,11 +665,13 @@ class RemoveGraph(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph" def __init__( - self, - graph_id: str, - remove_cache: bool = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + remove_cache: typing.Optional[bool] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.remove_cache = remove_cache self.graph_id = graph_id @@ -680,11 +703,13 @@ class RemoveGraphAndDeleteAllData(Operation): CLASS = "uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraphAndDeleteAllData" def __init__( - self, - remove_cache: bool = None, - graph_id: str = None, - user_requesting_admin_usage: bool = None, - options: typing.Dict[str, str] = None): + self, + remove_cache: typing.Optional[bool] = None, + graph_id: typing.Optional[str] = None, + user_requesting_admin_usage: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.remove_cache = remove_cache self.graph_id = graph_id @@ -728,23 +753,25 @@ class AddElementsFromHdfs(Operation): CLASS = "uk.gov.gchq.gaffer.hdfs.operation.AddElementsFromHdfs" def __init__( - self, - job_initialiser: typing.Any, - input_mapper_pairs: typing.Dict[str, str], - failure_path: str, - output_path: str, - splits_file_path: str = None, - num_map_tasks: int = None, - working_path: str = None, - min_reduce_tasks: int = None, - max_reduce_tasks: int = None, - min_map_tasks: int = None, - use_provided_splits: bool = None, - command_line_args: typing.List[str] = None, - partitioner: typing.Any = None, - max_map_tasks: int = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + job_initialiser: typing.Any, + input_mapper_pairs: typing.Dict[str, str], + failure_path: str, + output_path: str, + splits_file_path: typing.Optional[str] = None, + num_map_tasks: typing.Optional[int] = None, + working_path: typing.Optional[str] = None, + min_reduce_tasks: typing.Optional[int] = None, + max_reduce_tasks: typing.Optional[int] = None, + min_map_tasks: typing.Optional[int] = None, + use_provided_splits: typing.Optional[bool] = None, + command_line_args: typing.Optional[typing.List[str]] = None, + partitioner: typing.Optional[typing.Any] = None, + max_map_tasks: typing.Optional[int] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_initialiser = job_initialiser self.splits_file_path = splits_file_path @@ -825,24 +852,26 @@ class SampleDataForSplitPoints(Operation): CLASS = "uk.gov.gchq.gaffer.hdfs.operation.SampleDataForSplitPoints" def __init__( - self, - splits_file_path: str, - job_initialiser: typing.Any, - input_mapper_pairs: typing.Dict[str, str], - output_path: str, - num_map_tasks: int = None, - min_reduce_tasks: int = None, - num_splits: int = None, - max_reduce_tasks: int = None, - min_map_tasks: int = None, - use_provided_splits: bool = None, - command_line_args: typing.List[str] = None, - compression_codec: typing.Any = None, - partitioner: typing.Any = None, - proportion_to_sample: float = None, - max_map_tasks: int = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + splits_file_path: str, + job_initialiser: typing.Any, + input_mapper_pairs: typing.Dict[str, str], + output_path: str, + num_map_tasks: typing.Optional[int] = None, + min_reduce_tasks: typing.Optional[int] = None, + num_splits: typing.Optional[int] = None, + max_reduce_tasks: typing.Optional[int] = None, + min_map_tasks: typing.Optional[int] = None, + use_provided_splits: typing.Optional[bool] = None, + command_line_args: typing.Optional[typing.List[str]] = None, + compression_codec: typing.Optional[typing.Any] = None, + partitioner: typing.Optional[typing.Any] = None, + proportion_to_sample: typing.Optional[float] = None, + max_map_tasks: typing.Optional[int] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.splits_file_path = splits_file_path self.job_initialiser = job_initialiser @@ -911,9 +940,11 @@ class CountAllElementsDefaultView(Operation): CLASS = "uk.gov.gchq.gaffer.mapstore.operation.CountAllElementsDefaultView" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -947,19 +978,21 @@ class AddNamedOperation(Operation): CLASS = "uk.gov.gchq.gaffer.named.operation.AddNamedOperation" def __init__( - self, - overwrite_flag: bool = None, - write_access_predicate: typing.Any = None, - score: int = None, - read_access_roles: typing.List[str] = None, - read_access_predicate: typing.Any = None, - description: str = None, - operation_name: str = None, - operation_chain: typing.Any = None, - parameters: typing.Dict[str, typing.Any] = None, - write_access_roles: typing.List[str] = None, - labels: typing.List[str] = None, - options: typing.Dict[str, str] = None): + self, + overwrite_flag: typing.Optional[bool] = None, + write_access_predicate: typing.Optional[typing.Any] = None, + score: typing.Optional[int] = None, + read_access_roles: typing.Optional[typing.List[str]] = None, + read_access_predicate: typing.Optional[typing.Any] = None, + description: typing.Optional[str] = None, + operation_name: typing.Optional[str] = None, + operation_chain: typing.Optional[typing.Any] = None, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = None, + write_access_roles: typing.Optional[typing.List[str]] = None, + labels: typing.Optional[typing.List[str]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.overwrite_flag = overwrite_flag self.write_access_predicate = write_access_predicate @@ -1013,9 +1046,11 @@ class DeleteNamedOperation(Operation): CLASS = "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation" def __init__( - self, - operation_name: str, - options: typing.Dict[str, str] = None): + self, + operation_name: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.operation_name = operation_name @@ -1038,8 +1073,10 @@ class GetAllNamedOperations(Operation): CLASS = "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -1061,11 +1098,13 @@ class NamedOperation(Operation): CLASS = "uk.gov.gchq.gaffer.named.operation.NamedOperation" def __init__( - self, - operation_name: str, - input: typing.List[typing.Any] = None, - parameters: typing.Dict[str, typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + operation_name: str, + input: typing.Optional[typing.List[typing.Any]] = None, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.operation_name = operation_name @@ -1102,16 +1141,18 @@ class AddNamedView(Operation): CLASS = "uk.gov.gchq.gaffer.named.view.AddNamedView" def __init__( - self, - view: typing.Any, - name: str, - overwrite_flag: bool = None, - write_access_predicate: typing.Any = None, - read_access_predicate: typing.Any = None, - description: str = None, - parameters: typing.Dict[str, typing.Any] = None, - write_access_roles: typing.List[str] = None, - options: typing.Dict[str, str] = None): + self, + view: typing.Any, + name: str, + overwrite_flag: typing.Optional[bool] = None, + write_access_predicate: typing.Optional[typing.Any] = None, + read_access_predicate: typing.Optional[typing.Any] = None, + description: typing.Optional[str] = None, + parameters: typing.Optional[typing.Dict[str, typing.Any]] = None, + write_access_roles: typing.Optional[typing.List[str]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.overwrite_flag = overwrite_flag self.write_access_predicate = write_access_predicate @@ -1156,9 +1197,11 @@ class DeleteNamedView(Operation): CLASS = "uk.gov.gchq.gaffer.named.view.DeleteNamedView" def __init__( - self, - name: str, - options: typing.Dict[str, str] = None): + self, + name: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.name = name @@ -1181,8 +1224,10 @@ class GetAllNamedViews(Operation): CLASS = "uk.gov.gchq.gaffer.named.view.GetAllNamedViews" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -1202,9 +1247,11 @@ class OperationChain(Operation): CLASS = "uk.gov.gchq.gaffer.operation.OperationChain" def __init__( - self, - operations: typing.List[Operation] = None, - options: typing.Dict[str, str] = None): + self, + operations: typing.Optional[typing.List[Operation]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.operations = operations @@ -1232,13 +1279,15 @@ class ExportToOtherAuthorisedGraph(Operation): CLASS = "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph" def __init__( - self, - graph_id: str, - input: typing.List[gafferpy.gaffer_core.Element] = None, - parent_store_properties_id: str = None, - parent_schema_ids: typing.List[str] = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + input: typing.Optional[typing.List[Element]] = None, + parent_store_properties_id: typing.Optional[str] = None, + parent_schema_ids: typing.Optional[typing.List[str]] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.parent_store_properties_id = parent_store_properties_id @@ -1280,15 +1329,17 @@ class ExportToOtherGraph(Operation): CLASS = "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph" def __init__( - self, - graph_id: str, - schema: typing.Dict = None, - input: typing.List[gafferpy.gaffer_core.Element] = None, - parent_store_properties_id: str = None, - store_properties: typing.Dict = None, - parent_schema_ids: typing.List[str] = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + graph_id: str, + schema: typing.Optional[typing.Dict] = None, + input: typing.Optional[typing.List[Element]] = None, + parent_store_properties_id: typing.Optional[str] = None, + store_properties: typing.Optional[typing.Dict] = None, + parent_schema_ids: typing.Optional[typing.List[str]] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.schema = schema self.input = input @@ -1330,9 +1381,11 @@ class Count(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.Count" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -1357,10 +1410,12 @@ class CountGroups(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.CountGroups" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - limit: int = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + limit: typing.Optional[int] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.limit = limit @@ -1387,9 +1442,11 @@ class DiscardOutput(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" def __init__( - self, - input: typing.Any = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -1414,10 +1471,12 @@ class ForEach(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.ForEach" def __init__( - self, - input: typing.List[typing.Any] = None, - operation: Operation = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + operation: typing.Optional[Operation] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.operation = operation @@ -1445,10 +1504,12 @@ class GenerateSplitPointsFromSample(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.GenerateSplitPointsFromSample" def __init__( - self, - input: typing.List[typing.Any] = None, - num_splits: int = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + num_splits: typing.Optional[int] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.num_splits = num_splits @@ -1475,9 +1536,11 @@ class GetVariable(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.GetVariable" def __init__( - self, - variable_name: str = None, - options: typing.Dict[str, str] = None): + self, + variable_name: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.variable_name = variable_name @@ -1501,9 +1564,11 @@ class GetVariables(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.GetVariables" def __init__( - self, - variable_names: typing.List[str] = None, - options: typing.Dict[str, str] = None): + self, + variable_names: typing.Optional[typing.List[str]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.variable_names = variable_names @@ -1531,13 +1596,15 @@ class GetWalks(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.GetWalks" def __init__( - self, - input: typing.List[typing.Any] = None, - operations: typing.List[typing.Any] = None, - include_partial: bool = None, - conditional: Conditional = None, - results_limit: int = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + operations: typing.Optional[typing.List[typing.Any]] = None, + include_partial: typing.Optional[bool] = None, + conditional: typing.Optional[Conditional] = None, + results_limit: typing.Optional[int] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.operations = operations @@ -1578,14 +1645,16 @@ class If(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.If" def __init__( - self, - otherwise: Operation = None, - input: typing.Any = None, - condition: bool = None, - conditional: Conditional = None, - multi_input_wrapper: typing.Any = None, - then: Operation = None, - options: typing.Dict[str, str] = None): + self, + otherwise: typing.Optional[Operation] = None, + input: typing.Optional[typing.Any] = None, + condition: typing.Optional[bool] = None, + conditional: typing.Optional[Conditional] = None, + multi_input_wrapper: typing.Optional[typing.Any] = None, + then: typing.Optional[Operation] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.otherwise = otherwise self.input = input @@ -1626,11 +1695,13 @@ class Limit(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.Limit" def __init__( - self, - result_limit: int, - input: typing.List[typing.Any] = None, - truncate: bool = None, - options: typing.Dict[str, str] = None): + self, + result_limit: int, + input: typing.Optional[typing.List[typing.Any]] = None, + truncate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.result_limit = result_limit @@ -1662,11 +1733,13 @@ class Map(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.Map" def __init__( - self, - functions: typing.List, - input: typing.Any = None, - function: typing.Any = None, - options: typing.Dict[str, str] = None): + self, + functions: typing.List[Function], + input: typing.Optional[typing.Any] = None, + function: typing.Optional[Function] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.functions = functions @@ -1698,11 +1771,13 @@ class Reduce(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.Reduce" def __init__( - self, - aggregate_function: gafferpy.gaffer_binaryoperators.BinaryOperator, - input: typing.List[typing.Any] = None, - identity: typing.Any = None, - options: typing.Dict[str, str] = None): + self, + aggregate_function: BinaryOperator, + input: typing.Optional[typing.List[typing.Any]] = None, + identity: typing.Optional[typing.Any] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.identity = identity @@ -1734,11 +1809,13 @@ class SampleElementsForSplitPoints(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.SampleElementsForSplitPoints" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - num_splits: int = None, - proportion_to_sample: float = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + num_splits: typing.Optional[int] = None, + proportion_to_sample: typing.Optional[float] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.num_splits = num_splits @@ -1768,9 +1845,11 @@ class ScoreOperationChain(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain" def __init__( - self, - operation_chain: OperationChain = None, - options: typing.Dict[str, str] = None): + self, + operation_chain: typing.Optional[OperationChain] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.operation_chain = operation_chain @@ -1795,10 +1874,12 @@ class SetVariable(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.SetVariable" def __init__( - self, - input: typing.Any = None, - variable_name: str = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + variable_name: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.variable_name = variable_name @@ -1825,9 +1906,11 @@ class SplitStoreFromFile(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile" def __init__( - self, - input_path: str, - options: typing.Dict[str, str] = None): + self, + input_path: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input_path = input_path @@ -1851,9 +1934,11 @@ class SplitStoreFromIterable(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.SplitStoreFromIterable" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -1879,11 +1964,13 @@ class Validate(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.Validate" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - skip_invalid_elements: bool = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + skip_invalid_elements: typing.Optional[bool] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.skip_invalid_elements = skip_invalid_elements @@ -1913,9 +2000,11 @@ class ValidateOperationChain(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain" def __init__( - self, - operation_chain: OperationChain, - options: typing.Dict[str, str] = None): + self, + operation_chain: OperationChain, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.operation_chain = operation_chain @@ -1944,14 +2033,16 @@ class While(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.While" def __init__( - self, - input: typing.Any = None, - condition: bool = None, - conditional: Conditional = None, - max_repeats: int = None, - multi_input_wrapper: typing.Any = None, - operation: Operation = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + condition: typing.Optional[bool] = None, + conditional: typing.Optional[Conditional] = None, + max_repeats: typing.Optional[int] = None, + multi_input_wrapper: typing.Optional[typing.Any] = None, + operation: typing.Optional[Operation] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.condition = condition @@ -1992,11 +2083,13 @@ class AddElements(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.add.AddElements" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - skip_invalid_elements: bool = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + skip_invalid_elements: typing.Optional[bool] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.skip_invalid_elements = skip_invalid_elements @@ -2030,13 +2123,15 @@ class AddElementsFromFile(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile" def __init__( - self, - element_generator: typing.Any, - filename: str, - parallelism: int = None, - skip_invalid_elements: bool = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + element_generator: typing.Any, + filename: str, + parallelism: typing.Optional[int] = None, + skip_invalid_elements: typing.Optional[bool] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.element_generator = element_generator self.filename = filename @@ -2079,16 +2174,18 @@ class AddElementsFromKafka(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka" def __init__( - self, - element_generator: typing.Any, - bootstrap_servers: typing.List[str], - group_id: str, - topic: str, - parallelism: int = None, - consume_as: typing.Any = None, - skip_invalid_elements: bool = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + element_generator: typing.Any, + bootstrap_servers: typing.List[str], + group_id: str, + topic: str, + parallelism: typing.Optional[int] = None, + consume_as: typing.Optional[typing.Any] = None, + skip_invalid_elements: typing.Optional[bool] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.element_generator = element_generator self.bootstrap_servers = bootstrap_servers @@ -2139,15 +2236,17 @@ class AddElementsFromSocket(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket" def __init__( - self, - element_generator: typing.Any, - hostname: str, - port: int, - delimiter: str = None, - parallelism: int = None, - skip_invalid_elements: bool = None, - validate: bool = None, - options: typing.Dict[str, str] = None): + self, + element_generator: typing.Any, + hostname: str, + port: int, + delimiter: typing.Optional[str] = None, + parallelism: typing.Optional[int] = None, + skip_invalid_elements: typing.Optional[bool] = None, + validate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.element_generator = element_generator self.hostname = hostname @@ -2190,10 +2289,12 @@ class Max(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.compare.Max" def __init__( - self, - comparators: typing.List[typing.Any], - input: typing.List[gafferpy.gaffer_core.Element] = None, - options: typing.Dict[str, str] = None): + self, + comparators: typing.List[typing.Any], + input: typing.Optional[typing.List[Element]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.comparators = comparators @@ -2221,10 +2322,12 @@ class Min(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.compare.Min" def __init__( - self, - comparators: typing.List[typing.Any], - input: typing.List[gafferpy.gaffer_core.Element] = None, - options: typing.Dict[str, str] = None): + self, + comparators: typing.List[typing.Any], + input: typing.Optional[typing.List[Element]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.comparators = comparators @@ -2254,12 +2357,14 @@ class Sort(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.compare.Sort" def __init__( - self, - comparators: typing.List[typing.Any], - input: typing.List[gafferpy.gaffer_core.Element] = None, - result_limit: int = None, - deduplicate: bool = None, - options: typing.Dict[str, str] = None): + self, + comparators: typing.List[typing.Any], + input: typing.Optional[typing.List[Element]] = None, + result_limit: typing.Optional[int] = None, + deduplicate: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.result_limit = result_limit @@ -2292,9 +2397,11 @@ class GetExports(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.GetExports" def __init__( - self, - get_exports: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + get_exports: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.get_exports = get_exports @@ -2320,11 +2427,13 @@ class ExportToLocalFile(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.localfile.ExportToLocalFile" def __init__( - self, - file_path: str, - input: typing.List[str] = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + file_path: str, + input: typing.Optional[typing.List[str]] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.file_path = file_path @@ -2356,11 +2465,13 @@ class ImportFromLocalFile(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.localfile.ImportFromLocalFile" def __init__( - self, - file_path: str, - job_id: str = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + file_path: str, + job_id: typing.Optional[str] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id self.file_path = file_path @@ -2392,11 +2503,13 @@ class ExportToGafferResultCache(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" def __init__( - self, - input: typing.Any = None, - op_auths: typing.Set[str] = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + op_auths: typing.Optional[typing.Set[str]] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.op_auths = op_auths @@ -2427,10 +2540,12 @@ class GetGafferResultCacheExport(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport" def __init__( - self, - job_id: str = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + job_id: typing.Optional[str] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id self.key = key @@ -2458,10 +2573,12 @@ class ExportToSet(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet" def __init__( - self, - input: typing.Any = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.key = key @@ -2491,12 +2608,14 @@ class GetSetExport(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport" def __init__( - self, - job_id: str = None, - start: int = None, - end: int = None, - key: str = None, - options: typing.Dict[str, str] = None): + self, + job_id: typing.Optional[str] = None, + start: typing.Optional[int] = None, + end: typing.Optional[int] = None, + key: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id self.start = start @@ -2531,11 +2650,13 @@ class Aggregate(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.function.Aggregate" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - entities: typing.Dict[str, AggregatePair] = None, - edges: typing.Dict[str, AggregatePair] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + entities: typing.Optional[typing.Dict[str, AggregatePair]] = None, + edges: typing.Optional[typing.Dict[str, AggregatePair]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.entities = entities @@ -2570,14 +2691,16 @@ class Filter(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.function.Filter" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - global_edges: gafferpy.generated_api.predicates.ElementFilter = None, - global_entities: gafferpy.generated_api.predicates.ElementFilter = None, - entities: typing.Dict[str, gafferpy.generated_api.predicates.ElementFilter] = None, - edges: typing.Dict[str, gafferpy.generated_api.predicates.ElementFilter] = None, - global_elements: gafferpy.generated_api.predicates.ElementFilter = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + global_edges: typing.Optional[ElementFilter] = None, + global_entities: typing.Optional[ElementFilter] = None, + entities: typing.Optional[typing.Dict[str, ElementFilter]] = None, + edges: typing.Optional[typing.Dict[str, ElementFilter]] = None, + global_elements: typing.Optional[ElementFilter] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.global_edges = global_edges @@ -2618,11 +2741,13 @@ class Transform(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.function.Transform" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - entities: typing.Dict[str, gafferpy.generated_api.functions.ElementTransformer] = None, - edges: typing.Dict[str, gafferpy.generated_api.functions.ElementTransformer] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + entities: typing.Optional[typing.Dict[str, ElementTransformer]] = None, + edges: typing.Optional[typing.Dict[str, ElementTransformer]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.entities = entities @@ -2653,10 +2778,12 @@ class GenerateElements(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements" def __init__( - self, - element_generator: typing.Any, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + element_generator: Function, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.element_generator = element_generator @@ -2684,10 +2811,12 @@ class GenerateObjects(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects" def __init__( - self, - element_generator: typing.Any, - input: typing.List[gafferpy.gaffer_core.Element] = None, - options: typing.Dict[str, str] = None): + self, + element_generator: Function, + input: typing.Optional[typing.List[Element]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.element_generator = element_generator @@ -2718,13 +2847,15 @@ class GetAdjacentIds(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds" def __init__( - self, - input: typing.List[typing.Any] = None, - view: View = None, - include_incoming_out_going: str = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -2762,11 +2893,13 @@ class GetAllElements(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" def __init__( - self, - view: View = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + view: typing.Optional[View] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.view = view self.directed_type = directed_type @@ -2800,13 +2933,15 @@ class GetElements(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.get.GetElements" def __init__( - self, - input: typing.List[typing.Any] = None, - view: View = None, - include_incoming_out_going: str = None, - directed_type: str = None, - views: typing.List[View] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + view: typing.Optional[View] = None, + include_incoming_out_going: typing.Optional[str] = None, + directed_type: typing.Optional[str] = None, + views: typing.Optional[typing.List[View]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.view = view @@ -2842,9 +2977,11 @@ class GetFromEndpoint(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.get.GetFromEndpoint" def __init__( - self, - endpoint: str, - options: typing.Dict[str, str] = None): + self, + endpoint: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.endpoint = endpoint @@ -2868,9 +3005,11 @@ class CancelScheduledJob(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob" def __init__( - self, - job_id: str, - options: typing.Dict[str, str] = None): + self, + job_id: str, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id @@ -2893,8 +3032,10 @@ class GetAllJobDetails(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -2914,9 +3055,11 @@ class GetJobDetails(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails" def __init__( - self, - job_id: str = None, - options: typing.Dict[str, str] = None): + self, + job_id: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id @@ -2940,9 +3083,11 @@ class GetJobResults(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults" def __init__( - self, - job_id: str = None, - options: typing.Dict[str, str] = None): + self, + job_id: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.job_id = job_id @@ -2972,15 +3117,17 @@ class Join(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.join.Join" def __init__( - self, - flatten: bool = None, - input: typing.List[typing.Any] = None, - join_type: str = None, - match_key: str = None, - collection_limit: int = None, - match_method: typing.Any = None, - operation: Operation = None, - options: typing.Dict[str, str] = None): + self, + flatten: typing.Optional[bool] = None, + input: typing.Optional[typing.List[typing.Any]] = None, + join_type: typing.Optional[str] = None, + match_key: typing.Optional[str] = None, + collection_limit: typing.Optional[int] = None, + match_method: typing.Optional[typing.Any] = None, + operation: typing.Optional[Operation] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.flatten = flatten self.input = input @@ -3022,9 +3169,11 @@ class ToArray(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToArray" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3050,11 +3199,13 @@ class ToCsv(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToCsv" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.Element] = None, - csv_generator: gafferpy.generated_api.functions.CsvGenerator = None, - include_header: bool = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[Element]] = None, + csv_generator: typing.Optional[CsvGenerator] = None, + include_header: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.csv_generator = csv_generator @@ -3084,9 +3235,11 @@ class ToEntitySeeds(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3110,9 +3263,11 @@ class ToList(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToList" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3137,10 +3292,12 @@ class ToMap(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToMap" def __init__( - self, - element_generator: gafferpy.generated_api.functions.MapGenerator, - input: typing.List[gafferpy.gaffer_core.Element] = None, - options: typing.Dict[str, str] = None): + self, + element_generator: MapGenerator, + input: typing.Optional[typing.List[Element]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.element_generator = element_generator @@ -3167,9 +3324,11 @@ class ToSet(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToSet" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3193,9 +3352,11 @@ class ToSingletonList(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList" def __init__( - self, - input: typing.Any = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.Any] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3219,9 +3380,11 @@ class ToStream(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToStream" def __init__( - self, - input: typing.List[typing.Any] = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[typing.Any]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input @@ -3247,11 +3410,13 @@ class ToVertices(Operation): CLASS = "uk.gov.gchq.gaffer.operation.impl.output.ToVertices" def __init__( - self, - input: typing.List[gafferpy.gaffer_core.ElementSeed] = None, - use_matched_vertex: str = None, - edge_vertices: str = None, - options: typing.Dict[str, str] = None): + self, + input: typing.Optional[typing.List[ElementSeed]] = None, + use_matched_vertex: typing.Optional[str] = None, + edge_vertices: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.input = input self.use_matched_vertex = use_matched_vertex @@ -3280,8 +3445,10 @@ class GetProxyProperties(Operation): CLASS = "uk.gov.gchq.gaffer.proxystore.operation.GetProxyProperties" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -3300,8 +3467,10 @@ class GetProxyUrl(Operation): CLASS = "uk.gov.gchq.gaffer.proxystore.operation.GetProxyUrl" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -3320,8 +3489,10 @@ class DeleteAllData(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.DeleteAllData" def __init__( - self, - options: typing.Dict[str, str] = None): + self, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) def to_json(self): @@ -3341,9 +3512,11 @@ class GetSchema(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.GetSchema" def __init__( - self, - compact: bool = None, - options: typing.Dict[str, str] = None): + self, + compact: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.compact = compact @@ -3367,9 +3540,11 @@ class GetTraits(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.GetTraits" def __init__( - self, - current_traits: bool = None, - options: typing.Dict[str, str] = None): + self, + current_traits: typing.Optional[bool] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.current_traits = current_traits @@ -3394,10 +3569,12 @@ class HasTrait(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.HasTrait" def __init__( - self, - current_traits: bool = None, - trait: str = None, - options: typing.Dict[str, str] = None): + self, + current_traits: typing.Optional[bool] = None, + trait: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.current_traits = current_traits self.trait = trait @@ -3426,11 +3603,13 @@ class AddSchemaToLibrary(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.add.AddSchemaToLibrary" def __init__( - self, - schema: typing.Dict, - id: str, - parent_schema_ids: typing.List[str] = None, - options: typing.Dict[str, str] = None): + self, + schema: typing.Dict, + id: str, + parent_schema_ids: typing.Optional[typing.List[str]] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.schema = schema self.id = id @@ -3462,11 +3641,13 @@ class AddStorePropertiesToLibrary(Operation): CLASS = "uk.gov.gchq.gaffer.store.operation.add.AddStorePropertiesToLibrary" def __init__( - self, - store_properties: typing.Dict, - id: str, - parent_properties_id: str = None, - options: typing.Dict[str, str] = None): + self, + store_properties: typing.Dict, + id: str, + parent_properties_id: typing.Optional[str] = None, + options: typing.Optional[typing.Dict[str, str]] = None + ): + super().__init__(_class_name=self.CLASS, options=options) self.store_properties = store_properties self.parent_properties_id = parent_properties_id diff --git a/src/gafferpy/generated_api/predicates.py b/src/gafferpy/generated_api/predicates.py index 76398e7d..090eb52b 100644 --- a/src/gafferpy/generated_api/predicates.py +++ b/src/gafferpy/generated_api/predicates.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -19,16 +19,19 @@ To make changes, either extend these classes or change fishbowl. """ -from gafferpy.gaffer_predicates import AbstractPredicate +import typing +from gafferpy.gaffer_core import AbstractPredicate, Function, Predicate +from gafferpy.gaffer_functions import ElementTransformer class DefaultUserPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.access.predicate.user.DefaultUserPredicate" def __init__( - self, - auths=None, - creating_user_id=None): + self, + auths: typing.Optional[typing.List[str]] = None, + creating_user_id: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.auths = auths self.creating_user_id = creating_user_id @@ -66,8 +69,9 @@ class ElementJoinComparator(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.data.element.comparison.ElementJoinComparator" def __init__( - self, - group_by_properties=None): + self, + group_by_properties: typing.Optional[typing.Set[str]] = None, + ): super().__init__(_class_name=self.CLASS) self.group_by_properties = group_by_properties @@ -82,8 +86,9 @@ class ElementFilter(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.data.element.function.ElementFilter" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates @@ -98,8 +103,9 @@ class PropertiesFilter(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.data.element.function.PropertiesFilter" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates @@ -114,9 +120,10 @@ class NamedViewWriteUserPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.user.NamedViewWriteUserPredicate" def __init__( - self, - auths=None, - creating_user_id=None): + self, + auths: typing.Optional[typing.List[str]] = None, + creating_user_id: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.auths = auths self.creating_user_id = creating_user_id @@ -134,10 +141,11 @@ class FederatedGraphReadUserPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.federatedstore.access.predicate.user.FederatedGraphReadUserPredicate" def __init__( - self, - public=None, - auths=None, - creating_user_id=None): + self, + public: typing.Optional[bool] = None, + auths: typing.Optional[typing.List[str]] = None, + creating_user_id: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.public = public self.auths = auths @@ -158,8 +166,9 @@ class FederatedGraphWriteUserPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.federatedstore.access.predicate.user.FederatedGraphWriteUserPredicate" def __init__( - self, - creating_user_id=None): + self, + creating_user_id: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.creating_user_id = creating_user_id @@ -174,9 +183,10 @@ class TransformAndFilter(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.graph.hook.migrate.predicate.TransformAndFilter" def __init__( - self, - filter=None, - transformer=None): + self, + filter: typing.Optional[ElementFilter] = None, + transformer: typing.Optional[ElementTransformer] = None, + ): super().__init__(_class_name=self.CLASS) self.filter = filter self.transformer = transformer @@ -204,9 +214,10 @@ class HyperLogLogPlusIsLessThan(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.predicate.HyperLogLogPlusIsLessThan" def __init__( - self, - value=None, - or_equal_to=None): + self, + value: typing.Optional[int] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value self.or_equal_to = or_equal_to @@ -224,9 +235,10 @@ class HllSketchIsLessThan(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.sketches.datasketches.cardinality.predicate.HllSketchIsLessThan" def __init__( - self, - value=None, - or_equal_to=None): + self, + value: typing.Optional[int] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value self.or_equal_to = or_equal_to @@ -254,11 +266,12 @@ class RBMBackedTimestampSetInRange(AbstractPredicate): CLASS = "uk.gov.gchq.gaffer.time.predicate.RBMBackedTimestampSetInRange" def __init__( - self, - start_time=None, - end_time=None, - include_all_timestamps=None, - time_unit=None): + self, + start_time: typing.Optional[typing.Any] = None, + end_time: typing.Optional[typing.Any] = None, + include_all_timestamps: typing.Optional[bool] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.start_time = start_time self.end_time = end_time @@ -282,10 +295,11 @@ class AgeOff(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.AgeOff" def __init__( - self, - age_off_hours=None, - age_off_days=None, - age_off_time=None): + self, + age_off_hours: typing.Optional[int] = None, + age_off_days: typing.Optional[int] = None, + age_off_time: typing.Optional[int] = None, + ): super().__init__(_class_name=self.CLASS) self.age_off_hours = age_off_hours self.age_off_days = age_off_days @@ -316,8 +330,9 @@ class And(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.And" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates @@ -342,9 +357,10 @@ class AreIn(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.AreIn" def __init__( - self, - values=None, - null_or_empty_values_accepted=None): + self, + values: typing.Optional[typing.List[typing.Any]] = None, + null_or_empty_values_accepted: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.values = values self.null_or_empty_values_accepted = null_or_empty_values_accepted @@ -362,8 +378,9 @@ class CollectionContains(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.CollectionContains" def __init__( - self, - value=None): + self, + value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value @@ -388,11 +405,12 @@ class If(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.If" def __init__( - self, - otherwise=None, - predicate=None, - condition=None, - then=None): + self, + otherwise: typing.Optional[Predicate] = None, + predicate: typing.Optional[Predicate] = None, + condition: typing.Optional[bool] = None, + then: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.otherwise = otherwise self.predicate = predicate @@ -416,8 +434,9 @@ class IsA(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsA" def __init__( - self, - type=None): + self, + type: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.type = type @@ -432,8 +451,9 @@ class IsEqual(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsEqual" def __init__( - self, - value=None): + self, + value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value @@ -458,8 +478,9 @@ class IsIn(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsIn" def __init__( - self, - values=None): + self, + values: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.values = values @@ -474,9 +495,10 @@ class IsLessThan(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsLessThan" def __init__( - self, - value=None, - or_equal_to=None): + self, + value: typing.Optional[typing.Any] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value self.or_equal_to = or_equal_to @@ -494,9 +516,10 @@ class IsLongerThan(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsLongerThan" def __init__( - self, - min_length=None, - or_equal_to=None): + self, + min_length: typing.Optional[int] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.min_length = min_length self.or_equal_to = or_equal_to @@ -514,9 +537,10 @@ class IsMoreThan(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan" def __init__( - self, - value=None, - or_equal_to=None): + self, + value: typing.Optional[typing.Any] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value self.or_equal_to = or_equal_to @@ -534,9 +558,10 @@ class IsShorterThan(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.IsShorterThan" def __init__( - self, - max_length=None, - or_equal_to=None): + self, + max_length: typing.Optional[int] = None, + or_equal_to: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.max_length = max_length self.or_equal_to = or_equal_to @@ -584,8 +609,9 @@ class MapContains(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.MapContains" def __init__( - self, - key=None): + self, + key: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.key = key @@ -600,8 +626,9 @@ class MapContainsPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.MapContainsPredicate" def __init__( - self, - key_predicate=None): + self, + key_predicate: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.key_predicate = key_predicate @@ -616,8 +643,9 @@ class MultiRegex(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.MultiRegex" def __init__( - self, - value=None): + self, + value: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value @@ -632,8 +660,9 @@ class Not(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.Not" def __init__( - self, - predicate=None): + self, + predicate: typing.Optional[Predicate] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate @@ -648,8 +677,9 @@ class Or(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.Or" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates @@ -664,8 +694,9 @@ class Regex(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.Regex" def __init__( - self, - value=None): + self, + value: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.value = value @@ -680,9 +711,10 @@ class StringContains(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.StringContains" def __init__( - self, - ignore_case=None, - value=None): + self, + ignore_case: typing.Optional[bool] = None, + value: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.ignore_case = ignore_case self.value = value @@ -700,16 +732,17 @@ class InDateRange(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InDateRange" def __init__( - self, - end_offset=None, - offset_unit=None, - start_offset=None, - start_inclusive=None, - start=None, - time_zone=None, - end=None, - end_inclusive=None, - time_unit=None): + self, + end_offset: typing.Optional[int] = None, + offset_unit: typing.Optional[str] = None, + start_offset: typing.Optional[int] = None, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + end: typing.Optional[str] = None, + end_inclusive: typing.Optional[bool] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.end_offset = end_offset self.offset_unit = offset_unit @@ -748,18 +781,19 @@ class InDateRangeDual(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InDateRangeDual" def __init__( - self, - end_fully_contained=None, - end_offset=None, - offset_unit=None, - start_offset=None, - start_inclusive=None, - start=None, - time_zone=None, - end=None, - end_inclusive=None, - start_fully_contained=None, - time_unit=None): + self, + end_fully_contained: typing.Optional[bool] = None, + end_offset: typing.Optional[int] = None, + offset_unit: typing.Optional[str] = None, + start_offset: typing.Optional[int] = None, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + end: typing.Optional[str] = None, + end_inclusive: typing.Optional[bool] = None, + start_fully_contained: typing.Optional[bool] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.end_fully_contained = end_fully_contained self.end_offset = end_offset @@ -804,11 +838,12 @@ class InRange(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InRange" def __init__( - self, - start_inclusive=None, - start=None, - end=None, - end_inclusive=None): + self, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[typing.Any] = None, + end: typing.Optional[typing.Any] = None, + end_inclusive: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.start_inclusive = start_inclusive self.start = start @@ -832,13 +867,14 @@ class InRangeDual(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InRangeDual" def __init__( - self, - end_fully_contained=None, - start_inclusive=None, - start=None, - end=None, - end_inclusive=None, - start_fully_contained=None): + self, + end_fully_contained: typing.Optional[bool] = None, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[typing.Any] = None, + end: typing.Optional[typing.Any] = None, + end_inclusive: typing.Optional[bool] = None, + start_fully_contained: typing.Optional[bool] = None, + ): super().__init__(_class_name=self.CLASS) self.end_fully_contained = end_fully_contained self.start_inclusive = start_inclusive @@ -868,16 +904,17 @@ class InTimeRange(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange" def __init__( - self, - end_offset=None, - offset_unit=None, - start_offset=None, - start_inclusive=None, - start=None, - time_zone=None, - end=None, - end_inclusive=None, - time_unit=None): + self, + end_offset: typing.Optional[int] = None, + offset_unit: typing.Optional[str] = None, + start_offset: typing.Optional[int] = None, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + end: typing.Optional[str] = None, + end_inclusive: typing.Optional[bool] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.end_offset = end_offset self.offset_unit = offset_unit @@ -916,18 +953,19 @@ class InTimeRangeDual(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.impl.predicate.range.InTimeRangeDual" def __init__( - self, - end_fully_contained=None, - end_offset=None, - offset_unit=None, - start_offset=None, - start_inclusive=None, - start=None, - time_zone=None, - end=None, - end_inclusive=None, - start_fully_contained=None, - time_unit=None): + self, + end_fully_contained: typing.Optional[bool] = None, + end_offset: typing.Optional[int] = None, + offset_unit: typing.Optional[str] = None, + start_offset: typing.Optional[int] = None, + start_inclusive: typing.Optional[bool] = None, + start: typing.Optional[str] = None, + time_zone: typing.Optional[str] = None, + end: typing.Optional[str] = None, + end_inclusive: typing.Optional[bool] = None, + start_fully_contained: typing.Optional[bool] = None, + time_unit: typing.Optional[str] = None, + ): super().__init__(_class_name=self.CLASS) self.end_fully_contained = end_fully_contained self.end_offset = end_offset @@ -972,9 +1010,10 @@ class AdaptedPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.predicate.AdaptedPredicate" def __init__( - self, - predicate=None, - input_adapter=None): + self, + predicate: typing.Optional[Predicate] = None, + input_adapter: typing.Optional[Function] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate self.input_adapter = input_adapter @@ -992,8 +1031,9 @@ class PredicateComposite(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.predicate.PredicateComposite" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates @@ -1008,9 +1048,10 @@ class PredicateMap(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.predicate.PredicateMap" def __init__( - self, - predicate=None, - key=None): + self, + predicate: typing.Optional[Predicate] = None, + key: typing.Optional[typing.Any] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate self.key = key @@ -1028,10 +1069,11 @@ class IntegerTupleAdaptedPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate" def __init__( - self, - predicate=None, - input_adapter=None, - selection=None): + self, + predicate: typing.Optional[Predicate] = None, + input_adapter: typing.Optional[Function] = None, + selection: typing.Optional[typing.List[int]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate self.input_adapter = input_adapter @@ -1052,10 +1094,11 @@ class TupleAdaptedPredicate(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate" def __init__( - self, - predicate=None, - input_adapter=None, - selection=None): + self, + predicate: typing.Optional[Predicate] = None, + input_adapter: typing.Optional[Function] = None, + selection: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicate = predicate self.input_adapter = input_adapter @@ -1076,8 +1119,9 @@ class TupleAdaptedPredicateComposite(AbstractPredicate): CLASS = "uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicateComposite" def __init__( - self, - predicates=None): + self, + predicates: typing.Optional[typing.List[typing.Any]] = None, + ): super().__init__(_class_name=self.CLASS) self.predicates = predicates diff --git a/src/gafferpy_examples/example.py b/src/gafferpy_examples/example.py index 449cbad1..9997df85 100755 --- a/src/gafferpy_examples/example.py +++ b/src/gafferpy_examples/example.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -361,7 +361,7 @@ def add_cardinality_entity(gc): group='Cardinality', vertex='M1:1', properties={ - 'hllp': g.hyper_log_log_plus(['M1']), + 'hll': g.hll_sketch(['M1']), 'count': g.long(60), 'edgeGroup': g.tree_set(['RoadHasJunction']) } diff --git a/src/generate.py b/src/generate.py index e349a651..6cadcb74 100644 --- a/src/generate.py +++ b/src/generate.py @@ -1,12 +1,17 @@ -import os - +from pathlib import Path from gafferpy.gaffer_connector import GafferConnector from fishbowl.fishbowl import Fishbowl +import urllib # Generate the core api using spring-rest as it has access to every store operation gc = GafferConnector("http://localhost:8080/rest") -dirname = os.path.dirname(__file__) -filename = os.path.join(dirname, 'gafferpy/generated_api') +generated_dir_path = Path(__file__).parent / "gafferpy/generated_api" -Fishbowl(gc, generated_directory_path=filename) +try: + Fishbowl(gc, generated_directory_path=generated_dir_path) +except urllib.error.URLError: + print( + "Unable to connect to running Gaffer API at localhost:8080. Please ensure " + "this is running before using Fishbowl." + ) diff --git a/src/test/test_connector.py b/src/test/test_connector.py deleted file mode 100755 index 478cd428..00000000 --- a/src/test/test_connector.py +++ /dev/null @@ -1,197 +0,0 @@ -# -# Copyright 2016-2019 Crown Copyright -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import unittest -import json - -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - - -class BaseTestCases: - class GafferConnectorTest(unittest.TestCase): - client_class = "" - - def test_execute_operation(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest', - client_class=self.client_class) - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] - ) - ) - ) - - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) - - def test_is_operation_supported(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest', - client_class=self.client_class) - - response = gc.is_operation_supported( - g.IsOperationSupported( - operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' - ), - json_result=True - ) - response.pop("next") - response_text = json.dumps(response) - - expected_response_text = ''' - { - "name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "summary": "Gets all elements compatible with a provided View", - "fields": [ - { - "name": "view", - "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", - "required": false - }, - { - "name": "options", - "className": "java.util.Map", - "required": false - }, - { - "name": "directedType", - "summary": "Is the Edge directed?", - "className": "java.lang.String", - "options": [ - "DIRECTED", - "UNDIRECTED", - "EITHER" - ], - "required": false - }, - { - "name": "views", - "className": "java.util.List", - "required": false - } - ], - "exampleJson": { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, - "outputClassName": "java.lang.Iterable" - } - ''' - - self.assertEqual( - json.loads(expected_response_text), - json.loads(response_text) - ) - - def test_execute_get(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest', - client_class=self.client_class) - - response = gc.execute_get( - g.GetSchema(), - json_result=True - ) - - self.assertTrue( - isinstance(response, dict) and response != {} - ) - - def test_dummy_header(self): - '''Test that the addition of a dummy header does not effect the standard test''' - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest', - headers={ - "dummy_Header": "value"}, - client_class=self.client_class) - elements = gc.execute_operation( - g.GetElements( - input=[ - g.EntitySeed('M5:10') - ], - view=g.View( - edges=[ - g.ElementDefinition( - group='JunctionLocatedAt' - ) - ] - ) - ) - ) - - self.assertEqual( - [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, - "SOURCE")], - elements) - - def test_class_initilisation(self): - '''Test that the gaffer_connector class is correctly initialised with instance attributes''' - host = 'http://localhost:8080/rest/latest' - verbose = False - headers = {"dummy_Header": "value"} - gc = gaffer_connector.GafferConnector( - host, verbose, headers, client_class=self.client_class) - - actuals = [gc._host, gc._verbose, gc._headers] - expecteds = [host, verbose, headers] - - for actual, expected in zip(actuals, expecteds): - self.assertEqual(actual, expected) - - def test_raise_connection_error(self): - '''Test that a ConnectionError is correctly raised when a HTTP 404 error is caught''' - # Define a host that has an invalid endpoint in order to get a HTTP 404 error - host_with_bad_endpoint = "http://localhost:8080/badEndPoint" - gc = gaffer_connector.GafferConnector( - host_with_bad_endpoint, client_class=self.client_class) - - # Check that a ConnectionError is raised (which is catching the underlying HTTP 404) - with self.assertRaises(ConnectionError): - gc.execute_get(g.GetOperations()) - - def test_raise_connection_error_https(self): - '''Test that an error is correctly raised when a HTTPS endpoint cannot be found''' - # Define a host that uses https - host_with_ssh_endpoint = "https://localhost:8080/rest/latest" - gc = gaffer_connector.GafferConnector( - host_with_ssh_endpoint, client_class=self.client_class) - - # Check that an OSError is raised (caused by SSLError) - with self.assertRaises(OSError): - gc.execute_get(g.GetOperations()) - - -class GafferConnectorUrllibTest(BaseTestCases.GafferConnectorTest): - client_class = "urllib" - - -class GafferConnectorRequestsTest(BaseTestCases.GafferConnectorTest): - client_class = "requests" - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/test_gaffer_functions_it.py b/src/test/test_gaffer_functions_it.py deleted file mode 100755 index 87ef865f..00000000 --- a/src/test/test_gaffer_functions_it.py +++ /dev/null @@ -1,64 +0,0 @@ -# -# Copyright 2016-2019 Crown Copyright -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import json -import unittest - -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - - -class GafferFunctionsIntegrationTest(unittest.TestCase): - def test_all_functions_have_classes(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') - functions = gc.execute_get( - g.GetTransformFunctions() - ) - functions = json.loads(functions) - - ignore_functions = [ - 'uk.gov.gchq.gaffer.operation.data.generator.EdgeIdExtractor', - 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToIngestElementKey', - 'uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator', - 'uk.gov.gchq.gaffer.data.element.function.ElementTransformer', - 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficCsvElementGenerator', - 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToElementKey', - 'uk.gov.gchq.koryphe.function.FunctionComposite', - 'uk.gov.gchq.gaffer.rest.example.ExampleTransformFunction', - 'uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop', - 'uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform', - 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToQueryElementKey', - 'uk.gov.gchq.koryphe.tuple.TupleInputAdapter', - 'uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor', - 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator', - 'uk.gov.gchq.gaffer.rest.example.ExampleElementGenerator', - 'uk.gov.gchq.gaffer.sketches.datasketches.cardinality.HllSketchEntityGenerator', - 'uk.gov.gchq.gaffer.sketches.clearspring.cardinality.HyperLogLogPlusEntityGenerator', - 'uk.gov.gchq.gaffer.data.element.function.PropertiesTransformer' - ] - - for i in ignore_functions: - if i in functions: - functions.remove(i) - - for op in functions: - self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, - 'Missing transform function class: ' + op) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/test_gaffer_operations_it.py b/src/test/test_gaffer_operations_it.py deleted file mode 100755 index 9af64461..00000000 --- a/src/test/test_gaffer_operations_it.py +++ /dev/null @@ -1,91 +0,0 @@ -# -# Copyright 2016-2022 Crown Copyright -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import json -import unittest - -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - - -class GafferOperationsIntegrationTest(unittest.TestCase): - def test_all_supported_operations_have_classes(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') - operations = gc.execute_get( - g.GetOperations() - ) - operations = json.loads(operations) - for op in operations: - self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, - 'Missing operation class: ' + op) - - def test_all_supported_operation_examples(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') - operation_details = gc.execute_get( - g.GetOperationsDetails(), json_result=True - ) - for detail in operation_details: - try: - gc.execute_operation( - g.JsonConverter.from_json( - detail["exampleJson"], - class_name=detail["name"])) - except ConnectionError as e: - # Ignore 500 as a lot of operation examples won't run as they have dummy data - # We just care they are valid operations and don't return 400 error - if "HTTP error 500" in e.__str__(): - pass - else: - raise e - - def _get_all_subclasses(self, cls): - all_subclasses = [] - - for subclass in cls.__subclasses__(): - if hasattr(subclass, "CLASS"): - all_subclasses.append(subclass) - all_subclasses.extend(self._get_all_subclasses(subclass)) - - return all_subclasses - - def test_all_operation_classes_are_valid(self): - # TODO: This should be in fishbowl tests in the future - # only the spring-rest has this endpoint - gc = gaffer_connector.GafferConnector('http://localhost:8080/rest/latest') - - try: - response = gc.execute_get( - g.GetOperationsDetailsAll(), - json_result=True - ) - except BaseException: - return - - response = [operation["name"] for operation in response] - - operation_subclasses = self._get_all_subclasses(g.Operation) - expected_response = set(c.CLASS for c in operation_subclasses) - - self.assertEqual( - sorted(expected_response), - sorted(response) - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/test_gaffer_predicates_it.py b/src/test/test_gaffer_predicates_it.py deleted file mode 100755 index 3b4c7d2d..00000000 --- a/src/test/test_gaffer_predicates_it.py +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright 2016-2019 Crown Copyright -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import json -import unittest - -from gafferpy import gaffer as g -from gafferpy import gaffer_connector - - -class GafferPredicatesIntegrationTest(unittest.TestCase): - def test_all_predicates_have_classes(self): - gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest') - predicates = gc.execute_get( - g.GetFilterFunctions() - ) - predicates = json.loads(predicates) - - ignore_predicates = [ - 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', - 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', - 'uk.gov.gchq.koryphe.predicate.PredicateComposite', - 'uk.gov.gchq.gaffer.rest.example.ExampleFilterFunction', - 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate', - 'uk.gov.gchq.gaffer.data.element.function.ElementFilter', - 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicateComposite', - 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$IsElementAggregated', - 'uk.gov.gchq.gaffer.graph.hook.migrate.predicate.TransformAndFilter', - 'uk.gov.gchq.gaffer.data.element.function.PropertiesFilter' - ] - - for i in ignore_predicates: - if i in predicates: - predicates.remove(i) - - for op in predicates: - self.assertTrue(op in g.JsonConverter.GENERIC_JSON_CONVERTERS, - 'Missing predicate class: ' + op) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/test_json_converter.py b/src/test/test_json_converter.py deleted file mode 100644 index dc47f36d..00000000 --- a/src/test/test_json_converter.py +++ /dev/null @@ -1,57 +0,0 @@ -# -# Copyright 2016-2019 Crown Copyright -# -# Licensed under the Apache License, Version 2.0 (the 'License'); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an 'AS IS' BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import unittest -import json - -from gafferpy import gaffer as g -from gafferpy.gaffer_core import JsonConverter - - -class JsonConverterTest(unittest.TestCase): - def test_throw_improper_string_json(self): - with self.assertRaises(json.JSONDecodeError): - JsonConverter.from_json('Not json') - - def test_throw_when_op(self): - with self.assertRaises(TypeError): - JsonConverter.from_json(g.GetAllElements()) - - def test_throw_when_not_json(self): - class NonJsonSerialisable(): - pass - - with self.assertRaises(TypeError): - JsonConverter.from_json(NonJsonSerialisable()) - - def test_correct_json(self): - op_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - } - - self.assertEqual(JsonConverter.from_json(op_json), g.GetAllElements()) - - def test_incorrect_json(self): - op_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - } - - with self.assertRaises(TypeError): - JsonConverter.from_json(op_json, g.GetAllGraphIds()) - - -if __name__ == "__main__": - unittest.main() diff --git a/src/test/__init__.py b/tests/__init__.py similarity index 82% rename from src/test/__init__.py rename to tests/__init__.py index d04722b9..6764c339 100644 --- a/src/test/__init__.py +++ b/tests/__init__.py @@ -8,4 +8,4 @@ __author__ = "GCHQ" __license__ = "Apache 2.0" -__copyright__ = "Crown Copyright (c) 2016-2022" +__copyright__ = "Crown Copyright (c) 2016-2023" diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 00000000..6764c339 --- /dev/null +++ b/tests/integration/__init__.py @@ -0,0 +1,11 @@ +__version__ = "2.0.0" + +__title__ = "gafferpy" +__description__ = "Gaffer Python Shell" +__uri__ = "https://github.com/gchq/gafferpy" +__doc__ = __description__ + " <" + __uri__ + ">" + +__author__ = "GCHQ" + +__license__ = "Apache 2.0" +__copyright__ = "Crown Copyright (c) 2016-2023" diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py new file mode 100644 index 00000000..bce27b60 --- /dev/null +++ b/tests/integration/conftest.py @@ -0,0 +1,119 @@ +# +# Copyright 2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from urllib.error import URLError + +import pytest + +from gafferpy import gaffer_connector, gaffer as g + + +def _connection_test(): + gc = gaffer_connector.GafferConnector( + 'http://localhost:8080/rest/latest' + ) + try: + gc.execute_get(operation=g.GetStatus()) + return True + except (URLError, ConnectionError): + return False + + +def skip_connection(): + if not _connection_test(): + pytest.skip( + reason="Skipping integration tests as cannot connect to localhost", + allow_module_level=True + ) + + +def _return_gaffer_connector(): + return gaffer_connector.GafferConnector( + 'http://localhost:8080/rest/latest' + ) + + +@pytest.fixture +def gc(): + """ + Vanilla Gaffer Connector used in various test modules + """ + return _return_gaffer_connector() + + +def _get_predicates(gc=_return_gaffer_connector()): + predicates = gc.execute_get( + g.GetFilterFunctions() + ) + predicates = g.json.loads(predicates) + + ignore_predicates = [ + 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', + 'uk.gov.gchq.koryphe.predicate.AdaptedPredicate', + 'uk.gov.gchq.koryphe.predicate.PredicateComposite', + 'uk.gov.gchq.gaffer.rest.example.ExampleFilterFunction', + 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate', + 'uk.gov.gchq.gaffer.data.element.function.ElementFilter', + 'uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicateComposite', + 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$IsElementAggregated', + 'uk.gov.gchq.gaffer.graph.hook.migrate.predicate.TransformAndFilter', + 'uk.gov.gchq.gaffer.data.element.function.PropertiesFilter' + ] + + predicates = [pred for pred in predicates if pred not in ignore_predicates] + + return predicates + + +def _get_functions(gc=_return_gaffer_connector()): + functions = gc.execute_get( + g.GetTransformFunctions() + ) + functions = g.json.loads(functions) + + ignore_functions = [ + 'uk.gov.gchq.gaffer.operation.data.generator.EdgeIdExtractor', + 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToIngestElementKey', + 'uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator', + 'uk.gov.gchq.gaffer.data.element.function.ElementTransformer', + 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficCsvElementGenerator', + 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToElementKey', + 'uk.gov.gchq.koryphe.function.FunctionComposite', + 'uk.gov.gchq.gaffer.rest.example.ExampleTransformFunction', + 'uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop', + 'uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform', + 'uk.gov.gchq.gaffer.store.util.AggregatorUtil$ToQueryElementKey', + 'uk.gov.gchq.koryphe.tuple.TupleInputAdapter', + 'uk.gov.gchq.gaffer.operation.data.generator.EntityIdExtractor', + 'uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator', + 'uk.gov.gchq.gaffer.rest.example.ExampleElementGenerator', + 'uk.gov.gchq.gaffer.sketches.datasketches.cardinality.HllSketchEntityGenerator', + 'uk.gov.gchq.gaffer.sketches.clearspring.cardinality.HyperLogLogPlusEntityGenerator', + 'uk.gov.gchq.gaffer.data.element.function.PropertiesTransformer' + ] + + functions = [func for func in functions if func not in ignore_functions] + + return functions + + +def _get_operations(gc=_return_gaffer_connector()): + operations = gc.execute_get( + g.GetOperations() + ) + operations = g.json.loads(operations) + + return operations diff --git a/tests/integration/test_connector.py b/tests/integration/test_connector.py new file mode 100755 index 00000000..7df871be --- /dev/null +++ b/tests/integration/test_connector.py @@ -0,0 +1,186 @@ +# +# Copyright 2016-2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + +from gafferpy import gaffer as g +from gafferpy import gaffer_connector + +from .conftest import skip_connection + +skip_connection() + + +pytestmark = pytest.mark.parametrize( + "client_class,gc", + [ + ( + "urllib", + gaffer_connector.GafferConnector( + "http://localhost:8080/rest/latest", + client_class="urllib" + ) + ), + ( + "requests", + gaffer_connector.GafferConnector( + "http://localhost:8080/rest/latest", + client_class="requests" + ) + ) + ] +) + + +def test_execute_operation(client_class, gc): + elements = gc.execute_operation( + g.GetElements( + input=[ + g.EntitySeed('M5:10') + ], + view=g.View( + edges=[ + g.ElementDefinition( + group='JunctionLocatedAt' + ) + ] + ) + ) + ) + + assert elements == [ + g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", + True, {}, "SOURCE" + ) + ] + + +def test_is_operation_supported(client_class, gc): + response = gc.is_operation_supported( + g.IsOperationSupported( + operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' + ), + json_result=True + ) + response.pop("next") + + expected_response_json = {"name": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", + "summary": "Gets all elements compatible with a provided View", + "fields": [{"name": "view", + "className": "uk.gov.gchq.gaffer.data.elementdefinition.view.View", + "required": False}, + {"name": "options", + "className": "java.util.Map", + "required": False}, + {"name": "directedType", + "summary": "Is the Edge directed?", + "className": "java.lang.String", + "options": ["DIRECTED", + "UNDIRECTED", + "EITHER"], + "required": False}, + {"name": "views", + "className": "java.util.List", + "required": False}], + "exampleJson": {"class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements"}, + "outputClassName": "java.lang.Iterable"} + + assert response == expected_response_json + + +def test_execute_get(client_class, gc): + response = gc.execute_get( + g.GetSchema(), + json_result=True + ) + + assert isinstance(response, dict) and response != {} + + +def test_dummy_header(client_class, gc): + """ + Test that the addition of a dummy header does not effect the standard test + """ + gc = gaffer_connector.GafferConnector( + 'http://localhost:8080/rest/latest', + headers={ + "dummy_Header": "value"}, + client_class=client_class + ) + + elements = gc.execute_operation( + g.GetElements( + input=[ + g.EntitySeed('M5:10') + ], + view=g.View( + edges=[ + g.ElementDefinition( + group='JunctionLocatedAt' + ) + ] + ) + ) + ) + + assert elements == [g.Edge("JunctionLocatedAt", "M5:10", "390466,225615", True, {}, + "SOURCE")] + + +def test_class_initilisation(client_class, gc): + """ + Test that the gaffer_connector class is correctly initialised with instance attributes + """ + host = 'http://localhost:8080/rest/latest' + verbose = False + headers = {"dummy_Header": "value"} + gc = gaffer_connector.GafferConnector( + host, verbose, headers, client_class=client_class + ) + + actuals = [gc._host, gc._verbose, gc._headers] + expecteds = [host, verbose, headers] + + for actual, expected in zip(actuals, expecteds): + assert actual == expected + + +def test_raise_connection_error(client_class, gc): + """ + Test that a ConnectionError is correctly raised when a HTTP 404 error is caught + """ + # Define a host that has an invalid endpoint in order to get a HTTP 404 error + host_with_bad_endpoint = "http://localhost:8080/badEndPoint" + gc = gaffer_connector.GafferConnector( + host_with_bad_endpoint, client_class=client_class) + + # Check that a ConnectionError is raised (which is catching the underlying HTTP 404) + with pytest.raises(ConnectionError): + gc.execute_get(g.GetOperations()) + + +def test_raise_connection_error_https(client_class, gc): + """ + Test that an error is correctly raised when a HTTPS endpoint cannot be found + """ + # Define a host that uses https + host_with_ssh_endpoint = "https://localhost:8080/rest/latest" + gc = gaffer_connector.GafferConnector( + host_with_ssh_endpoint, client_class=client_class) + + # Check that an OSError is raised (caused by SSLError) + with pytest.raises(OSError): + gc.execute_get(g.GetOperations()) diff --git a/src/test/test_example.py b/tests/integration/test_example.py similarity index 71% rename from src/test/test_example.py rename to tests/integration/test_example.py index 13ee6231..b763d83e 100755 --- a/src/test/test_example.py +++ b/tests/integration/test_example.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,15 +14,12 @@ # limitations under the License. # -import unittest - from gafferpy_examples import example +from .conftest import skip_connection -class ExampleTest(unittest.TestCase): - def test_example_does_not_error(self): - example.run('http://localhost:8080/rest/latest') +skip_connection() -if __name__ == "__main__": - unittest.main() +def test_example_does_not_error(): + example.run('http://localhost:8080/rest/latest') diff --git a/src/test/test_example_map.py b/tests/integration/test_example_map.py similarity index 70% rename from src/test/test_example_map.py rename to tests/integration/test_example_map.py index c1e1fdaf..09f1723d 100644 --- a/src/test/test_example_map.py +++ b/tests/integration/test_example_map.py @@ -1,5 +1,5 @@ # -# Copyright 2021 Crown Copyright +# Copyright 2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,15 +14,12 @@ # limitations under the License. # -import unittest - from gafferpy_examples import example_map +from .conftest import skip_connection -class ExampleMapTest(unittest.TestCase): - def test_example_map_does_not_error(self): - example_map.run('http://localhost:8080/rest/latest') +skip_connection() -if __name__ == "__main__": - unittest.main() +def test_example_map_does_not_error(): + example_map.run('http://localhost:8080/rest/latest') diff --git a/tests/integration/test_gaffer_functions_it.py b/tests/integration/test_gaffer_functions_it.py new file mode 100755 index 00000000..5ad3a179 --- /dev/null +++ b/tests/integration/test_gaffer_functions_it.py @@ -0,0 +1,32 @@ +# +# Copyright 2016-2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + +from gafferpy import gaffer as g + +from .conftest import skip_connection, _get_functions + +skip_connection() + + +@pytest.fixture(params=_get_functions()) +def functions_to_test(request): + return request.param + + +def test_all_functions_have_classes(functions_to_test): + assert functions_to_test in g.JsonConverter.GENERIC_JSON_CONVERTERS diff --git a/tests/integration/test_gaffer_operations_it.py b/tests/integration/test_gaffer_operations_it.py new file mode 100755 index 00000000..9c33008f --- /dev/null +++ b/tests/integration/test_gaffer_operations_it.py @@ -0,0 +1,83 @@ +# +# Copyright 2016-2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + +from gafferpy import gaffer as g + +from .conftest import skip_connection, _get_operations + +skip_connection() + + +@pytest.fixture(params=_get_operations()) +def operations_to_test(request): + return request.param + + +def test_all_supported_operations_have_classes(operations_to_test): + assert operations_to_test in g.JsonConverter.GENERIC_JSON_CONVERTERS + + +def test_all_supported_operation_examples(gc): + operation_details = gc.execute_get( + g.GetOperationsDetails(), json_result=True + ) + for detail in operation_details: + try: + gc.execute_operation( + g.JsonConverter.from_json( + detail["exampleJson"], + class_name=detail["name"] + ) + ) + except ConnectionError as e: + # Ignore 500 as a lot of operation examples won't run as they have dummy data + # We just care they are valid operations and don't return 400 error + if "HTTP error 500" in e.__str__(): + pass + else: + raise e + + +def _get_all_subclasses(cls): + all_subclasses = [] + + for subclass in cls.__subclasses__(): + if hasattr(subclass, "CLASS"): + all_subclasses.append(subclass) + all_subclasses.extend(_get_all_subclasses(subclass)) + + return all_subclasses + + +def test_all_operation_classes_are_valid(gc): + # TODO: This should be in fishbowl tests in the future + # only the spring-rest has this endpoint + try: + response = gc.execute_get( + g.GetOperationsDetailsAll(), + json_result=True + ) + except BaseException: + return + + response = [operation["name"] for operation in response] + + operation_subclasses = _get_all_subclasses(g.Operation) + expected_response = set(c.CLASS for c in operation_subclasses) + + assert sorted(expected_response) == sorted(response) diff --git a/tests/integration/test_gaffer_predicates_it.py b/tests/integration/test_gaffer_predicates_it.py new file mode 100755 index 00000000..cd6ead4a --- /dev/null +++ b/tests/integration/test_gaffer_predicates_it.py @@ -0,0 +1,32 @@ +# +# Copyright 2016-2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + +from gafferpy import gaffer as g + +from .conftest import skip_connection, _get_predicates + +skip_connection() + + +@pytest.fixture(params=_get_predicates()) +def predicates_to_test(request): + return request.param + + +def test_all_predicates_have_classes(predicates_to_test): + assert predicates_to_test in g.JsonConverter.GENERIC_JSON_CONVERTERS diff --git a/src/test/road-traffic-example/addOperationsToChain.json b/tests/road-traffic-example/addOperationsToChain.json similarity index 100% rename from src/test/road-traffic-example/addOperationsToChain.json rename to tests/road-traffic-example/addOperationsToChain.json diff --git a/src/test/road-traffic-example/federatedGraphConfig.json b/tests/road-traffic-example/federatedGraphConfig.json similarity index 100% rename from src/test/road-traffic-example/federatedGraphConfig.json rename to tests/road-traffic-example/federatedGraphConfig.json diff --git a/src/test/road-traffic-example/federatedStore.properties b/tests/road-traffic-example/federatedStore.properties similarity index 100% rename from src/test/road-traffic-example/federatedStore.properties rename to tests/road-traffic-example/federatedStore.properties diff --git a/src/test/road-traffic-example/graphConfig.json b/tests/road-traffic-example/graphConfig.json similarity index 100% rename from src/test/road-traffic-example/graphConfig.json rename to tests/road-traffic-example/graphConfig.json diff --git a/src/test/road-traffic-example/roadTrafficSampleData.csv b/tests/road-traffic-example/roadTrafficSampleData.csv similarity index 100% rename from src/test/road-traffic-example/roadTrafficSampleData.csv rename to tests/road-traffic-example/roadTrafficSampleData.csv diff --git a/src/test/road-traffic-example/schema/elements.json b/tests/road-traffic-example/schema/elements.json similarity index 100% rename from src/test/road-traffic-example/schema/elements.json rename to tests/road-traffic-example/schema/elements.json diff --git a/src/test/road-traffic-example/schema/types.json b/tests/road-traffic-example/schema/types.json similarity index 100% rename from src/test/road-traffic-example/schema/types.json rename to tests/road-traffic-example/schema/types.json diff --git a/src/test/road-traffic-example/store.properties b/tests/road-traffic-example/store.properties similarity index 100% rename from src/test/road-traffic-example/store.properties rename to tests/road-traffic-example/store.properties diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..6764c339 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,11 @@ +__version__ = "2.0.0" + +__title__ = "gafferpy" +__description__ = "Gaffer Python Shell" +__uri__ = "https://github.com/gchq/gafferpy" +__doc__ = __description__ + " <" + __uri__ + ">" + +__author__ = "GCHQ" + +__license__ = "Apache 2.0" +__copyright__ = "Crown Copyright (c) 2016-2023" diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py new file mode 100644 index 00000000..705fb48f --- /dev/null +++ b/tests/unit/conftest.py @@ -0,0 +1,32 @@ +# +# Copyright 2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest + + +@pytest.fixture +def get_all_elements_json(): + return { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" + } + + +@pytest.fixture +def non_serialisable_object(): + class NonJsonSerialisable(): + pass + + return NonJsonSerialisable diff --git a/src/test/test_gaffer_functions.py b/tests/unit/test_gaffer_functions.py similarity index 98% rename from src/test/test_gaffer_functions.py rename to tests/unit/test_gaffer_functions.py index 1ed6dfec..577670f1 100755 --- a/src/test/test_gaffer_functions.py +++ b/tests/unit/test_gaffer_functions.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,14 +14,14 @@ # limitations under the License. # -import json -import unittest +import pytest from gafferpy import gaffer as g -class GafferFunctionsTest(unittest.TestCase): - examples = [ +@pytest.mark.parametrize( + "json_string,gafferpy_method", + [ [ ''' { @@ -1147,17 +1147,7 @@ class GafferFunctionsTest(unittest.TestCase): ]) ] ] - - def test_examples(self): - for example in self.examples: - self.assertEqual( - json.loads(example[0]), - example[1].to_json(), - "json failed: \n" + example[0] + "\n" - + g.JsonConverter.from_json(example[0]).to_code_string() - ) - g.JsonConverter.from_json(example[0], validate=True) - - -if __name__ == "__main__": - unittest.main() +) +def test_functions(json_string, gafferpy_method): + assert g.json.loads(json_string) == gafferpy_method.to_json() + g.JsonConverter.from_json(json_string, validate=True) diff --git a/src/test/test_gaffer_operations.py b/tests/unit/test_gaffer_operations.py similarity index 79% rename from src/test/test_gaffer_operations.py rename to tests/unit/test_gaffer_operations.py index 74f30274..abb0dcdd 100755 --- a/src/test/test_gaffer_operations.py +++ b/tests/unit/test_gaffer_operations.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,38 +14,38 @@ # limitations under the License. # -import json -import unittest +import pytest from gafferpy import gaffer as g from gafferpy.gaffer_operations import GetSchema -class GafferOperationsTest(unittest.TestCase): - examples = [ +@pytest.mark.parametrize( + "json_string,gafferpy_method", + [ [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements", - "validate" : true, - "skipInvalidElements" : false, - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements", + "validate" : true, + "skipInvalidElements" : false, + "input" : [ { "group" : "entity", "vertex" : 6, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Entity" - }, { + }, { "group" : "edge", "source" : 5, "destination" : 6, "directed" : true, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Edge" - } ] + } ] } ''', g.AddElements( @@ -70,12 +70,12 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile", - "filename" : "filename", - "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", - "parallelism" : 1, - "validate" : true, - "skipInvalidElements" : false + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile", + "filename" : "filename", + "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", + "parallelism" : 1, + "validate" : true, + "skipInvalidElements" : false } ''', g.AddElementsFromFile( @@ -90,14 +90,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka", - "topic" : "topic1", - "groupId" : "groupId1", - "bootstrapServers" : [ "hostname1:8080,hostname2:8080" ], - "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", - "parallelism" : 1, - "validate" : true, - "skipInvalidElements" : false + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka", + "topic" : "topic1", + "groupId" : "groupId1", + "bootstrapServers" : [ "hostname1:8080,hostname2:8080" ], + "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", + "parallelism" : 1, + "validate" : true, + "skipInvalidElements" : false } ''', g.AddElementsFromKafka( @@ -116,14 +116,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket", - "hostname" : "localhost", - "port" : 8080, - "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", - "parallelism" : 1, - "validate" : true, - "skipInvalidElements" : false, - "delimiter" : "," + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket", + "hostname" : "localhost", + "port" : 8080, + "elementGenerator" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", + "parallelism" : 1, + "validate" : true, + "skipInvalidElements" : false, + "delimiter" : "," } ''', g.AddElementsFromSocket( @@ -140,12 +140,12 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.CountGroups" - } ] + } ] } ''', g.OperationChain( @@ -159,13 +159,13 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.CountGroups", "limit" : 5 - } ] + } ] } ''', g.OperationChain( @@ -181,17 +181,17 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", "key" : "ALL" - } ] + } ] } ''', g.OperationChain( @@ -208,16 +208,16 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails" - } ] + } ] } ''', g.OperationChain( @@ -232,12 +232,12 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", "jobId" : "0f47bc2a-547d-4990-9104-04a8dd64e588", "key" : "ALL" - } ] + } ] } ''', g.OperationChain( @@ -252,31 +252,31 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", "key" : "edges" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", "key" : "entities" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.GetExports", "getExports" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", - "key" : "edges" + "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", + "key" : "edges" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", - "key" : "entities" + "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", + "key" : "entities" + } ] } ] - } ] } ''', g.OperationChain( @@ -307,19 +307,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", "graphId" : "graph2" - } ] + } ] } ''', g.OperationChain( @@ -344,21 +344,21 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph", "graphId" : "newGraphId", "parentSchemaIds" : [ "schemaId1" ], "parentStorePropertiesId" : "storePropsId1" - } ] + } ] } ''', g.OperationChain( @@ -387,19 +387,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "graphId" : "newGraphId" - } ] + } ] } ''', g.OperationChain( @@ -424,66 +424,66 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "graphId" : "newGraphId", "schema" : { - "edges" : { + "edges" : { "edge" : { - "properties" : { + "properties" : { "count" : "int" - }, - "groupBy" : [ ], - "directed" : "true", - "source" : "int", - "destination" : "int" + }, + "groupBy" : [ ], + "directed" : "true", + "source" : "int", + "destination" : "int" } - }, - "entities" : { + }, + "entities" : { "entity" : { - "properties" : { + "properties" : { "count" : "int" - }, - "groupBy" : [ ], - "vertex" : "int" + }, + "groupBy" : [ ], + "vertex" : "int" } - }, - "types" : { + }, + "types" : { "int" : { - "aggregateFunction" : { + "aggregateFunction" : { "class" : "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" - }, - "class" : "java.lang.Integer" + }, + "class" : "java.lang.Integer" }, "true" : { - "validateFunctions" : [ { + "validateFunctions" : [ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsTrue" - } ], - "class" : "java.lang.Boolean" + } ], + "class" : "java.lang.Boolean" + } } - } }, "storeProperties" : { - "accumulo.instance" : "someInstanceName", - "gaffer.cache.service.class" : "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService", - "accumulo.password" : "password", - "accumulo.zookeepers" : "localhost", - "gaffer.store.class" : "uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore", - "gaffer.store.job.tracker.enabled" : "true", - "gaffer.store.operation.declarations" : "ExportToOtherGraphOperationDeclarations.json", - "gaffer.store.properties.class" : "uk.gov.gchq.gaffer.accumulostore.AccumuloProperties", - "accumulo.user" : "user01" + "accumulo.instance" : "someInstanceName", + "gaffer.cache.service.class" : "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService", + "accumulo.password" : "password", + "accumulo.zookeepers" : "localhost", + "gaffer.store.class" : "uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore", + "gaffer.store.job.tracker.enabled" : "true", + "gaffer.store.operation.declarations" : "ExportToOtherGraphOperationDeclarations.json", + "gaffer.store.properties.class" : "uk.gov.gchq.gaffer.accumulostore.AccumuloProperties", + "accumulo.user" : "user01" } - } ] + } ] } ''', g.OperationChain( @@ -531,26 +531,26 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "graphId" : "otherGafferRestApiGraphId", "storeProperties" : { - "gaffer.host" : "localhost", - "gaffer.context-root" : "/rest/v1", - "gaffer.store.class" : "uk.gov.gchq.gaffer.proxystore.ProxyStore", - "gaffer.port" : "8081", - "gaffer.store.properties.class" : "uk.gov.gchq.gaffer.proxystore.ProxyProperties" + "gaffer.host" : "localhost", + "gaffer.context-root" : "/rest/v1", + "gaffer.store.class" : "uk.gov.gchq.gaffer.proxystore.ProxyStore", + "gaffer.port" : "8081", + "gaffer.store.properties.class" : "uk.gov.gchq.gaffer.proxystore.ProxyProperties" } - } ] + } ] } ''', g.OperationChain( @@ -580,19 +580,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "graphId" : "exportGraphId" - } ] + } ] } ''', g.OperationChain( @@ -617,21 +617,21 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } } - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph", "graphId" : "newGraphId", "parentSchemaIds" : [ "exportSchemaId" ], "parentStorePropertiesId" : "exportStorePropertiesId" - } ] + } ] } ''', g.OperationChain( @@ -660,17 +660,17 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", "start" : 0 - } ] + } ] } ''', g.OperationChain( @@ -687,18 +687,18 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", "start" : 2, "end" : 4 - } ] + } ] } ''', g.OperationChain( @@ -716,33 +716,33 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "key" : "edges" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "key" : "entities" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.GetExports", "getExports" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "key" : "edges", - "start" : 0 + "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", + "key" : "edges", + "start" : 0 }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "key" : "entities", - "start" : 0 + "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", + "key" : "entities", + "start" : 0 + } ] } ] - } ] } ''', g.OperationChain( @@ -775,11 +775,11 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "elementGenerator" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", + "elementGenerator" : { "class" : "uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator" - }, - "input" : [ "1,1", "1,2,1" ] + }, + "input" : [ "1,1", "1,2,1" ] } ''', g.GenerateElements( @@ -796,20 +796,20 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", - "elementGenerator" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", + "elementGenerator" : { "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator" - }, - "input" : [ { + }, + "input" : [ { "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1", "a" : 1, "c" : 1 - }, { + }, { "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2", "a" : 1, "b" : 2, "c" : 1 - } ] + } ] } ''', g.GenerateElements( @@ -819,38 +819,38 @@ class GafferOperationsTest(unittest.TestCase): ), input=[ {'c': 1, - 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1', - 'a': 1}, + 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject1', + 'a': 1}, {'b': 2, 'c': 1, - 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2', - 'a': 1} + 'class': 'uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObject2', + 'a': 1} ] ) ], [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "elementGenerator" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", + "elementGenerator" : { "class" : "uk.gov.gchq.gaffer.doc.operation.generator.ObjectGenerator" - }, - "input" : [ { + }, + "input" : [ { "group" : "entity", "vertex" : 6, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Entity" - }, { + }, { "group" : "edge", "source" : 5, "destination" : 6, "directed" : true, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Edge" - } ] + } ] } ''', g.GenerateObjects( @@ -877,27 +877,27 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", - "elementGenerator" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", + "elementGenerator" : { "class" : "uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator" - }, - "input" : [ { + }, + "input" : [ { "group" : "entity", "vertex" : 6, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Entity" - }, { + }, { "group" : "edge", "source" : 5, "destination" : 6, "directed" : true, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Edge" - } ] + } ] } ''', g.GenerateObjects( @@ -924,11 +924,11 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetAdjacentIds( @@ -942,12 +942,12 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetAdjacentIds( @@ -962,27 +962,27 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "view" : { "edges" : { - "edge" : { + "edge" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 1 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } }, "entities" : { } - }, - "includeIncomingOutGoing" : "OUTGOING", - "input" : [ { + }, + "includeIncomingOutGoing" : "OUTGOING", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetAdjacentIds( @@ -1017,7 +1017,7 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" } ''', g.GetAllElements() @@ -1025,33 +1025,33 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 2 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } }, "entities" : { - "entity" : { + "entity" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 2 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } + } } - } } ''', g.GetAllElements( @@ -1090,7 +1090,7 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails" + "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails" } ''', g.GetAllJobDetails() @@ -1098,17 +1098,17 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }, { + }, { "source" : 2, "destination" : 3, "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ] + } ] } ''', g.GetElements( @@ -1128,15 +1128,15 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }], - "view": { - "allEdges": true, - "allEntities": true - } + }], + "view": { + "allEdges": true, + "allEntities": true + } } ''', g.GetElements( @@ -1154,14 +1154,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }], - "view": { - "allEdges": true - } + }], + "view": { + "allEdges": true + } } ''', g.GetElements( @@ -1179,14 +1179,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }], - "view": { - "allEntities": true - } + }], + "view": { + "allEntities": true + } } ''', g.GetElements( @@ -1203,43 +1203,43 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 1 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } }, "entities" : { - "entity" : { + "entity" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 1 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } } - }, - "input" : [ { + }, + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }, { + }, { "source" : 2, "destination" : 3, "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ] + } ] } ''', g.GetElements( @@ -1289,11 +1289,11 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetElements( @@ -1307,14 +1307,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "source" : 1, "destination" : 2, "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ] + } ] } ''', g.GetElements( @@ -1331,40 +1331,40 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 1 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } }, "entities" : { - "entity" : { + "entity" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 1 - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } } - }, - "input" : [ { + }, + "input" : [ { "source" : 1, "destination" : 2, "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ] + } ] } ''', g.GetElements( @@ -1413,39 +1413,39 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { }, "entities" : { - "entity" : { + "entity" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.Or", "predicates" : [ { - "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", - "orEqualTo" : false, - "value" : 2 + "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", + "orEqualTo" : false, + "value" : 2 }, { - "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", - "orEqualTo" : false, - "value" : 5 + "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", + "orEqualTo" : false, + "value" : 5 } ] - }, - "selection" : [ "count" ] + }, + "selection" : [ "count" ] } ] - } + } } - }, - "input" : [ { + }, + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }, { + }, { "source" : 2, "destination" : 3, "directedType" : "EITHER", "matchedVertex" : "SOURCE", "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" - } ] + } ] } ''', g.GetElements( @@ -1493,41 +1493,41 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "preAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.Or", "predicates" : [ { - "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate", - "predicate" : { + "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate", + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", "orEqualTo" : false, "value" : 2 - }, - "selection" : [ 0 ] + }, + "selection" : [ 0 ] }, { - "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate", - "predicate" : { + "class" : "uk.gov.gchq.koryphe.tuple.predicate.IntegerTupleAdaptedPredicate", + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 3 - }, - "selection" : [ 1 ] + }, + "selection" : [ 1 ] } ] - }, - "selection" : [ "SOURCE", "DESTINATION" ] + }, + "selection" : [ "SOURCE", "DESTINATION" ] } ] - } + } }, "entities" : { } - }, - "input" : [ { + }, + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetElements( @@ -1580,30 +1580,30 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "properties" : [ "vertex|count" ], "transientProperties" : { - "vertex|count" : "java.lang.String" + "vertex|count" : "java.lang.String" }, "transformFunctions" : [ { - "function" : { + "function" : { "class" : "uk.gov.gchq.koryphe.impl.function.Concat", "separator" : "|" - }, - "selection" : [ "SOURCE", "count" ], - "projection" : [ "vertex|count" ] + }, + "selection" : [ "SOURCE", "count" ], + "projection" : [ "vertex|count" ] } ] - } + } }, "entities" : { } - }, - "input" : [ { + }, + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetElements( @@ -1643,30 +1643,30 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "edge" : { + "edge" : { "excludeProperties" : [ "count" ], "transientProperties" : { - "vertex|count" : "java.lang.String" + "vertex|count" : "java.lang.String" }, "transformFunctions" : [ { - "function" : { + "function" : { "class" : "uk.gov.gchq.koryphe.impl.function.Concat", "separator" : "|" - }, - "selection" : [ "SOURCE", "count" ], - "projection" : [ "vertex|count" ] + }, + "selection" : [ "SOURCE", "count" ], + "projection" : [ "vertex|count" ] } ] - } + } }, "entities" : { } - }, - "input" : [ { + }, + "input" : [ { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetElements( @@ -1715,17 +1715,17 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", "key" : "ALL" - } ] + } ] } ''', g.OperationChain( @@ -1742,16 +1742,16 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails" - } ] + } ] } ''', g.OperationChain( @@ -1766,12 +1766,12 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", "jobId" : "675c6d4a-fba0-410b-8b84-6b40d0415555", "key" : "ALL" - } ] + } ] } ''', g.OperationChain( @@ -1786,31 +1786,31 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", "key" : "edges" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.ExportToGafferResultCache", "key" : "entities" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.GetExports", "getExports" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", - "key" : "edges" + "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", + "key" : "edges" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", - "key" : "entities" + "class" : "uk.gov.gchq.gaffer.operation.impl.export.resultcache.GetGafferResultCacheExport", + "key" : "entities" + } ] } ] - } ] } ''', g.OperationChain( @@ -1841,8 +1841,8 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", - "jobId" : "18be2a20-5f36-4598-b522-1efc409b6b39" + "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", + "jobId" : "18be2a20-5f36-4598-b522-1efc409b6b39" } ''', g.GetJobDetails( @@ -1852,8 +1852,8 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", - "jobId" : "92932856-be96-41b3-85d8-bba7b6886284" + "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", + "jobId" : "92932856-be96-41b3-85d8-bba7b6886284" } ''', g.GetJobResults( @@ -1863,17 +1863,17 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", "start" : 0 - } ] + } ] } ''', g.OperationChain( @@ -1890,18 +1890,18 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", "start" : 2, "end" : 4 - } ] + } ] } ''', g.OperationChain( @@ -1919,33 +1919,33 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "key" : "edges" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.ExportToSet", "key" : "entities" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.DiscardOutput" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.export.GetExports", "getExports" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "key" : "edges", - "start" : 0 + "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", + "key" : "edges", + "start" : 0 }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", - "key" : "entities", - "start" : 0 + "class" : "uk.gov.gchq.gaffer.operation.impl.export.set.GetSetExport", + "key" : "entities", + "start" : 0 + } ] } ] - } ] } ''', g.OperationChain( @@ -1978,14 +1978,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", "resultLimit" : 3, "truncate" : true - } ] + } ] } ''', g.OperationChain( @@ -2001,14 +2001,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", "resultLimit" : 3, "truncate" : false - } ] + } ] } ''', g.OperationChain( @@ -2024,14 +2024,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", "resultLimit" : 3, "truncate" : true - } ] + } ] } ''', g.OperationChain( @@ -2047,25 +2047,25 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Max", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false + } ] } ] - } ] } ''', g.OperationChain( @@ -2098,60 +2098,60 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "DESTINATION", "count" ], "projection" : [ "score" ] - } ] + } ] } - }, - "entities" : { + }, + "entities" : { "entity" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "VERTEX", "count" ], "projection" : [ "score" ] - } ] + } ] + } } - } }, "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Max", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false - }, { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "score", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false + }, { + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "score", + "groups" : [ "entity", "edge" ], + "reversed" : false + } ] } ] - } ] } ''', g.OperationChain( @@ -2238,25 +2238,25 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Min", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false + } ] } ] - } ] } ''', g.OperationChain( @@ -2289,60 +2289,60 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "DESTINATION", "count" ], "projection" : [ "score" ] - } ] + } ] } - }, - "entities" : { + }, + "entities" : { "entity" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "VERTEX", "count" ], "projection" : [ "score" ] - } ] + } ] + } } - } }, "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Min", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false - }, { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "score", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false + }, { + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "score", + "groups" : [ "entity", "edge" ], + "reversed" : false + } ] } ] - } ] } ''', g.OperationChain( @@ -2429,22 +2429,22 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "operationName" : "2-hop", - "description" : "2 hop query", - "readAccessRoles" : [ "read-user" ], - "writeAccessRoles" : [ "write-user" ], - "overwriteFlag" : true, - "labels": ["label_1", "label_2"], - "operationChain" : { + "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", + "operationName" : "2-hop", + "description" : "2 hop query", + "readAccessRoles" : [ "read-user" ], + "writeAccessRoles" : [ "write-user" ], + "overwriteFlag" : true, + "labels": ["label_1", "label_2"], + "operationChain" : { "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" } ] - } + } } ''', g.AddNamedOperation( @@ -2473,22 +2473,22 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "operationName" : "2-hop-with-score", - "description" : "2 hop query", - "readAccessRoles" : [ "read-user" ], - "writeAccessRoles" : [ "write-user" ], - "overwriteFlag" : true, - "score" : 3, - "operationChain" : { + "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", + "operationName" : "2-hop-with-score", + "description" : "2 hop query", + "readAccessRoles" : [ "read-user" ], + "writeAccessRoles" : [ "write-user" ], + "overwriteFlag" : true, + "score" : 3, + "operationChain" : { "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" } ] - } + } } ''', g.AddNamedOperation( @@ -2517,32 +2517,32 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "operationName" : "2-hop-with-limit", - "description" : "2 hop query with settable limit", - "readAccessRoles" : [ "read-user" ], - "writeAccessRoles" : [ "write-user" ], - "overwriteFlag" : true, - "parameters" : { + "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", + "operationName" : "2-hop-with-limit", + "description" : "2 hop query with settable limit", + "readAccessRoles" : [ "read-user" ], + "writeAccessRoles" : [ "write-user" ], + "overwriteFlag" : true, + "parameters" : { "param1" : { - "description" : "Limit param", - "defaultValue" : 1, - "valueClass" : "java.lang.Long", - "required" : false + "description" : "Limit param", + "defaultValue" : 1, + "valueClass" : "java.lang.Long", + "required" : false } - }, - "operationChain" : { + }, + "operationChain" : { "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", - "resultLimit" : "${param1}" + "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", + "resultLimit" : "${param1}" } ] - } + } } ''', g.AddNamedOperation( @@ -2582,32 +2582,32 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", - "operationName" : "2-hop-with-limit", - "description" : "2 hop query with settable limit", - "readAccessRoles" : [ "read-user" ], - "writeAccessRoles" : [ "write-user" ], - "overwriteFlag" : true, - "parameters" : { + "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", + "operationName" : "2-hop-with-limit", + "description" : "2 hop query with settable limit", + "readAccessRoles" : [ "read-user" ], + "writeAccessRoles" : [ "write-user" ], + "overwriteFlag" : true, + "parameters" : { "param1" : { - "description" : "Limit param", - "defaultValue" : 1, - "valueClass" : "java.lang.Long", - "required" : false + "description" : "Limit param", + "defaultValue" : 1, + "valueClass" : "java.lang.Long", + "required" : false } - }, - "operationChain" : { + }, + "operationChain" : { "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", - "includeIncomingOutGoing" : "OUTGOING" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", + "includeIncomingOutGoing" : "OUTGOING" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", - "resultLimit" : "${param1}" + "class" : "uk.gov.gchq.gaffer.operation.impl.Limit", + "resultLimit" : "${param1}" } ] - } + } } ''', g.AddNamedOperation( @@ -2647,7 +2647,7 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations" + "class" : "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations" } ''', g.GetAllNamedOperations() @@ -2655,13 +2655,13 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "operationName" : "2-hop", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", + "operationName" : "2-hop", + "input" : [ { "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed", "vertex" : 1, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.NamedOperation( @@ -2676,16 +2676,16 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", - "operationName" : "2-hop-with-limit", - "parameters" : { + "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", + "operationName" : "2-hop-with-limit", + "parameters" : { "param1" : 2 - }, - "input" : [ { + }, + "input" : [ { "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed", "vertex" : 1, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.NamedOperation( @@ -2701,8 +2701,8 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", - "operationName" : "2-hop" + "class" : "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", + "operationName" : "2-hop" } ''', g.DeleteNamedOperation( @@ -2712,27 +2712,27 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Sort", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false } ], "resultLimit" : 10, "deduplicate" : true - } ] + } ] } ''', g.OperationChain( @@ -2767,27 +2767,27 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Sort", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false } ], "resultLimit" : 10, "deduplicate" : false - } ] + } ] } ''', g.OperationChain( @@ -2822,62 +2822,62 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "DESTINATION", "count" ], "projection" : [ "score" ] - } ] + } ] } - }, - "entities" : { + }, + "entities" : { "entity" : { - "transientProperties" : { + "transientProperties" : { "score" : "java.lang.Integer" - }, - "transformFunctions" : [ { + }, + "transformFunctions" : [ { "function" : { - "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" + "class" : "uk.gov.gchq.gaffer.doc.operation.function.ExampleScoreFunction" }, "selection" : [ "VERTEX", "count" ], "projection" : [ "score" ] - } ] + } ] + } } - } }, "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.compare.Sort", "comparators" : [ { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "count", - "groups" : [ "entity", "edge" ], - "reversed" : false - }, { - "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", - "property" : "score", - "groups" : [ "entity", "edge" ], - "reversed" : false + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "count", + "groups" : [ "entity", "edge" ], + "reversed" : false + }, { + "class" : "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator", + "property" : "score", + "groups" : [ "entity", "edge" ], + "reversed" : false } ], "resultLimit" : 4, "deduplicate" : true - } ] + } ] } ''', g.OperationChain( @@ -2966,19 +2966,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToArray" - } ] + } ] } ''', g.OperationChain( @@ -3000,30 +3000,30 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToCsv", "csvGenerator" : { - "class" : "uk.gov.gchq.gaffer.data.generator.CsvGenerator", - "fields" : { + "class" : "uk.gov.gchq.gaffer.data.generator.CsvGenerator", + "fields" : { "GROUP" : "Edge group", "VERTEX" : "vertex", "SOURCE" : "source", "count" : "total count" - }, - "quoted" : false + }, + "quoted" : false }, "includeHeader" : true - } ] + } ] } ''', g.OperationChain( @@ -3056,19 +3056,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds" - } ] + } ] } ''', g.OperationChain( @@ -3090,19 +3090,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToList" - } ] + } ] } ''', g.OperationChain( @@ -3124,28 +3124,28 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToMap", "elementGenerator" : { - "class" : "uk.gov.gchq.gaffer.data.generator.MapGenerator", - "fields" : { + "class" : "uk.gov.gchq.gaffer.data.generator.MapGenerator", + "fields" : { "GROUP" : "group", "VERTEX" : "vertex", "SOURCE" : "source", "count" : "total count" - } + } } - } ] + } ] } ''', g.OperationChain( @@ -3176,14 +3176,14 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "input" : [ { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input" : [ { "vertex" : 1, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - }, { + }, { "vertex" : 2, "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" - } ] + } ] } ''', g.GetElements( @@ -3200,19 +3200,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" - } ] + } ] } ''', g.OperationChain( @@ -3234,19 +3234,19 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToStream" - } ] + } ] } ''', g.OperationChain( @@ -3268,28 +3268,28 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { }, - "entities" : { + "edges" : { }, + "entities" : { "entity" : { } - } + } }, "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "edgeVertices" : "NONE" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" - } ] + } ] } ''', g.OperationChain( @@ -3323,29 +3323,29 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } }, "includeIncomingOutGoing" : "OUTGOING", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "edgeVertices" : "DESTINATION" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" - } ] + } ] } ''', g.OperationChain( @@ -3380,29 +3380,29 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } }, "includeIncomingOutGoing" : "OUTGOING", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "edgeVertices" : "BOTH" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" - } ] + } ] } ''', g.OperationChain( @@ -3437,29 +3437,29 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { - "edges" : { + "edges" : { "edge" : { } - }, - "entities" : { } + }, + "entities" : { } }, "includeIncomingOutGoing" : "OUTGOING", "input" : [ { - "vertex" : 1, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 1, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" }, { - "vertex" : 2, - "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" + "vertex" : 2, + "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToVertices", "useMatchedVertex" : "EQUAL" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" - } ] + } ] } ''', g.OperationChain( @@ -3494,23 +3494,23 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.OperationChain", - "operations" : [ { + "class" : "uk.gov.gchq.gaffer.operation.OperationChain", + "operations" : [ { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", "jobId" : "job1" - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.impl.function.Filter", "globalEdges" : { - "predicates" : [ { + "predicates" : [ { "predicate" : { - "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", - "orEqualTo" : false, - "value" : 2 + "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", + "orEqualTo" : false, + "value" : 2 }, "selection" : [ "count" ] - } ] + } ] } - } ] + } ] } ''', g.OperationChain( @@ -4156,91 +4156,91 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "operations" : [ + "class" : "uk.gov.gchq.gaffer.operation.impl.GetWalks", + "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "BasicEdge" : { + "BasicEdge" : { "properties" : [ "count" ] - } + } }, "entities" : { } - }, - "directedType" : "DIRECTED", - "includeIncomingOutGoing" : "OUTGOING" + }, + "directedType" : "DIRECTED", + "includeIncomingOutGoing" : "OUTGOING" }, { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { }, "entities" : { - "BasicEntity" : { + "BasicEntity" : { "postAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", "orEqualTo" : false, "value" : 3 - }, - "selection" : [ "property1" ] + }, + "selection" : [ "property1" ] } ] - } + } + } } - } }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "BasicEdge" : { + "BasicEdge" : { "properties" : [ "count" ] - } + } }, "entities" : { } - }, - "directedType" : "DIRECTED", - "includeIncomingOutGoing" : "OUTGOING" + }, + "directedType" : "DIRECTED", + "includeIncomingOutGoing" : "OUTGOING" } ] - }, { + }, { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { }, "entities" : { - "BasicEntity" : { + "BasicEntity" : { "postAggregationFilterFunctions" : [ { - "predicate" : { + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", "orEqualTo" : false, "value" : 3 - }, - "selection" : [ "property1" ] + }, + "selection" : [ "property1" ] } ] - } + } + } } - } }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", - "view" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "view" : { "edges" : { - "BasicEdge" : { + "BasicEdge" : { "properties" : [ "count" ] - } + } }, "entities" : { } - }, - "directedType" : "DIRECTED", - "includeIncomingOutGoing" : "OUTGOING" + }, + "directedType" : "DIRECTED", + "includeIncomingOutGoing" : "OUTGOING" } ] - } ], - "resultsLimit" : 1000000, - "input" : [ { + } ], + "resultsLimit" : 1000000, + "input" : [ { "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed", "vertex" : "A" - } ] + } ] } ''', g.GetWalks( @@ -4537,19 +4537,19 @@ class GafferOperationsTest(unittest.TestCase): "group" : "entity", "vertex" : 6, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Entity" - }, { + }, { "group" : "edge", "source" : 5, "destination" : 6, "directed" : true, "properties" : { - "count" : 1 + "count" : 1 }, "class" : "uk.gov.gchq.gaffer.data.element.Edge" - } ], + } ], "numSplits": 5, "proportionToSample": 0.1 } @@ -4637,16 +4637,16 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", - "name" : "testNamedView", - "description" : "example test NamedView", - "view" : { + "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", + "name" : "testNamedView", + "description" : "example test NamedView", + "view" : { "edges" : { - "testEdge" : { } + "testEdge" : { } } - }, - "overwriteFlag" : true, - "writeAccessRoles" : [ "auth1", "auth2" ] + }, + "overwriteFlag" : true, + "writeAccessRoles" : [ "auth1", "auth2" ] } ''', g.AddNamedView( @@ -4665,32 +4665,32 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", - "view" : { + "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", + "view" : { "edges" : { - "testEdge" : { + "testEdge" : { "preAggregationFilterFunctions" : [ { - "selection" : [ "count" ], - "predicate" : { + "selection" : [ "count" ], + "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "value" : "${countThreshold}" - } + } } ] - } + } } - }, - "name" : "isMoreThan", - "description" : "is more than", - "parameters" : { + }, + "name" : "isMoreThan", + "description" : "is more than", + "parameters" : { "countThreshold" : { - "valueClass" : "Long", - "required" : false, - "description" : "count threshold", - "defaultValue" : 1 + "valueClass" : "Long", + "required" : false, + "description" : "count threshold", + "defaultValue" : 1 } - }, - "overwriteFlag" : true, - "writeAccessRoles" : [ "auth1", "auth2" ] + }, + "overwriteFlag" : true, + "writeAccessRoles" : [ "auth1", "auth2" ] } ''', g.AddNamedView( @@ -4726,8 +4726,8 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph", - "graphId" : "graph1" + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph", + "graphId" : "graph1" } ''', g.RemoveGraph( @@ -4737,7 +4737,7 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds" + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds" } ''', g.GetAllGraphIds() @@ -4745,7 +4745,7 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo" + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo" } ''', g.GetAllGraphInfo() @@ -4753,35 +4753,35 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraph", - "graphId" : "graph1", - "isPublic" : false, - "schema" : { + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraph", + "graphId" : "graph1", + "isPublic" : false, + "schema" : { "edges" : { - "RoadHasJunction" : { + "RoadHasJunction" : { "description" : "A directed edge from each road to all the junctions on that road.", "source" : "road", "destination" : "junction", "directed" : "true", "properties" : { }, "groupBy" : [ ] - } + } }, "types" : { - "junction" : { + "junction" : { "description" : "A road junction represented by a String.", "class" : "String" - }, - "road" : { + }, + "road" : { "description" : "A road represented by a String.", "class" : "String" - } + } } - }, - "storeProperties" : { + }, + "storeProperties" : { "gaffer.store.class" : "uk.gov.gchq.gaffer.mapstore.SingleUseMapStore", "gaffer.cache.service.class" : "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService" - } + } } ''', g.AddGraph( @@ -4818,40 +4818,40 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks", - "graphId" : "graph1", - "isPublic" : false, - "schema" : { + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks", + "graphId" : "graph1", + "isPublic" : false, + "schema" : { "edges" : { - "RoadHasJunction" : { + "RoadHasJunction" : { "description" : "A directed edge from each road to all the junctions on that road.", "source" : "road", "destination" : "junction", "directed" : "true", "properties" : { }, "groupBy" : [ ] - } + } }, "types" : { - "junction" : { + "junction" : { "description" : "A road junction represented by a String.", "class" : "String" - }, - "road" : { + }, + "road" : { "description" : "A road represented by a String.", "class" : "String" - } + } } - }, - "storeProperties" : { + }, + "storeProperties" : { "gaffer.store.class" : "uk.gov.gchq.gaffer.mapstore.SingleUseMapStore", "gaffer.cache.service.class" : "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService" - }, - "hooks": [ + }, + "hooks": [ { "class": "uk.gov.gchq.gaffer.graph.hook.Log4jLogger" } - ] + ] } ''', g.AddGraphWithHooks( @@ -5121,18 +5121,18 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", - "operationChain" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", + "operationChain" : { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" } ] - }, - "options" : { + }, + "options" : { "key" : "value" - } + } } ''', g.ValidateOperationChain( @@ -5150,18 +5150,18 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", - "operationChain" : { + "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", + "operationChain" : { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" } ] - }, - "options" : { + }, + "options" : { "key" : "value" - } + } } ''', g.ValidateOperationChain( @@ -5264,18 +5264,18 @@ class GafferOperationsTest(unittest.TestCase): [ ''' { - "class" : "uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation", - "operation": { + "class" : "uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation", + "operation": { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { - "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements" }, { - "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" + "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements" } ] - }, - "options" : { + }, + "options" : { "key" : "value" - } + } } ''', g.FederatedOperation( @@ -5429,69 +5429,71 @@ class GafferOperationsTest(unittest.TestCase): ) ] ] +) +def test_operations(json_string, gafferpy_method): + assert g.json.loads(json_string) == gafferpy_method.to_json() + g.JsonConverter.from_json(json_string, validate=True) - def test_operations(self): - self.maxDiff = None - for example in self.examples: - self.assertEqual( - json.loads(example[0]), - example[1].to_json(), - "json failed: \n" + example[0] + "\n" + example[ - 1].to_json_pretty_str() - ) - g.JsonConverter.from_json(example[0], validate=True) +def test_get_elements_should_handle_single_inputs(): + expected_output_json = { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements", + "input": [ + { + "class": "uk.gov.gchq.gaffer.operation.data.EntitySeed", + "vertex": "value" + } + ] + } + assert g.GetElements(input="value") == expected_output_json + - def test_get_elements_should_handle_single_inputs(self): - self.assertEqual( +def test_get_walks_correct_op(): + expected_output_json = { + "class": "uk.gov.gchq.gaffer.operation.impl.GetWalks", + "operations": [ { - 'class': 'uk.gov.gchq.gaffer.operation.impl.get.GetElements', - 'input': [ + "class": "uk.gov.gchq.gaffer.operation.OperationChain", + "operations": [ { - 'class': 'uk.gov.gchq.gaffer.operation.data.EntitySeed', - 'vertex': 'value' + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" } ] - }, - g.GetElements(input="value").to_json()) - - def test_get_walks_correct_op(self): - expected_output_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "operations": [{ - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" - }] - } - self.assertEqual(g.GetWalks( - operations=[g.GetElements()]), expected_output_json) + } + ] + } + assert g.GetWalks( + operations=[g.OperationChain(operations=[g.GetElements()])] + ) == expected_output_json - def test_get_walks_correct_json(self): - get_elements_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" - } - expected_output_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.GetWalks", - "operations": [{ - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" - }] - } - self.assertEqual( - g.GetWalks(operations=[get_elements_json]), - expected_output_json - ) - def test_federated_graph_ids_helper(self): - expected_output_json = { - "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", - "options": { - "gaffer.federatedstore.operation.graphIds": "graph1,graph2" +def test_get_walks_correct_json(): + get_elements_json = { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" + } + expected_output_json = { + "class": "uk.gov.gchq.gaffer.operation.impl.GetWalks", + "operations": [ + { + "class": "uk.gov.gchq.gaffer.operation.OperationChain", + "operations": [ + { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements" + } + ] } - } - self.assertEqual( - g.GetAllElements(options=["graph1,graph2"]), - expected_output_json - ) + ] + } + assert g.GetWalks( + operations=[g.OperationChain(operations=[get_elements_json])] + ) == expected_output_json -if __name__ == "__main__": - unittest.main() +def test_federated_graph_ids_helper(): + expected_output_json = { + "class": "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", + "options": { + "gaffer.federatedstore.operation.graphIds": "graph1,graph2" + } + } + assert g.GetAllElements(options=["graph1,graph2"]) == expected_output_json diff --git a/src/test/test_gaffer_predicates.py b/tests/unit/test_gaffer_predicates.py similarity index 97% rename from src/test/test_gaffer_predicates.py rename to tests/unit/test_gaffer_predicates.py index 89259a2b..c02a8714 100755 --- a/src/test/test_gaffer_predicates.py +++ b/tests/unit/test_gaffer_predicates.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 Crown Copyright +# Copyright 2016-2023 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ # limitations under the License. # -import unittest - +import pytest from gafferpy import gaffer as g -class GafferPredicatesTest(unittest.TestCase): - examples = [ +@pytest.mark.parametrize( + "json_string,gafferpy_method", + [ [ ''' { @@ -627,16 +627,7 @@ class GafferPredicatesTest(unittest.TestCase): g.NamedViewWriteUserPredicate(auths=["a", "test2"], creating_user_id="user1") ] ] - - def test_examples(self): - for example in self.examples: - self.assertEqual( - g.json.loads(example[0]), - example[1].to_json(), - "json failed: \n" + example[0] - ) - g.JsonConverter.from_json(example[0], validate=True) - - -if __name__ == "__main__": - unittest.main() +) +def test_predicates(json_string, gafferpy_method): + assert g.json.loads(json_string) == gafferpy_method.to_json() + g.JsonConverter.from_json(json_string, validate=True) diff --git a/tests/unit/test_json_converter.py b/tests/unit/test_json_converter.py new file mode 100644 index 00000000..5cec62d8 --- /dev/null +++ b/tests/unit/test_json_converter.py @@ -0,0 +1,45 @@ +# +# Copyright 2016-2023 Crown Copyright +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import pytest +import json + +from gafferpy import gaffer as g +from gafferpy.gaffer_core import JsonConverter + + +def test_throw_improper_string_json(): + with pytest.raises(json.JSONDecodeError): + JsonConverter.from_json('Not json') + + +def test_throw_when_op(): + with pytest.raises(TypeError): + JsonConverter.from_json(g.GetAllElements()) + + +def test_throw_when_not_json(non_serialisable_object): + with pytest.raises(TypeError): + JsonConverter.from_json(non_serialisable_object()) + + +def test_correct_json(get_all_elements_json): + assert JsonConverter.from_json(get_all_elements_json) == g.GetAllElements() + + +def test_incorrect_json(get_all_elements_json): + with pytest.raises(TypeError): + JsonConverter.from_json(get_all_elements_json, g.GetAllGraphIds()) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..74a6f4d1 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +envlist = + py37 + py38 + py39 + py310 + +skip_missing_interpreters = True + +# At least this version is needed for PEP 517/518 support. +minversion = 3.3.0 + +# PEP 517/518 compliant build. Build tools and arguments +# are specified in pyproject.toml. +isolated_build = true + +[testenv] +deps = + pytest + requests>=2.4.0 +commands = + pytest {posargs}