diff --git a/docs/source/conf.py b/docs/source/conf.py index 452a9054..3146182e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,33 +12,33 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../../src/')) +sys.path.insert(0, os.path.abspath("../../src/")) # -- Project information ----------------------------------------------------- -project = 'gafferpy' -copyright = '2022, GCHQ' -author = 'GCHQ' +project = "gafferpy" +copyright = "2022, GCHQ" +author = "GCHQ" # The full version, including alpha/beta/rc tags -release = '2.2.0' +release = "2.2.0" # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# extensions coming with Sphinx (named "sphinx.ext.*") or your custom # ones. extensions = [ - 'sphinx_rtd_theme', - 'sphinx.ext.autodoc', - 'sphinx.ext.napoleon' + "sphinx_rtd_theme", + "sphinx.ext.autodoc", + "sphinx.ext.napoleon" ] -pygments_style = 'sphinx' +pygments_style = "sphinx" # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -51,9 +51,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] diff --git a/src/fishbowl/fishbowl.py b/src/fishbowl/fishbowl.py index 5dd269d1..7ba17ccb 100644 --- a/src/fishbowl/fishbowl.py +++ b/src/fishbowl/fishbowl.py @@ -1,5 +1,5 @@ # -# Copyright 2023 Crown Copyright +# Copyright 2023-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -172,7 +172,7 @@ def _generate_operations(self) -> str: operation_summaries = sorted(operation_summaries, key=lambda op: op["name"]) - op_names = [op['name'] for op in operation_summaries] + op_names = [op["name"] for op in operation_summaries] imports = self._generate_import_strings(op_names) @@ -221,7 +221,7 @@ def _generate_import_strings(self, List of import strings e.g. `from gafferpy.gaffer_binaryoperators import BinaryOperator` """ - get_field_types = self._get_function_dict()['get_field_types'] + get_field_types = self._get_function_dict()["get_field_types"] class_names = [func.split(".")[-1] for func in funcs] @@ -232,12 +232,12 @@ def _generate_import_strings(self, 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: + 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('.') + 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 @@ -245,7 +245,7 @@ def _generate_import_strings(self, import_map[module].add(_class) return [ - f"from {import_path} import {', '.join(sorted(classes))}" for import_path, + f"from {import_path} import {", ".join(sorted(classes))}" for import_path, classes in import_map.items() ] diff --git a/src/gafferpy/client/base_client.py b/src/gafferpy/client/base_client.py index 6ddcc919..ea028c48 100644 --- a/src/gafferpy/client/base_client.py +++ b/src/gafferpy/client/base_client.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2022-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,22 +15,22 @@ # class BaseClient: - ''' + """ This class handles the connection to a Gaffer server and handles operations. This class is initialised with a host to connect to. - ''' + """ def __init__(self, base_url, verbose=False, headers={}, **kwargs): - ''' + """ This initialiser sets up a connection to the specified Gaffer server. The host (and port) of the Gaffer server, should be in the form, - 'hostname:1234/service-name/version' - ''' + "hostname:1234/service-name/version" + """ self.base_url = base_url self.verbose = verbose self.headers = headers - self.headers.setdefault('Content-Type', 'application/json;charset=utf-8') + self.headers.setdefault("Content-Type", "application/json;charset=utf-8") def perform_request(self, method, target, headers=None, body=None, json_result=True): raise NotImplementedError() diff --git a/src/gafferpy/client/pki_client.py b/src/gafferpy/client/pki_client.py index f8986f1b..ea0c2968 100755 --- a/src/gafferpy/client/pki_client.py +++ b/src/gafferpy/client/pki_client.py @@ -1,5 +1,5 @@ # -# Copyright 2022 Crown Copyright +# Copyright 2022-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,12 +22,12 @@ class PkiClient(UrllibClient): def __init__(self, base_url, verbose=False, headers={}, **kwargs): - ''' + """ This initialiser sets up a connection to the specified Gaffer server. The host (and port) of the Gaffer server, should be in the form, - 'hostname:1234/service-name/version' - ''' + "hostname:1234/service-name/version" + """ super().__init__(base_url, verbose, headers, **kwargs) # Fail if none pki, protocol None diff --git a/src/gafferpy/client/requests_client.py b/src/gafferpy/client/requests_client.py index d91bdaf0..7ad3a605 100644 --- a/src/gafferpy/client/requests_client.py +++ b/src/gafferpy/client/requests_client.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,10 +23,10 @@ _REQUESTS_AVAILABLE = True class SSLAdapter(HTTPAdapter): - ''' + """ A subclass of the HTTPS Transport Adapter that is used to setup an arbitrary SSL version for the requests session. - ''' + """ def __init__(self, ssl_version=None, **kwargs): self.ssl_version = ssl_version @@ -48,10 +48,10 @@ def init_poolmanager(self, connections, maxsize, block=False): class RequestsClient(BaseClient): - ''' + """ This class handles the connection to a Gaffer server and handles operations. This class is initialised with a host to connect to. - ''' + """ def __init__(self, base_url, verbose=False, headers={}, **kwargs): if not _REQUESTS_AVAILABLE: @@ -70,7 +70,7 @@ def __init__(self, base_url, verbose=False, headers={}, **kwargs): self._session.verify = kwargs.get("verify", True) self._session.proxies = kwargs.get("proxies", {}) protocol = kwargs.get("protocol", None) - self._session.mount('https://', SSLAdapter(ssl_version=protocol)) + self._session.mount("https://", SSLAdapter(ssl_version=protocol)) def perform_request(self, method, target, headers=None, body=None, json_result=True): url = self.base_url + target @@ -85,7 +85,7 @@ def perform_request(self, method, target, headers=None, body=None, json_result=T response.raise_for_status() except requests.exceptions.HTTPError as error: raise ConnectionError( - 'HTTP error ' + str(error.response.status_code) + ': ' + error.response.text) + "HTTP error " + str(error.response.status_code) + ": " + error.response.text) if not json_result and method == "GET": return response.text @@ -96,10 +96,10 @@ def perform_request(self, method, target, headers=None, body=None, json_result=T response_json = response.text if self.verbose: - print('\nQuery response:\n' + - json.dumps(response_json, indent=4) + '\n') + print("\nQuery response:\n" + + json.dumps(response_json, indent=4) + "\n") - if response_json is not None and response_json != '': + if response_json is not None and response_json != "": result = response_json else: result = None diff --git a/src/gafferpy/client/urllib_client.py b/src/gafferpy/client/urllib_client.py index ea22308d..9a83e51a 100755 --- a/src/gafferpy/client/urllib_client.py +++ b/src/gafferpy/client/urllib_client.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 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,18 +24,18 @@ class UrllibClient(BaseClient): - ''' + """ This class handles the connection to a Gaffer server and handles operations. This class is initialised with a host to connect to. - ''' + """ def __init__(self, base_url, verbose=False, headers={}, **kwargs): - ''' + """ This initialiser sets up a connection to the specified Gaffer server. The host (and port) of the Gaffer server, should be in the form, - 'hostname:1234/service-name/version' - ''' + "hostname:1234/service-name/version" + """ super().__init__(base_url, verbose, headers, **kwargs) # Create the opener @@ -52,22 +52,22 @@ def perform_request(self, method, target, headers=None, body=None, json_result=T try: response = self._opener.open(request) except urllib.error.HTTPError as error: - error_body = error.read().decode('utf-8') - new_error_string = ('HTTP error ' + - str(error.code) + ' ' + - error.reason + ': ' + + error_body = error.read().decode("utf-8") + new_error_string = ("HTTP error " + + str(error.code) + " " + + error.reason + ": " + error_body) raise ConnectionError(new_error_string) - response_text = response.read().decode('utf-8') + response_text = response.read().decode("utf-8") if not json_result and method == "GET": return response_text if self.verbose: - print('Query response: ' + response_text) + print("Query response: " + response_text) - if response_text is not None and response_text != '': + if response_text is not None and response_text != "": result = json.loads(response_text) else: result = None diff --git a/src/gafferpy/fromJson.py b/src/gafferpy/fromJson.py index ad8f96d1..b5c3f12c 100755 --- a/src/gafferpy/fromJson.py +++ b/src/gafferpy/fromJson.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2019 Crown Copyright +# Copyright 2016-2024 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,7 +20,7 @@ if __name__ == "__main__": if len(sys.argv) < 2: - raise TypeError('JSON str argument is required') + raise TypeError("JSON str argument is required") json_str = sys.argv[1] if len(sys.argv) > 2: @@ -31,6 +31,6 @@ pythonObj = g.JsonConverter.from_json(json_str, class_name=class_name) if not isinstance(pythonObj, g.ToCodeString): - raise TypeError('Unable to convert JSON to a Python: ' + json_str) + raise TypeError("Unable to convert JSON to a Python: " + json_str) print(pythonObj.to_code_string()) diff --git a/src/gafferpy/gaffer_binaryoperators.py b/src/gafferpy/gaffer_binaryoperators.py index ad263a9f..677f6074 100755 --- a/src/gafferpy/gaffer_binaryoperators.py +++ b/src/gafferpy/gaffer_binaryoperators.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,9 +34,9 @@ def __init__(self, selection=None, binary_operator=None): def to_json(self): function_json = {} if self.selection is not None: - function_json['selection'] = self.selection + function_json["selection"] = self.selection if self.binary_operator is not None: - function_json['binaryOperator'] = self.binary_operator.to_json() + function_json["binaryOperator"] = self.binary_operator.to_json() return function_json @@ -46,25 +46,25 @@ def to_json(self): def binary_operator_context_converter(obj): - if 'class' in obj: + if "class" in obj: binary_operator = dict(obj) else: - binary_operator = obj['binary_operator'] + binary_operator = obj["binary_operator"] if isinstance(binary_operator, dict): binary_operator = dict(binary_operator) if not isinstance(binary_operator, BinaryOperator): binary_operator = JsonConverter.from_json(binary_operator) if not isinstance(binary_operator, BinaryOperator): - class_name = binary_operator.get('class') - binary_operator.pop('class', None) + class_name = binary_operator.get("class") + binary_operator.pop("class", None) binary_operator = BinaryOperator( class_name=class_name, fields=binary_operator ) return BinaryOperatorContext( - selection=obj.get('selection'), + selection=obj.get("selection"), binary_operator=binary_operator ) @@ -78,8 +78,8 @@ def binary_operator_converter(obj): if not isinstance(binary_operator, BinaryOperator): binary_operator = JsonConverter.from_json(binary_operator) if not isinstance(binary_operator, BinaryOperator): - class_name = binary_operator.get('class') - binary_operator.pop('class', None) + class_name = binary_operator.get("class") + binary_operator.pop("class", None) binary_operator = BinaryOperator( class_name=class_name, fields=binary_operator @@ -91,7 +91,7 @@ def binary_operator_converter(obj): def load_binaryoperator_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj diff --git a/src/gafferpy/gaffer_config.py b/src/gafferpy/gaffer_config.py index 9fd409be..328ad999 100755 --- a/src/gafferpy/gaffer_config.py +++ b/src/gafferpy/gaffer_config.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 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,7 +24,7 @@ class GetGraph: - def __init__(self, _url=''): + def __init__(self, _url=""): self._url = _url def get_url(self): @@ -38,7 +38,7 @@ def get_url(self): class GetClassFilterFunctions(GetFilterFunctions): - def __init__(self, class_name=''): + def __init__(self, class_name=""): super().__init__(class_name) @@ -53,7 +53,7 @@ def get_operation(self): def load_config_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj diff --git a/src/gafferpy/gaffer_connector.py b/src/gafferpy/gaffer_connector.py index 4d962a51..55a83cf7 100644 --- a/src/gafferpy/gaffer_connector.py +++ b/src/gafferpy/gaffer_connector.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ def execute_operation_chain(self, operation_chain, headers=None): """ This method queries Gaffer with the provided operation chain. """ - target = '/graph/operations/execute' + target = "/graph/operations/execute" op_chain_json_obj = ToJson.recursive_to_json(operation_chain) diff --git a/src/gafferpy/gaffer_connector_pki.py b/src/gafferpy/gaffer_connector_pki.py index b44c5b43..5049f872 100644 --- a/src/gafferpy/gaffer_connector_pki.py +++ b/src/gafferpy/gaffer_connector_pki.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ warnings.warn(""" This connector is deprecated, instead use gaffer_connector.GafferConnector( host, - client_class='pki', + client_class="pki", pki = pki, protocol = protocol ) @@ -68,7 +68,7 @@ def __init__(self, cert_filename, password=None): # Read the contents of the certificate file to check that it is # readable - with open(cert_filename, 'r') as cert_file: + with open(cert_filename, "r") as cert_file: self._cert_file_contents = cert_file.read() cert_file.close() @@ -77,7 +77,7 @@ def __init__(self, cert_filename, password=None): # Obtain the password if required and remember it if password is None: - password = getpass.getpass('Password for PEM certificate file: ') + password = getpass.getpass("Password for PEM certificate file: ") self._password = password def get_ssl_context(self, protocol=None): @@ -105,4 +105,4 @@ def get_ssl_context(self, protocol=None): return ssl_context def __str__(self): - return 'Certificates from ' + self._cert_filename + return "Certificates from " + self._cert_filename diff --git a/src/gafferpy/gaffer_core.py b/src/gafferpy/gaffer_core.py index 2714e5de..b360e4a9 100755 --- a/src/gafferpy/gaffer_core.py +++ b/src/gafferpy/gaffer_core.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,13 +37,13 @@ def to_json(self): """ Converts an object to a simple json dictionary """ - raise NotImplementedError('Use an implementation') + raise NotImplementedError("Use an implementation") def to_json_str(self): return json.dumps(ToJson.recursive_to_json(self)) def to_json_pretty_str(self): - return json.dumps(ToJson.recursive_to_json(self), indent=4, separators=(',', ': ')) + return json.dumps(ToJson.recursive_to_json(self), indent=4, separators=(",", ": ")) def pretty_print(self): print(self.to_json_pretty_str()) @@ -90,98 +90,98 @@ class ToCodeString: """ @staticmethod - def obj_to_code_string(obj, indent=''): + def obj_to_code_string(obj, indent=""): if obj is None: - return '' + return "" - new_line = ' \n' + indent - new_line_indent = new_line + ' ' + new_line = " \n" + indent + new_line_indent = new_line + " " if isinstance(obj, ToCodeString): - obj_str = obj.to_code_string(indent=indent + ' ') + obj_str = obj.to_code_string(indent=indent + " ") elif isinstance(obj, list): - obj_str = '[' + obj_str = "[" for item in obj: obj_item_str = ToCodeString.obj_to_code_string(item, - indent=indent + ' ') - if obj_str == '[': - obj_str = obj_str + new_line_indent + ' ' + obj_item_str + indent=indent + " ") + if obj_str == "[": + obj_str = obj_str + new_line_indent + " " + obj_item_str else: - obj_str = obj_str + ',' + new_line_indent + ' ' + obj_item_str - obj_str = obj_str + new_line_indent + ']' + obj_str = obj_str + "," + new_line_indent + " " + obj_item_str + obj_str = obj_str + new_line_indent + "]" elif isinstance(obj, str): obj_str = '"' + obj + '"' else: obj_str = str(obj) return obj_str - def to_code_string(self, header=False, indent=''): - new_line = ' \n' + indent - new_line_indent = new_line + ' ' + def to_code_string(self, header=False, indent=""): + new_line = " \n" + indent + new_line_indent = new_line + " " fields = dict(self.__dict__) - field_code_str = '' + field_code_str = "" for name, val in fields.items(): - if (not name.startswith('_')) and val is not None: + if (not name.startswith("_")) and val is not None: val_str = ToCodeString.obj_to_code_string(val, indent) - if field_code_str == '': - field_code_str = name + '=' + val_str + if field_code_str == "": + field_code_str = name + "=" + val_str else: - field_code_str = field_code_str + ',' + new_line_indent + name + '=' + val_str + field_code_str = field_code_str + "," + new_line_indent + name + "=" + val_str if header: - header_str = 'from gafferpy import gaffer as g\n' + new_line + header_str = "from gafferpy import gaffer as g\n" + new_line else: - header_str = '' + header_str = "" - if field_code_str == '': - return header_str + 'g.' + type(self).__name__ + '()' + if field_code_str == "": + return header_str + "g." + type(self).__name__ + "()" - return header_str + 'g.' + type(self).__name__ + '(' + new_line_indent \ + return header_str + "g." + type(self).__name__ + "(" + new_line_indent \ + field_code_str \ - + new_line + ')' + + new_line + ")" class DirectedType: - EITHER = 'EITHER' - DIRECTED = 'DIRECTED' - UNDIRECTED = 'UNDIRECTED' + EITHER = "EITHER" + DIRECTED = "DIRECTED" + UNDIRECTED = "UNDIRECTED" class InOutType: - EITHER = 'EITHER' - IN = 'INCOMING' - OUT = 'OUTGOING' + EITHER = "EITHER" + IN = "INCOMING" + OUT = "OUTGOING" class SeedMatchingType: - RELATED = 'RELATED' - EQUAL = 'EQUAL' + RELATED = "RELATED" + EQUAL = "EQUAL" class EdgeVertices: - NONE = 'NONE' - SOURCE = 'SOURCE' - DESTINATION = 'DESTINATION' - BOTH = 'BOTH' + NONE = "NONE" + SOURCE = "SOURCE" + DESTINATION = "DESTINATION" + BOTH = "BOTH" class UseMatchedVertex: - IGNORE = 'IGNORE' - EQUAL = 'EQUAL' - OPPOSITE = 'OPPOSITE' + IGNORE = "IGNORE" + EQUAL = "EQUAL" + OPPOSITE = "OPPOSITE" class MatchKey: - LEFT = 'LEFT' - RIGHT = 'RIGHT' + LEFT = "LEFT" + RIGHT = "RIGHT" class JoinType: - FULL = 'FULL' - OUTER = 'OUTER' - INNER = 'INNER' + FULL = "FULL" + OUTER = "OUTER" + INNER = "INNER" class ElementSeed(ToJson, ToCodeString): @@ -189,34 +189,34 @@ def __repr__(self): return json.dumps(self.to_json()) def to_json(self): - raise NotImplementedError('Use either EntitySeed or EdgeSeed') + raise NotImplementedError("Use either EntitySeed or EdgeSeed") def to_json_wrapped(self): - raise NotImplementedError('Use either EntitySeed or EdgeSeed') + raise NotImplementedError("Use either EntitySeed or EdgeSeed") class EntitySeed(ElementSeed): - CLASS = 'uk.gov.gchq.gaffer.operation.data.EntitySeed' + CLASS = "uk.gov.gchq.gaffer.operation.data.EntitySeed" def __init__(self, vertex): super().__init__() self.vertex = vertex def to_json(self): - return {'class': self.CLASS, - 'vertex': self.vertex} + return {"class": self.CLASS, + "vertex": self.vertex} def to_json_wrapped(self): return { self.CLASS: { - 'vertex': self.vertex, - 'class': self.CLASS + "vertex": self.vertex, + "class": self.CLASS } } class EdgeSeed(ElementSeed): - CLASS = 'uk.gov.gchq.gaffer.operation.data.EdgeSeed' + CLASS = "uk.gov.gchq.gaffer.operation.data.EdgeSeed" def __init__(self, source, destination, directed_type, matched_vertex=None): super().__init__() @@ -232,27 +232,27 @@ def __init__(self, source, destination, directed_type, matched_vertex=None): def to_json(self): seed = { - 'class': self.CLASS, - 'source': self.source, - 'destination': self.destination, - 'directedType': self.directed_type + "class": self.CLASS, + "source": self.source, + "destination": self.destination, + "directedType": self.directed_type } if self.matched_vertex is not None: - seed['matchedVertex'] = self.matched_vertex + seed["matchedVertex"] = self.matched_vertex return seed def to_json_wrapped(self): seed = { - 'source': self.source, - 'destination': self.destination, - 'directedType': self.directed_type, - 'class': self.CLASS + "source": self.source, + "destination": self.destination, + "directedType": self.directed_type, + "class": self.CLASS } if self.matched_vertex is not None: - seed['matchedVertex'] = self.matched_vertex + seed["matchedVertex"] = self.matched_vertex return { self.CLASS: seed @@ -268,7 +268,7 @@ def __init__(self, class_name, fields=None): def to_json(self): tmp_json = { - 'class': self.class_name + "class": self.class_name } if self.fields is not None: @@ -279,7 +279,7 @@ def to_json(self): class ElementPropertyComparator(Comparator): - CLASS = 'uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator' + CLASS = "uk.gov.gchq.gaffer.data.element.comparison.ElementPropertyComparator" def __init__(self, groups, property, reversed=False): super().__init__(class_name=None) @@ -290,21 +290,21 @@ def __init__(self, groups, property, reversed=False): def to_json(self): tmp_json = super().to_json() tmp_json["class"] = self.CLASS - tmp_json['groups'] = self.groups - tmp_json['property'] = self.property - tmp_json['reversed'] = self.reversed + tmp_json["groups"] = self.groups + tmp_json["property"] = self.property + tmp_json["reversed"] = self.reversed return tmp_json class SeedPair(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.commonutil.pair.Pair' + CLASS = "uk.gov.gchq.gaffer.commonutil.pair.Pair" def __init__(self, first, second): super().__init__() if isinstance(first, ElementSeed): self.first = first - elif isinstance(first, dict) and 'class' in first: + elif isinstance(first, dict) and "class" in first: self.first = JsonConverter.from_json(first) elif isinstance(first, dict) and EntitySeed.CLASS in first: self.first = first[EntitySeed.CLASS] @@ -319,7 +319,7 @@ def __init__(self, first, second): if isinstance(second, ElementSeed): self.second = second - elif isinstance(second, dict) and 'class' in second: + elif isinstance(second, dict) and "class" in second: self.second = JsonConverter.from_json(second) elif isinstance(second, dict) and EntitySeed.CLASS in second: self.second = second[EntitySeed.CLASS] @@ -334,9 +334,9 @@ def __init__(self, first, second): def to_json(self): return { - 'class': self.CLASS, - 'first': self.first.to_json_wrapped(), - 'second': self.second.to_json_wrapped() + "class": self.CLASS, + "first": self.first.to_json_wrapped(), + "second": self.second.to_json_wrapped() } @@ -344,24 +344,24 @@ class Element(ToJson, ToCodeString): def __init__(self, _class_name, group, properties=None): super().__init__() if not isinstance(_class_name, str): - raise TypeError('ClassName must be a class name string') + raise TypeError("ClassName must be a class name string") if not isinstance(group, str): - raise TypeError('Group must be a string') + raise TypeError("Group must be a string") if not isinstance(properties, dict) and properties is not None: - raise TypeError('properties must be a dictionary or None') + raise TypeError("properties must be a dictionary or None") self._class_name = _class_name self.group = group self.properties = properties def to_json(self): - element = {'class': self._class_name, 'group': self.group} + element = {"class": self._class_name, "group": self.group} if self.properties is not None: - element['properties'] = self.properties + element["properties"] = self.properties return element class Entity(Element): - CLASS = 'uk.gov.gchq.gaffer.data.element.Entity' + CLASS = "uk.gov.gchq.gaffer.data.element.Entity" def __init__(self, group, vertex, properties=None): super().__init__(self.CLASS, group, @@ -370,12 +370,12 @@ def __init__(self, group, vertex, properties=None): def to_json(self): entity = super().to_json() - entity['vertex'] = self.vertex + entity["vertex"] = self.vertex return entity class Edge(Element): - CLASS = 'uk.gov.gchq.gaffer.data.element.Edge' + CLASS = "uk.gov.gchq.gaffer.data.element.Edge" def __init__(self, group, source, destination, directed, properties=None, matched_vertex=None): @@ -383,7 +383,7 @@ def __init__(self, group, source, destination, directed, properties=None, properties) # Validate the arguments if not isinstance(directed, bool): - raise TypeError('Directed must be a boolean') + raise TypeError("Directed must be a boolean") self.source = source self.destination = destination self.directed = directed @@ -391,11 +391,11 @@ def __init__(self, group, source, destination, directed, properties=None, def to_json(self): edge = super().to_json() - edge['source'] = self.source - edge['destination'] = self.destination - edge['directed'] = self.directed + edge["source"] = self.source + edge["destination"] = self.destination + edge["directed"] = self.directed if self.matched_vertex is not None: - edge['matchedVertex'] = self.matched_vertex + edge["matchedVertex"] = self.matched_vertex return edge @@ -407,27 +407,27 @@ class JsonConverter: @staticmethod def to_snake_case(name): - s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) - return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() + s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name) + return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() @staticmethod def object_decoder(obj, class_name=None): if not isinstance(obj, dict): raise TypeError( - 'from_json called on object of type ' + str(type(obj)) + - ', should be a dict. obj: ' + str(obj) + "from_json called on object of type " + str(type(obj)) + + ", should be a dict. obj: " + str(obj) ) if class_name is None: - if 'class' in obj: - class_name = obj.get('class') + if "class" in obj: + class_name = obj.get("class") else: return obj - if obj.get('class'): - if class_name != obj.get('class'): + if obj.get("class"): + if class_name != obj.get("class"): raise TypeError( - 'Argument ' + str(obj) + ' not of type ' + str(class_name) + "Argument " + str(obj) + " not of type " + str(class_name) ) custom_json_converter = JsonConverter.CUSTOM_JSON_CONVERTERS.get( @@ -441,7 +441,7 @@ def object_decoder(obj, class_name=None): if custom_json_converter is not None: obj = custom_json_converter(mapped_obj) else: - mapped_obj.pop('class', None) + mapped_obj.pop("class", None) obj = generic_json_converter(mapped_obj) return obj @@ -452,7 +452,7 @@ def from_json(json_obj, class_obj=None, class_name=None, validate=False): return None if class_obj is not None: - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): class_name = class_obj.CLASS if class_name is not None: @@ -490,11 +490,11 @@ def from_json(json_obj, class_obj=None, class_name=None, validate=False): if not isinstance(json_obj, str): json_obj = json.dumps(json_obj) raise TypeError( - 'Json object could not be deserialised correctly: \n' + json_obj) + "Json object could not be deserialised correctly: \n" + json_obj) if json_obj != obj.to_json(): raise TypeError( - 'Json object could not be deserialised correctly: \n' - 'Original: \n' + "Json object could not be deserialised correctly: \n" + "Original: \n" + json.dumps(json_obj) + " \nConverted:\n" + json.dumps(obj.to_json())) @@ -502,7 +502,7 @@ def from_json(json_obj, class_obj=None, class_name=None, validate=False): if not isinstance(json_obj, str): json_obj = json.dumps(json_obj) raise TypeError( - 'Json object could not be deserialised correctly: \n' + json_obj) + "Json object could not be deserialised correctly: \n" + json_obj) return obj @@ -511,13 +511,13 @@ def validate(obj, expected_class, allow_none=True): if obj is None: if allow_none: return None - raise TypeError('Argument must be of type ' + str(expected_class)) + raise TypeError("Argument must be of type " + str(expected_class)) if not issubclass(expected_class, ToJson): - raise TypeError(str(expected_class) + ' must inherit ToJson') + raise TypeError(str(expected_class) + " must inherit ToJson") if not isinstance(obj, ToJson): obj = JsonConverter.from_json(obj, expected_class) if not isinstance(obj, expected_class): - raise TypeError(str(obj) + ' must be of type ' + + raise TypeError(str(obj) + " must be of type " + str(expected_class)) return obj @@ -525,7 +525,7 @@ def validate(obj, expected_class, allow_none=True): def load_core_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj @@ -548,7 +548,7 @@ def to_json(self): function_json = {} if self.class_name is not None: - function_json['class'] = self.class_name + function_json["class"] = self.class_name return function_json @@ -564,7 +564,7 @@ def to_json(self): function_json = {} if self._class_name is not None: - function_json['class'] = self._class_name + function_json["class"] = self._class_name return function_json @@ -583,7 +583,7 @@ def to_json(self): predicate_json = {} if self.class_name is not None: - predicate_json['class'] = self.class_name + predicate_json["class"] = self.class_name return predicate_json @@ -597,7 +597,7 @@ def to_json(self): predicate_json = {} if self._class_name is not None: - predicate_json['class'] = self._class_name + predicate_json["class"] = self._class_name return predicate_json @@ -616,7 +616,7 @@ def to_json(self): function_json = {} if self.class_name is not None: - function_json['class'] = self.class_name + function_json["class"] = self.class_name return function_json @@ -631,6 +631,6 @@ def __init__(self, _class_name=None): def to_json(self): function_json = {} if self._class_name is not None: - function_json['class'] = self._class_name + function_json["class"] = self._class_name return function_json diff --git a/src/gafferpy/gaffer_functions.py b/src/gafferpy/gaffer_functions.py index c4bdbd0e..979e9f74 100755 --- a/src/gafferpy/gaffer_functions.py +++ b/src/gafferpy/gaffer_functions.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ class ElementGenerator(Function): - CLASS = 'uk.gov.gchq.gaffer.data.generator.ElementGenerator' + CLASS = "uk.gov.gchq.gaffer.data.generator.ElementGenerator" def __init__( self, @@ -51,27 +51,27 @@ def to_json(self): def function_context_converter(obj): - if 'class' in obj: + if "class" in obj: function = dict(obj) else: - function = obj['function'] + function = obj["function"] if isinstance(function, dict): function = dict(function) if not isinstance(function, Function): function = JsonConverter.from_json(function) if not isinstance(function, Function): - class_name = function.get('class') - function.pop('class', None) + class_name = function.get("class") + function.pop("class", None) function = Function( class_name=class_name, fields=function ) return FunctionContext( - selection=obj.get('selection'), + selection=obj.get("selection"), function=function, - projection=obj.get('projection') + projection=obj.get("projection") ) @@ -84,8 +84,8 @@ def function_converter(obj): if not isinstance(function, Function): function = JsonConverter.from_json(function) if not isinstance(function, Function): - class_name = function.get('class') - function.pop('class', None) + class_name = function.get("class") + function.pop("class", None) function = Function( class_name=class_name, fields=function @@ -97,7 +97,7 @@ def function_converter(obj): def load_function_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj diff --git a/src/gafferpy/gaffer_operations.py b/src/gafferpy/gaffer_operations.py index 6d735311..441a9494 100755 --- a/src/gafferpy/gaffer_operations.py +++ b/src/gafferpy/gaffer_operations.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ class NamedOperationParameter(ToJson, ToCodeString): - CLASS = 'gaffer.NamedOperationParameter' + CLASS = "gaffer.NamedOperationParameter" def __init__(self, name, @@ -46,9 +46,9 @@ def get_detail(self): "required": self.required } if self.description is not None: - detail['description'] = self.description + detail["description"] = self.description if self.default_value is not None: - detail['defaultValue'] = self.default_value + detail["defaultValue"] = self.default_value return detail def to_json(self): @@ -61,7 +61,7 @@ def to_json(self): class NamedViewParameter(ToJson, ToCodeString): - CLASS = 'gaffer.NamedViewParameter' + CLASS = "gaffer.NamedViewParameter" def __init__(self, name, @@ -81,9 +81,9 @@ def get_detail(self): "required": self.required } if self.description is not None: - detail['description'] = self.description + detail["description"] = self.description if self.default_value is not None: - detail['defaultValue'] = self.default_value + detail["defaultValue"] = self.default_value return detail def to_json(self): @@ -96,7 +96,7 @@ def to_json(self): class View(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.data.elementdefinition.view.View' + CLASS = "uk.gov.gchq.gaffer.data.elementdefinition.view.View" def __init__(self, entities=None, edges=None, global_elements=None, global_entities=None, global_edges=None, all_edges=False, @@ -199,42 +199,42 @@ def to_json(self): el_defs = {} for el_def in self.entities: el_defs[el_def.group] = el_def.to_json() - view['entities'] = el_defs + view["entities"] = el_defs if self.edges is not None: el_defs = {} for el_def in self.edges: el_defs[el_def.group] = el_def.to_json() - view['edges'] = el_defs + view["edges"] = el_defs if self.global_elements is not None: el_defs = [] for el_def in self.global_elements: el_defs.append(el_def.to_json()) - view['globalElements'] = el_defs + view["globalElements"] = el_defs if self.global_entities is not None: el_defs = [] for el_def in self.global_entities: el_defs.append(el_def.to_json()) - view['globalEntities'] = el_defs + view["globalEntities"] = el_defs if self.global_edges is not None: el_defs = [] for el_def in self.global_edges: el_defs.append(el_def.to_json()) - view['globalEdges'] = el_defs + view["globalEdges"] = el_defs if self.all_edges is True: - view['allEdges'] = True + view["allEdges"] = True if self.all_entities is True: - view['allEntities'] = True + view["allEntities"] = True return view class NamedView(View): - CLASS = 'uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView' + CLASS = "uk.gov.gchq.gaffer.data.elementdefinition.view.NamedView" def __init__(self, name, parameters=None, entities=None, edges=None, global_elements=None, @@ -246,17 +246,17 @@ def __init__(self, name, parameters=None, entities=None, edges=None, def to_json(self): view = super().to_json() - view['class'] = self.CLASS - view['name'] = self.name + view["class"] = self.CLASS + view["name"] = self.name if self.parameters is not None: - view['parameters'] = self.parameters + view["parameters"] = self.parameters return view class ElementDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition' + CLASS = "uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition" - def __init__(self, group='', + def __init__(self, group="", transient_properties=None, group_by=None, pre_aggregation_filter_functions=None, @@ -306,40 +306,40 @@ def __init__(self, group='', def to_json(self): element_def = {} if self.transient_properties is not None: - element_def['transientProperties'] = self.transient_properties + element_def["transientProperties"] = self.transient_properties if self.pre_aggregation_filter_functions is not None: funcs = [] for func in self.pre_aggregation_filter_functions: funcs.append(func.to_json()) - element_def['preAggregationFilterFunctions'] = funcs + element_def["preAggregationFilterFunctions"] = funcs if self.post_aggregation_filter_functions is not None: funcs = [] for func in self.post_aggregation_filter_functions: funcs.append(func.to_json()) - element_def['postAggregationFilterFunctions'] = funcs + element_def["postAggregationFilterFunctions"] = funcs if self.transform_functions is not None: funcs = [] for func in self.transform_functions: funcs.append(func.to_json()) - element_def['transformFunctions'] = funcs + element_def["transformFunctions"] = funcs if self.post_transform_filter_functions is not None: funcs = [] for func in self.post_transform_filter_functions: funcs.append(func.to_json()) - element_def['postTransformFilterFunctions'] = funcs + element_def["postTransformFilterFunctions"] = funcs if self.group_by is not None: - element_def['groupBy'] = self.group_by + element_def["groupBy"] = self.group_by if self.properties is not None: - element_def['properties'] = self.properties + element_def["properties"] = self.properties if self.exclude_properties is not None: - element_def['excludeProperties'] = self.exclude_properties + element_def["excludeProperties"] = self.exclude_properties return element_def class ElementTransformDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.ElementTransformDefinition' + CLASS = "uk.gov.gchq.gaffer.operation.impl.function.ElementTransformDefinition" - def __init__(self, group='', + def __init__(self, group="", functions=None): super().__init__() self.group = group @@ -352,12 +352,12 @@ def to_json(self): funcs = [] for func in self.functions: funcs.append(func.to_json()) - element_def['functions'] = funcs + element_def["functions"] = funcs return element_def class AggregatePair(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.util.AggregatePair' + CLASS = "uk.gov.gchq.gaffer.operation.util.AggregatePair" def __init__(self, group=None, @@ -371,20 +371,20 @@ def __init__(self, if element_aggregator is not None and not isinstance(element_aggregator, ElementAggregateDefinition): element_aggregator = ElementAggregateDefinition( - operators=element_aggregator['operators']) + operators=element_aggregator["operators"]) self.element_aggregator = element_aggregator def to_json(self): element_def = {} if self.group_by is not None: - element_def['groupBy'] = self.group_by + element_def["groupBy"] = self.group_by if self.element_aggregator is not None: - element_def['elementAggregator'] = self.element_aggregator.to_json() + element_def["elementAggregator"] = self.element_aggregator.to_json() return element_def class ElementAggregateDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.ElementAggregateDefinition' + CLASS = "uk.gov.gchq.gaffer.operation.impl.function.ElementAggregateDefinition" def __init__(self, operators=None): super().__init__() @@ -397,14 +397,14 @@ def to_json(self): funcs = [] for function in self.operators: funcs.append(function.to_json()) - element_def['operators'] = funcs + element_def["operators"] = funcs return element_def class ElementFilterDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.ElementFilterDefinition' + CLASS = "uk.gov.gchq.gaffer.operation.impl.function.ElementFilterDefinition" - def __init__(self, group='', + def __init__(self, group="", predicates=None): super().__init__() self.group = group @@ -417,12 +417,12 @@ def to_json(self): funcs = [] for function in self.predicates: funcs.append(function.to_json()) - element_def['predicates'] = funcs + element_def["predicates"] = funcs return element_def class GlobalElementFilterDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.impl.function.GlobalElementFilterDefinition' + CLASS = "uk.gov.gchq.gaffer.operation.impl.function.GlobalElementFilterDefinition" def __init__(self, predicates=None): super().__init__() @@ -435,12 +435,12 @@ def to_json(self): funcs = [] for func in self.predicates: funcs.append(func.to_json()) - element_def['predicates'] = funcs + element_def["predicates"] = funcs return element_def class GlobalElementDefinition(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.data.elementdefinition.view.GlobalViewElementDefinition' + CLASS = "uk.gov.gchq.gaffer.data.elementdefinition.view.GlobalViewElementDefinition" def __init__(self, transient_properties=None, @@ -488,33 +488,33 @@ def __init__(self, def to_json(self): element_def = {} if self.transient_properties is not None: - element_def['transientProperties'] = self.transient_properties + element_def["transientProperties"] = self.transient_properties if self.pre_aggregation_filter_functions is not None: funcs = [] for func in self.pre_aggregation_filter_functions: funcs.append(func.to_json()) - element_def['preAggregationFilterFunctions'] = funcs + element_def["preAggregationFilterFunctions"] = funcs if self.post_aggregation_filter_functions is not None: funcs = [] for func in self.post_aggregation_filter_functions: funcs.append(func.to_json()) - element_def['postAggregationFilterFunctions'] = funcs + element_def["postAggregationFilterFunctions"] = funcs if self.transform_functions is not None: funcs = [] for func in self.transform_functions: funcs.append(func.to_json()) - element_def['transformFunctions'] = funcs + element_def["transformFunctions"] = funcs if self.post_transform_filter_functions is not None: funcs = [] for func in self.post_transform_filter_functions: funcs.append(func.to_json()) - element_def['postTransformFilterFunctions'] = funcs + element_def["postTransformFilterFunctions"] = funcs if self.group_by is not None: - element_def['groupBy'] = self.group_by + element_def["groupBy"] = self.group_by if self.properties is not None: - element_def['properties'] = self.properties + element_def["properties"] = self.properties if self.exclude_properties is not None: - element_def['excludeProperties'] = self.exclude_properties + element_def["excludeProperties"] = self.exclude_properties return element_def @@ -524,9 +524,9 @@ class Property(ToJson, ToCodeString): def __init__(self, name, class_name): super().__init__() if not isinstance(name, str): - raise TypeError('Name must be a string') + raise TypeError("Name must be a string") if not isinstance(class_name, str): - raise TypeError('ClassName must be a class name string') + raise TypeError("ClassName must be a class name string") self.name = name self.class_name = class_name @@ -562,20 +562,20 @@ def __init__(self, # e.g. options = ["graph_1", "graph_2"] if isinstance(options, list): options = { - "gaffer.federatedstore.operation.graphIds": ','.join(options) + "gaffer.federatedstore.operation.graphIds": ",".join(options) } self.options = options def to_json(self): - operation = {'class': self._class_name} + operation = {"class": self._class_name} if self.options is not None: - operation['options'] = self.options + operation["options"] = self.options if self.view is not None: - operation['view'] = ToJson.recursive_to_json(self.view) + operation["view"] = ToJson.recursive_to_json(self.view) if self.views is not None: - operation['views'] = [] + operation["views"] = [] for view in self.views: - operation['views'].append(ToJson.recursive_to_json(view)) + operation["views"].append(ToJson.recursive_to_json(view)) return operation @@ -602,7 +602,7 @@ def __init__(self, _class_name): def to_json(self): return { - 'class': self._class_name + "class": self._class_name } @@ -617,7 +617,7 @@ def __init__(self, group_by_properties=None): def to_json(self): match_json = super().to_json() if (self.group_by_properties is not None): - match_json['groupByProperties'] = self.group_by_properties + match_json["groupByProperties"] = self.group_by_properties return match_json @@ -643,15 +643,15 @@ def __init__(self, first_key_function=None, second_key_function=None): def to_json(self): match_json = super().to_json() if self.first_key_function is not None: - match_json['firstKeyFunction'] = self.first_key_function.to_json() + match_json["firstKeyFunction"] = self.first_key_function.to_json() if self.second_key_function is not None: - match_json['secondKeyFunction'] = self.second_key_function.to_json() + match_json["secondKeyFunction"] = self.second_key_function.to_json() return match_json class Conditional(ToJson, ToCodeString): - CLASS = 'uk.gov.gchq.gaffer.operation.util.Conditional' + CLASS = "uk.gov.gchq.gaffer.operation.util.Conditional" def __init__(self, predicate=None, transform=None): self.predicate = JsonConverter.validate( @@ -683,9 +683,9 @@ def to_json(self): operation_json = super().to_json() if self.parameters is not None: if isinstance(self.parameters, list): - operation_json['parameters'] = {} + operation_json["parameters"] = {} for param in self.parameters: - operation_json['parameters'][param.name] = param.get_detail() + operation_json["parameters"][param.name] = param.get_detail() return operation_json @@ -694,9 +694,9 @@ def to_json(self): operation_json = super().to_json() if self.parameters is not None: if isinstance(self.parameters, list): - operation_json['parameters'] = {} + operation_json["parameters"] = {} for param in self.parameters: - operation_json['parameters'][param.name] = param.get_detail() + operation_json["parameters"][param.name] = param.get_detail() return operation_json # Element definitions @@ -707,14 +707,14 @@ def to_json(self): operation_json = super().to_json() if self.edges is not None: if isinstance(self.edges, list): - operation_json['edges'] = {} + operation_json["edges"] = {} for el_def in self.edges: - operation_json['edges'][el_def.group] = el_def.to_json() + operation_json["edges"][el_def.group] = el_def.to_json() if self.entities is not None: if isinstance(self.entities, list): - operation_json['entities'] = {} + operation_json["entities"] = {} for el_def in self.entities: - operation_json['entities'][el_def.group] = el_def.to_json() + operation_json["entities"][el_def.group] = el_def.to_json() return operation_json @@ -723,14 +723,14 @@ def to_json(self): operation_json = super().to_json() if self.edges is not None: if isinstance(self.edges, list): - operation_json['edges'] = {} + operation_json["edges"] = {} for el_def in self.edges: - operation_json['edges'][el_def.group] = el_def.to_json() + operation_json["edges"][el_def.group] = el_def.to_json() if self.entities is not None: if isinstance(self.entities, list): - operation_json['entities'] = {} + operation_json["entities"] = {} for el_def in self.entities: - operation_json['entities'][el_def.group] = el_def.to_json() + operation_json["entities"][el_def.group] = el_def.to_json() return operation_json @@ -739,14 +739,14 @@ def to_json(self): operation_json = super().to_json() if self.edges is not None: if isinstance(self.edges, list): - operation_json['edges'] = {} + operation_json["edges"] = {} for el_def in self.edges: - operation_json['edges'][el_def.group] = el_def.to_json() + operation_json["edges"][el_def.group] = el_def.to_json() if self.entities is not None: if isinstance(self.entities, list): - operation_json['entities'] = {} + operation_json["entities"] = {} for el_def in self.entities: - operation_json['entities'][el_def.group] = el_def.to_json() + operation_json["entities"][el_def.group] = el_def.to_json() return operation_json # List Input @@ -778,7 +778,7 @@ def to_json(self): json_seeds.append(seed.to_json()) else: json_seeds.append(EntitySeed(seed).to_json()) - operation_json['input'] = json_seeds + operation_json["input"] = json_seeds if isinstance(self.view, list): operation_json["views"] = operation_json.pop("view") @@ -815,7 +815,7 @@ def to_json(self): def load_operation_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj diff --git a/src/gafferpy/gaffer_predicates.py b/src/gafferpy/gaffer_predicates.py index d9e5140a..9fd7b4c8 100755 --- a/src/gafferpy/gaffer_predicates.py +++ b/src/gafferpy/gaffer_predicates.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,20 +34,20 @@ def __init__(self, selection=None, predicate=None): def to_json(self): predicate_json = {} if self.selection is not None: - predicate_json['selection'] = self.selection + predicate_json["selection"] = self.selection if self.predicate is not None: - predicate_json['predicate'] = self.predicate.to_json() + predicate_json["predicate"] = self.predicate.to_json() return predicate_json class TimeUnit: - DAY = 'DAY' - HOUR = 'HOUR' - MINUTE = 'MINUTE' - SECOND = 'SECOND' - MILLISECOND = 'MILLISECOND' - MICROSECOND = 'MICROSECOND' + DAY = "DAY" + HOUR = "HOUR" + MINUTE = "MINUTE" + SECOND = "SECOND" + MILLISECOND = "MILLISECOND" + MICROSECOND = "MICROSECOND" # Import generated predicate implementations from fishbowl @@ -63,25 +63,25 @@ def predicate_context_converter(obj): if obj is None: return None - if 'class' in obj: + if "class" in obj: predicate = dict(obj) else: - predicate = obj['predicate'] + predicate = obj["predicate"] if isinstance(predicate, dict): predicate = dict(predicate) if not isinstance(predicate, Predicate): predicate = JsonConverter.from_json(predicate) if not isinstance(predicate, Predicate): - class_name = predicate.get('class') - predicate.pop('class', None) + class_name = predicate.get("class") + predicate.pop("class", None) predicate = Predicate( class_name=class_name, fields=predicate ) return PredicateContext( - selection=obj.get('selection'), + selection=obj.get("selection"), predicate=predicate ) @@ -98,8 +98,8 @@ def predicate_converter(obj): if not isinstance(predicate, Predicate): predicate = JsonConverter.from_json(predicate) if not isinstance(predicate, Predicate): - class_name = predicate.get('class') - predicate.pop('class', None) + class_name = predicate.get("class") + predicate.pop("class", None) predicate = Predicate( class_name=class_name, fields=predicate @@ -111,7 +111,7 @@ def predicate_converter(obj): def load_predicate_json_map(): for name, class_obj in inspect.getmembers( sys.modules[__name__], inspect.isclass): - if hasattr(class_obj, 'CLASS'): + if hasattr(class_obj, "CLASS"): JsonConverter.GENERIC_JSON_CONVERTERS[class_obj.CLASS] = \ lambda obj, class_obj=class_obj: class_obj(**obj) JsonConverter.CLASS_MAP[class_obj.CLASS] = class_obj diff --git a/src/gafferpy/gaffer_types.py b/src/gafferpy/gaffer_types.py index 80567d5d..811bfaeb 100755 --- a/src/gafferpy/gaffer_types.py +++ b/src/gafferpy/gaffer_types.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -60,10 +60,10 @@ def parse_java_type_to_string(java_type: str, return_full_path: bool = True) -> else: type_name = str(python_type) - if return_full_path is False and 'gafferpy' in type_name: + 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]) + type_name = type_name.replace(gafferpy_class, gafferpy_class.split(".")[-1]) return type_name diff --git a/src/gafferpy_examples/Gaffer-Python-Demo.ipynb b/src/gafferpy_examples/Gaffer-Python-Demo.ipynb index 72dde2c8..6422d191 100644 --- a/src/gafferpy_examples/Gaffer-Python-Demo.ipynb +++ b/src/gafferpy_examples/Gaffer-Python-Demo.ipynb @@ -79,11 +79,11 @@ "source": [ "input = gc.execute_operation(\n", " g.GetElements(\n", - " input=['M32:1'],\n", + " input=[\"M32:1\"],\n", " view=g.View(\n", " edges=[\n", " g.ElementDefinition(\n", - " group='RoadUse',\n", + " group=\"RoadUse\",\n", " group_by=[]\n", " )\n", " ]\n", @@ -101,15 +101,15 @@ "source": [ "input = gc.execute_operation(\n", " g.GetElements(\n", - " input=['M32:1'],\n", + " input=[\"M32:1\"],\n", " view=g.View(\n", " edges=[\n", " g.ElementDefinition(\n", - " group='RoadUse',\n", + " group=\"RoadUse\",\n", " group_by=[],\n", " pre_aggregation_filter_functions=[\n", " g.PredicateContext(\n", - " selection=['count'],\n", + " selection=[\"count\"],\n", " predicate=g.IsMoreThan(\n", " value=g.long(1)\n", " )\n", @@ -121,7 +121,7 @@ " directed_type=g.DirectedType.EITHER\n", " )\n", ")\n", - "print('Related input')\n", + "print(\"Related input\")\n", "pprint(input)\n", "print()" ] @@ -134,32 +134,32 @@ "source": [ "input = gc.execute_operation(\n", " g.GetElements(\n", - " input=['M32:1'],\n", + " input=[\"M32:1\"],\n", " view=g.View(\n", " edges=[\n", " g.ElementDefinition(\n", - " group='RoadUse',\n", + " group=\"RoadUse\",\n", " group_by=[],\n", " transient_properties=[\n", - " g.Property('description', 'java.lang.String')\n", + " g.Property(\"description\", \"java.lang.String\")\n", " ],\n", " transform_functions=[\n", " g.FunctionContext(\n", - " selection=['SOURCE', 'DESTINATION', 'count'],\n", + " selection=[\"SOURCE\", \"DESTINATION\", \"count\"],\n", " function=g.Function(\n", - " class_name='uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform'\n", + " class_name=\"uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform\"\n", " ),\n", - " projection=['description']\n", + " projection=[\"description\"]\n", " )\n", " ],\n", - " properties=['description']\n", + " properties=[\"description\"]\n", " )\n", " ]\n", " ),\n", " directed_type=g.DirectedType.EITHER\n", " )\n", ")\n", - "print('Related input')\n", + "print(\"Related input\")\n", "pprint(input)\n", "print()" ] @@ -226,7 +226,7 @@ " ) \n", " ], \n", " group=\"JunctionUse\", \n", - " transient_properties={'CAR': 'Long'}, \n", + " transient_properties={\"CAR\": \"Long\"}, \n", " properties=[ \n", " \"CAR\" \n", " ], \n", @@ -273,7 +273,7 @@ " quoted=False, \n", " constants={}, \n", " comma_replacement=\" \", \n", - " fields={'VERTEX': 'Junction', 'CAR': 'CAR'} \n", + " fields={\"VERTEX\": \"Junction\", \"CAR\": \"CAR\"} \n", " ) \n", " ), \n", " condition=True \n", @@ -351,7 +351,7 @@ " ) \n", " ], \n", " group=\"JunctionUse\", \n", - " transient_properties={'${vehicle}': 'Long'}, \n", + " transient_properties={\"${vehicle}\": \"Long\"}, \n", " properties=[ \n", " \"${vehicle}\" \n", " ], \n", @@ -398,7 +398,7 @@ " quoted=False, \n", " constants={}, \n", " comma_replacement=\" \", \n", - " fields={'VERTEX': 'Junction', '${vehicle}': '${vehicle}'} \n", + " fields={\"VERTEX\": \"Junction\", \"${vehicle}\": \"${vehicle}\"} \n", " ) \n", " ), \n", " condition=\"${to-csv}\" \n", @@ -453,9 +453,9 @@ " operation_name=\"frequent-vehicles-in-region\",\n", " input=[g.EntitySeed(\"South West\")],\n", " parameters={\n", - " 'vehicle': 'CAR',\n", - " 'result-limit': 5,\n", - " 'to-csv': True\n", + " \"vehicle\": \"CAR\",\n", + " \"result-limit\": 5,\n", + " \"to-csv\": True\n", " }\n", " )\n", ")" diff --git a/src/gafferpy_examples/example.py b/src/gafferpy_examples/example.py index 9997df85..c684161d 100755 --- a/src/gafferpy_examples/example.py +++ b/src/gafferpy_examples/example.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 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,8 +24,8 @@ def run(host, verbose=False): def run_with_connector(gc): print() - print('Running operations') - print('--------------------------') + print("Running operations") + print("--------------------------") print() get_schema(gc) @@ -87,7 +87,7 @@ def get_schema(gc): g.GetSchema() ) - print('Schema:') + print("Schema:") print(result) print() @@ -98,19 +98,19 @@ def get_filter_functions(gc): g.GetFilterFunctions() ) - print('Filter Functions:') + print("Filter Functions:") print(result) print() def get_class_filter_functions(gc): # Get class filter functions - class_name = 'uk.gov.gchq.koryphe.impl.predicate.IsMoreThan' + class_name = "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan" result = gc.execute_get( g.GetClassFilterFunctions(class_name=class_name) ) - print('Class Filter Functions (IsMoreThan):') + print("Class Filter Functions (IsMoreThan):") print(result) print() @@ -121,7 +121,7 @@ def get_element_generators(gc): g.GetElementGenerators() ) - print('Element generators:') + print("Element generators:") print(result) print() @@ -132,7 +132,7 @@ def get_object_generators(gc): g.GetObjectGenerators() ) - print('Object generators:') + print("Object generators:") print(result) print() @@ -143,19 +143,19 @@ def get_operations(gc): g.GetOperations() ) - print('Operations:') + print("Operations:") print(result) print() def get_serialised_fields(gc): # Get serialised fields - class_name = 'uk.gov.gchq.koryphe.impl.predicate.IsMoreThan' + class_name = "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan" result = gc.execute_get( g.GetSerialisedFields(class_name=class_name) ) - print('Serialised Fields (IsMoreThan):') + print("Serialised Fields (IsMoreThan):") print(result) print() @@ -166,14 +166,14 @@ def get_store_traits(gc): g.GetStoreTraits() ) - print('Store Traits:') + print("Store Traits:") print(result) print() def is_operation_supported(gc): # Is operation supported - operation = 'uk.gov.gchq.gaffer.operation.impl.add.AddElements' + operation = "uk.gov.gchq.gaffer.operation.impl.add.AddElements" result = gc.is_operation_supported( g.IsOperationSupported(operation=operation) ) @@ -190,29 +190,29 @@ def add_elements(gc): g.AddElements( input=[ g.Entity( - group='JunctionUse', - vertex='M1:1', + group="JunctionUse", + vertex="M1:1", properties={ - 'countByVehicleType': g.freq_map({ - 'BUS': 10, - 'CAR': 50 + "countByVehicleType": g.freq_map({ + "BUS": 10, + "CAR": 50 }), - 'endDate': g.date(1034319600000), - 'count': g.long(60), - 'startDate': g.date(1034316000000) + "endDate": g.date(1034319600000), + "count": g.long(60), + "startDate": g.date(1034316000000) } ), g.Edge( - group='RoadHasJunction', - source='M1', - destination='M1:1', + group="RoadHasJunction", + source="M1", + destination="M1:1", directed=True, properties={} ) ] ) ) - print('Elements have been added') + print("Elements have been added") print() @@ -221,25 +221,25 @@ def get_elements(gc): input = gc.execute_operation( g.GetElements( input=[ - g.EntitySeed('M5:10'), + g.EntitySeed("M5:10"), # Edge input can be provided as follows - g.EdgeSeed('M5:10', 'M5:11', g.DirectedType.EITHER), - g.EdgeSeed('M5:10', 'M5:11', g.DirectedType.DIRECTED), + g.EdgeSeed("M5:10", "M5:11", g.DirectedType.EITHER), + g.EdgeSeed("M5:10", "M5:11", g.DirectedType.DIRECTED), # Or you can use True or False for the direction - g.EdgeSeed('M5:10', 'M5:11', True) + g.EdgeSeed("M5:10", "M5:11", True) ], view=g.View( edges=[ g.ElementDefinition( - group='RoadUse', + group="RoadUse", group_by=[], transient_properties=[ - g.Property('description', 'java.lang.String') + g.Property("description", "java.lang.String") ], pre_aggregation_filter_functions=[ g.PredicateContext( - selection=['count'], + selection=["count"], predicate=g.IsMoreThan( value=g.long(1) ) @@ -247,11 +247,11 @@ def get_elements(gc): ], transform_functions=[ g.FunctionContext( - selection=['SOURCE', 'DESTINATION', 'count'], + selection=["SOURCE", "DESTINATION", "count"], function=g.Function( - class_name='uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform' + class_name="uk.gov.gchq.gaffer.traffic.transform.DescriptionTransform" ), - projection=['description'] + projection=["description"] ) ] ) @@ -260,7 +260,7 @@ def get_elements(gc): directed_type=g.DirectedType.EITHER ) ) - print('Related input') + print("Related input") print(input) print() @@ -272,13 +272,13 @@ def get_adj_seeds(gc): g.GetAdjacentIds( input=[ g.EntitySeed( - vertex='M5' + vertex="M5" ) ], view=g.View( edges=[ g.ElementDefinition( - 'RoadHasJunction', + "RoadHasJunction", group_by=[] ) ] @@ -289,7 +289,7 @@ def get_adj_seeds(gc): view=g.View( edges=[ g.ElementDefinition( - 'RoadUse', + "RoadUse", group_by=[] ) ] @@ -298,7 +298,7 @@ def get_adj_seeds(gc): ) ] ) - print('Adjacent entities - 2 hop') + print("Adjacent entities - 2 hop") print(adj_seeds) print() @@ -311,7 +311,7 @@ def get_all_elements(gc): g.Limit(result_limit=3) ] ) - print('All input (Limited to first 3)') + print("All input (Limited to first 3)") print(all_elements) print() @@ -321,14 +321,14 @@ def get_walks(gc): walks = gc.execute_operation( g.GetWalks( input=[ - g.EntitySeed('M32'), + g.EntitySeed("M32"), ], operations=[ g.GetElements( view=g.View( edges=[ g.ElementDefinition( - group='RoadHasJunction' + group="RoadHasJunction" ) ] ) @@ -337,7 +337,7 @@ def get_walks(gc): view=g.View( edges=[ g.ElementDefinition( - group='JunctionLocatedAt' + group="JunctionLocatedAt" ) ] ) @@ -346,7 +346,7 @@ def get_walks(gc): ) ) print( - 'Walks from M32 traversing down RoadHasJunction then JunctionLocatedAt') + "Walks from M32 traversing down RoadHasJunction then JunctionLocatedAt") print(walks) print() @@ -358,18 +358,18 @@ def add_cardinality_entity(gc): g.AddElements( input=[ g.Entity( - group='Cardinality', - vertex='M1:1', + group="Cardinality", + vertex="M1:1", properties={ - 'hll': g.hll_sketch(['M1']), - 'count': g.long(60), - 'edgeGroup': g.tree_set(['RoadHasJunction']) + "hll": g.hll_sketch(["M1"]), + "count": g.long(60), + "edgeGroup": g.tree_set(["RoadHasJunction"]) } ) ] ) ) - print('Cardinality entity has been added') + print("Cardinality entity has been added") print() @@ -378,14 +378,14 @@ def generate_elements(gc): input = gc.execute_operation( g.GenerateElements( element_generator=g.ElementGenerator( - class_name='uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator' + class_name="uk.gov.gchq.gaffer.traffic.generator.RoadTrafficStringElementGenerator" ), input=[ '"South West","E06000054","Wiltshire","6016","389200","179080","M4","LA Boundary","381800","180030","17","391646","179560","TM","E","2000","2000-05-03 00:00:00","7","0","9","2243","15","426","127","21","20","37","106","56","367","3060"' ] ) ) - print('Generated input from provided domain input') + print("Generated input from provided domain input") print(input) print() @@ -395,15 +395,15 @@ def generate_domain_objs(gc): input = gc.execute_operation( g.GenerateObjects( element_generator=g.ElementGenerator( - class_name='uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator' + class_name="uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator" ), input=[ - g.Entity('entity', '1'), - g.Edge('edge', '1', '2', True) + g.Entity("entity", "1"), + g.Edge("edge", "1", "2", True) ] ) ) - print('Generated input from provided input') + print("Generated input from provided input") print(input) print() @@ -413,11 +413,11 @@ def generate_domain_objects_chain(gc): input = gc.execute_operations( [ g.GetElements( - input=[g.EntitySeed(vertex='M5')], + input=[g.EntitySeed(vertex="M5")], view=g.View( edges=[ g.ElementDefinition( - group='RoadHasJunction', + group="RoadHasJunction", group_by=[] ) ] @@ -426,12 +426,12 @@ def generate_domain_objects_chain(gc): g.GenerateObjects( element_generator=g.ElementGenerator( - class_name='uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator' + class_name="uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator" ) ) ] ) - print('Generated input from get input by seed') + print("Generated input from get input by seed") print(input) print() @@ -440,11 +440,11 @@ def get_element_group_counts(gc): # Get Elements group_counts = gc.execute_operations([ g.GetElements( - input=[g.EntitySeed('M5')] + input=[g.EntitySeed("M5")] ), g.CountGroups(limit=1000) ]) - print('Groups counts (limited to 1000 input)') + print("Groups counts (limited to 1000 input)") print(group_counts) print() @@ -454,7 +454,7 @@ def get_sub_graph(gc): entity_seeds = gc.execute_operations( [ g.GetAdjacentIds( - input=[g.EntitySeed('South West')], + input=[g.EntitySeed("South West")], include_incoming_out_going=g.InOutType.OUT ), g.ExportToSet(), @@ -464,7 +464,7 @@ def get_sub_graph(gc): g.GetSetExport() ] ) - print('Export and Get to/from an in memory set') + print("Export and Get to/from an in memory set") print(entity_seeds) print() @@ -474,7 +474,7 @@ def export_to_gaffer_result_cache(gc): job_details = gc.execute_operations( [ g.GetAdjacentIds( - input=[g.EntitySeed('South West')], + input=[g.EntitySeed("South West")], include_incoming_out_going=g.InOutType.OUT ), g.ExportToGafferResultCache(), @@ -482,15 +482,15 @@ def export_to_gaffer_result_cache(gc): g.GetJobDetails() ] ) - print('Export to Gaffer Result Cache. Job Details:') + print("Export to Gaffer Result Cache. Job Details:") print(job_details) print() - job_id = job_details['jobId'] + job_id = job_details["jobId"] entity_seeds = gc.execute_operation( g.GetGafferResultCacheExport(job_id=job_id), ) - print('Get Gaffer Result Cache Export.') + print("Get Gaffer Result Cache Export.") print(entity_seeds) print() @@ -500,7 +500,7 @@ def get_job_details(gc): job_details_initial = gc.execute_operations( [ g.GetAdjacentIds( - input=[g.EntitySeed('1')], + input=[g.EntitySeed("1")], ), g.ExportToGafferResultCache(), g.DiscardOutput(), @@ -508,12 +508,12 @@ def get_job_details(gc): ] ) - job_id = job_details_initial['jobId'] + job_id = job_details_initial["jobId"] job_details = gc.execute_operation( g.GetJobDetails(job_id=job_id), ) - print('Get job details') + print("Get job details") print(job_details) print() @@ -523,16 +523,16 @@ def get_all_job_details(gc): all_job_details = gc.execute_operation( g.GetAllJobDetails(), ) - print('Get all job details (just prints the first 3 results)') + print("Get all job details (just prints the first 3 results)") print(all_job_details[:3]) print() def delete_named_operation(gc): gc.execute_operation( - g.DeleteNamedOperation('2-hop-with-limit') + g.DeleteNamedOperation("2-hop-with-limit") ) - print('Deleted named operation: 2-hop-with-limit') + print("Deleted named operation: 2-hop-with-limit") print() @@ -551,8 +551,8 @@ def add_named_operation(gc): "resultLimit": "${param1}" }] }, - operation_name='2-hop-with-limit', - description='2 hop query with limit', + operation_name="2-hop-with-limit", + description="2 hop query with limit", overwrite_flag=True, read_access_roles=["read-user"], write_access_roles=["write-user"], @@ -568,7 +568,7 @@ def add_named_operation(gc): ) ) - print('Added named operation: 2-hop-with-limit') + print("Added named operation: 2-hop-with-limit") print() @@ -576,7 +576,7 @@ def get_all_named_operations(gc): namedOperations = gc.execute_operation( g.GetAllNamedOperations() ) - print('Named operations') + print("Named operations") print(namedOperations) print() @@ -584,29 +584,29 @@ def get_all_named_operations(gc): def named_operation(gc): result = gc.execute_operation( g.NamedOperation( - operation_name='2-hop-with-limit', + operation_name="2-hop-with-limit", parameters={ - 'param1': 2 + "param1": 2 }, input=[ - g.EntitySeed('M5') + g.EntitySeed("M5") ] ) ) - print('Execute named operation') + print("Execute named operation") print(result) print() def delete_named_views(gc): gc.execute_operation( - g.DeleteNamedView(name='summarise') + g.DeleteNamedView(name="summarise") ) - print('Deleted named view: summarise') + print("Deleted named view: summarise") gc.execute_operation( - g.DeleteNamedView(name='dateRange') + g.DeleteNamedView(name="dateRange") ) - print('Deleted named view: dateRange') + print("Deleted named view: dateRange") print() @@ -618,13 +618,13 @@ def add_named_view_summarise(gc): g.GlobalElementDefinition(group_by=[]) ] ), - name='summarise', - description='Summarises all results (overrides the groupBy to an empty array).', + name="summarise", + description="Summarises all results (overrides the groupBy to an empty array).", overwrite_flag=True ) ) - print('Added named view: summarise') + print("Added named view: summarise") print() @@ -635,17 +635,17 @@ def add_named_view_date_range(gc): global_elements=g.GlobalElementDefinition( pre_aggregation_filter_functions=[ g.PredicateContext( - selection=['startDate'], + selection=["startDate"], predicate=g.InDateRange( - start='${start}', - end='${end}' + start="${start}", + end="${end}" ) ) ] ) ), - name='dateRange', - description='Filters results to a provided date range.', + name="dateRange", + description="Filters results to a provided date range.", overwrite_flag=True, parameters=[ g.NamedViewParameter( @@ -664,7 +664,7 @@ def add_named_view_date_range(gc): ) ) - print('Added named view: dateRange') + print("Added named view: dateRange") print() @@ -672,7 +672,7 @@ def get_all_named_views(gc): namedViews = gc.execute_operation( g.GetAllNamedViews() ) - print('Named views') + print("Named views") print(namedViews) print() @@ -682,7 +682,7 @@ def named_view_summarise(gc): g.GetElements( input=[ g.EntitySeed( - vertex='M32:1' + vertex="M32:1" ) ], view=g.NamedView( @@ -690,7 +690,7 @@ def named_view_summarise(gc): ) ) ) - print('Execute get elements with summarised named view') + print("Execute get elements with summarised named view") print(result) print() @@ -700,19 +700,19 @@ def named_view_date_range(gc): g.GetElements( input=[ g.EntitySeed( - vertex='M32:1' + vertex="M32:1" ) ], view=g.NamedView( name="dateRange", parameters={ - 'start': '2005/05/03 06:00', - 'end': '2005/05/03 09:00' + "start": "2005/05/03 06:00", + "end": "2005/05/03 09:00" } ) ) ) - print('Execute get elements with date range named view') + print("Execute get elements with date range named view") print(result) print() @@ -722,7 +722,7 @@ def named_views(gc): g.GetElements( input=[ g.EntitySeed( - vertex='M32:1' + vertex="M32:1" ) ], view=[ @@ -732,14 +732,14 @@ def named_views(gc): g.NamedView( name="dateRange", parameters={ - 'start': '2005/05/03 06:00', - 'end': '2005/05/03 09:00' + "start": "2005/05/03 06:00", + "end": "2005/05/03 09:00" } ) ] ) ) - print('Execute get elements with summarised and date range named views') + print("Execute get elements with summarised and date range named views") print(result) print() @@ -751,7 +751,7 @@ def sort_elements(gc): view=g.View( edges=[ g.ElementDefinition( - group='RoadUse', + group="RoadUse", group_by=[] ) ] @@ -760,14 +760,14 @@ def sort_elements(gc): g.Sort( comparators=[ g.ElementPropertyComparator( - groups=['RoadUse'], - property='count' + groups=["RoadUse"], + property="count" ) ], result_limit=5 ) ]) - print('Sorted input') + print("Sorted input") print(input) print() @@ -779,7 +779,7 @@ def max_element(gc): view=g.View( edges=[ g.ElementDefinition( - group='RoadUse', + group="RoadUse", group_by=[] ) ] @@ -788,13 +788,13 @@ def max_element(gc): g.Max( comparators=[ g.ElementPropertyComparator( - groups=['RoadUse'], - property='count' + groups=["RoadUse"], + property="count" ) ] ) ]) - print('Max element') + print("Max element") print(input) print() @@ -806,7 +806,7 @@ def min_element(gc): view=g.View( edges=[ g.ElementDefinition( - group='RoadUse', + group="RoadUse", group_by=[] ) ] @@ -815,13 +815,13 @@ def min_element(gc): g.Min( comparators=[ g.ElementPropertyComparator( - groups=['RoadUse'], - property='count' + groups=["RoadUse"], + property="count" ) ] ) ]) - print('Min element') + print("Min element") print(input) print() @@ -832,13 +832,13 @@ def to_vertices_to_entity_seeds(gc): g.GetElements( input=[ g.EntitySeed( - vertex='South West' + vertex="South West" ) ], view=g.View( edges=[ g.ElementDefinition( - 'RegionContainsLocation', + "RegionContainsLocation", group_by=[] ) ] @@ -854,7 +854,7 @@ def to_vertices_to_entity_seeds(gc): view=g.View( edges=[ g.ElementDefinition( - 'LocationContainsRoad', + "LocationContainsRoad", group_by=[] ) ] @@ -863,7 +863,7 @@ def to_vertices_to_entity_seeds(gc): ), g.Limit(5) ]) - print('ToVertices then ToEntitySeeds') + print("ToVertices then ToEntitySeeds") print(input) print() @@ -873,11 +873,11 @@ def complex_op_chain(gc): junctions = gc.execute_operations( operations=[ g.GetAdjacentIds( - input=[g.EntitySeed(vertex='South West')], + input=[g.EntitySeed(vertex="South West")], view=g.View( edges=[ g.ElementDefinition( - group='RegionContainsLocation', + group="RegionContainsLocation", group_by=[] ) ] @@ -887,7 +887,7 @@ def complex_op_chain(gc): view=g.View( edges=[ g.ElementDefinition( - group='LocationContainsRoad', + group="LocationContainsRoad", group_by=[] ) ] @@ -898,7 +898,7 @@ def complex_op_chain(gc): view=g.View( edges=[ g.ElementDefinition( - group='RoadHasJunction', + group="RoadHasJunction", group_by=[] ) ] @@ -908,37 +908,37 @@ def complex_op_chain(gc): view=g.View( entities=[ g.ElementDefinition( - group='JunctionUse', + group="JunctionUse", group_by=[], transient_properties=[ - g.Property('busCount', 'java.lang.Long') + g.Property("busCount", "java.lang.Long") ], pre_aggregation_filter_functions=[ g.PredicateContext( - selection=['startDate'], + selection=["startDate"], predicate=g.InDateRange( - start='2000/01/01', - end='2001/01/01' + start="2000/01/01", + end="2001/01/01" ) ) ], post_aggregation_filter_functions=[ g.PredicateContext( - selection=['countByVehicleType'], + selection=["countByVehicleType"], predicate=g.PredicateMap( predicate=g.IsMoreThan( - value={'java.lang.Long': 1000}, + value={"java.lang.Long": 1000}, or_equal_to=False ), - key='BUS' + key="BUS" ) ) ], transform_functions=[ g.FunctionContext( - selection=['countByVehicleType'], - function=g.FreqMapExtractor(key='BUS'), - projection=['busCount'] + selection=["countByVehicleType"], + function=g.FreqMapExtractor(key="BUS"), + projection=["busCount"] ) ] ) @@ -949,8 +949,8 @@ def complex_op_chain(gc): g.ToCsv( csv_generator=g.CsvGenerator( fields={ - 'VERTEX': 'Junction', - 'busCount': 'Bus Count' + "VERTEX": "Junction", + "busCount": "Bus Count" }, quoted=False ), @@ -959,7 +959,7 @@ def complex_op_chain(gc): ] ) print( - 'All road junctions in the South West that were heavily used by buses in year 2000.') + "All road junctions in the South West that were heavily used by buses in year 2000.") print(junctions) print() @@ -976,10 +976,10 @@ def op_chain_in_json(gc): }] } ) - print('Operation chain defined in json') + print("Operation chain defined in json") print(result) print() if __name__ == "__main__": - run('http://localhost:8080/rest/latest', False) + run("http://localhost:8080/rest/latest", False) diff --git a/src/gafferpy_examples/example_map.py b/src/gafferpy_examples/example_map.py index 11a4b8c4..eab3db64 100644 --- a/src/gafferpy_examples/example_map.py +++ b/src/gafferpy_examples/example_map.py @@ -1,5 +1,5 @@ # -# Copyright 2021-2022 Crown Copyright +# Copyright 2021-2024 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,8 +24,8 @@ def run(host, verbose=False): def run_with_connector(gc): print() - print('Running Map operations') - print('--------------------------') + print("Running Map operations") + print("--------------------------") print() count_all_elements_default_view(gc) @@ -40,10 +40,10 @@ def count_all_elements_default_view(gc): elements = gc.execute_operation( g.CountAllElementsDefaultView() ) - print('Count of all Elements in default View') + print("Count of all Elements in default View") print(elements) print() if __name__ == "__main__": - run('http://localhost:8080/rest/latest', False) + run("http://localhost:8080/rest/latest", False) diff --git a/src/gafferpy_examples/example_map_pki.py b/src/gafferpy_examples/example_map_pki.py index 1d5f425e..cb1ff7db 100644 --- a/src/gafferpy_examples/example_map_pki.py +++ b/src/gafferpy_examples/example_map_pki.py @@ -1,5 +1,5 @@ # -# Copyright 2021-2022 Crown Copyright +# Copyright 2021-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ from gafferpy import gaffer_connector_pki -def run(host, verbose=False, pki_cert='cert.pem'): +def run(host, verbose=False, pki_cert="cert.pem"): # Store your PKI certificate in file cert.pem pki = gaffer_connector_pki.PkiCredentials(pki_cert) @@ -30,4 +30,4 @@ def create_connector(host, pki, verbose=False): if __name__ == "__main__": - run('localhost:8080/rest/latest') + run("localhost:8080/rest/latest") diff --git a/src/gafferpy_examples/example_pki.py b/src/gafferpy_examples/example_pki.py index 71457820..1381bda9 100755 --- a/src/gafferpy_examples/example_pki.py +++ b/src/gafferpy_examples/example_pki.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2022 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ from gafferpy import gaffer_connector_pki -def run(host, verbose=False, pki_cert='cert.pem'): +def run(host, verbose=False, pki_cert="cert.pem"): # Store your PKI certificate in file cert.pem pki = gaffer_connector_pki.PkiCredentials(pki_cert) @@ -30,4 +30,4 @@ def create_connector(host, pki, verbose=False): if __name__ == "__main__": - run('localhost:8080/rest/latest') + run("localhost:8080/rest/latest") diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index bce27b60..e8c6cddc 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,5 +1,5 @@ # -# Copyright 2023 Crown Copyright +# Copyright 2023-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ def _connection_test(): gc = gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest' + "http://localhost:8080/rest/latest" ) try: gc.execute_get(operation=g.GetStatus()) @@ -42,7 +42,7 @@ def skip_connection(): def _return_gaffer_connector(): return gaffer_connector.GafferConnector( - 'http://localhost:8080/rest/latest' + "http://localhost:8080/rest/latest" ) @@ -61,16 +61,16 @@ def _get_predicates(gc=_return_gaffer_connector()): 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' + "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] @@ -85,24 +85,24 @@ def _get_functions(gc=_return_gaffer_connector()): 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' + "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] diff --git a/tests/integration/test_connector.py b/tests/integration/test_connector.py index 7df871be..527c7cfb 100755 --- a/tests/integration/test_connector.py +++ b/tests/integration/test_connector.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -49,12 +49,12 @@ def test_execute_operation(client_class, gc): elements = gc.execute_operation( g.GetElements( input=[ - g.EntitySeed('M5:10') + g.EntitySeed("M5:10") ], view=g.View( edges=[ g.ElementDefinition( - group='JunctionLocatedAt' + group="JunctionLocatedAt" ) ] ) @@ -71,7 +71,7 @@ def test_execute_operation(client_class, gc): def test_is_operation_supported(client_class, gc): response = gc.is_operation_supported( g.IsOperationSupported( - operation='uk.gov.gchq.gaffer.operation.impl.get.GetAllElements' + operation="uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" ), json_result=True ) @@ -115,7 +115,7 @@ 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', + "http://localhost:8080/rest/latest", headers={ "dummy_Header": "value"}, client_class=client_class @@ -124,12 +124,12 @@ def test_dummy_header(client_class, gc): elements = gc.execute_operation( g.GetElements( input=[ - g.EntitySeed('M5:10') + g.EntitySeed("M5:10") ], view=g.View( edges=[ g.ElementDefinition( - group='JunctionLocatedAt' + group="JunctionLocatedAt" ) ] ) @@ -144,7 +144,7 @@ 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' + host = "http://localhost:8080/rest/latest" verbose = False headers = {"dummy_Header": "value"} gc = gaffer_connector.GafferConnector( diff --git a/tests/integration/test_example.py b/tests/integration/test_example.py index b763d83e..dcf70403 100755 --- a/tests/integration/test_example.py +++ b/tests/integration/test_example.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -22,4 +22,4 @@ def test_example_does_not_error(): - example.run('http://localhost:8080/rest/latest') + example.run("http://localhost:8080/rest/latest") diff --git a/tests/integration/test_example_map.py b/tests/integration/test_example_map.py index 09f1723d..2a3ffcda 100644 --- a/tests/integration/test_example_map.py +++ b/tests/integration/test_example_map.py @@ -1,5 +1,5 @@ # -# Copyright 2023 Crown Copyright +# Copyright 2023-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -22,4 +22,4 @@ def test_example_map_does_not_error(): - example_map.run('http://localhost:8080/rest/latest') + example_map.run("http://localhost:8080/rest/latest") diff --git a/tests/unit/test_gaffer_functions.py b/tests/unit/test_gaffer_functions.py index 577670f1..f64819cf 100755 --- a/tests/unit/test_gaffer_functions.py +++ b/tests/unit/test_gaffer_functions.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -23,45 +23,45 @@ "json_string,gafferpy_method", [ [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Concat", "separator" : "\u0020" } - ''', + """, g.Concat( separator=" " ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Divide" } - ''', + """, g.Divide() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.DivideBy", "by" : 3 } - ''', + """, g.DivideBy( by=3 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ExtractKeys" } - ''', + """, g.ExtractKeys() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.DictionaryLookup", "dictionary": { @@ -70,293 +70,293 @@ "Three": 3 } } - ''', + """, g.DictionaryLookup(dictionary=dict(One=1, Two=2, Three=3)) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ExtractValue", "key" : "blueKey" } - ''', + """, g.ExtractValue( key="blueKey" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ExtractValues" } - ''', + """, g.ExtractValues() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Identity" } - ''', + """, g.Identity() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.IsEmpty" } - ''', + """, g.IsEmpty() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Longest" } - ''', + """, g.Longest() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.IterableLongest" } - ''', + """, g.IterableLongest() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.IterableFlatten", "operator": { "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Max" } } - ''', + """, g.IterableFlatten(operator=g.bop.Max()) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.IterableConcat" } - ''', + """, g.IterableConcat() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Multiply" } - ''', + """, g.Multiply() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.MultiplyBy", "by" : 4 } - ''', + """, g.MultiplyBy( by=4 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.MultiplyLongBy", "by" : 4 } - ''', + """, g.MultiplyLongBy( by=4 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Size" } - ''', + """, g.Size() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ToString" } - ''', + """, g.ToString() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ToString", "charset": "UTF-16" } - ''', + """, g.ToString(charset="UTF-16") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringReplace", "searchString": "replaceme", "replacement": "withthis" } - ''', + """, g.StringReplace(search_string="replaceme", replacement="withthis") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringRegexReplace", "regex": "repl.*me", "replacement": "withthis" } - ''', + """, g.StringRegexReplace(regex="repl.*me", replacement="withthis") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringSplit", "delimiter": " " } - ''', + """, g.StringSplit(delimiter=" ") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringRegexSplit", "regex": "[ \\t]*" } - ''', + """, g.StringRegexSplit(regex="[ \t]*") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringJoin", "delimiter": " " } - ''', + """, g.StringJoin(delimiter=" ") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringTrim" } - ''', + """, g.StringTrim() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringAppend", "suffix": "test" } - ''', + """, g.StringAppend(suffix="test") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringPrepend", "prefix": "test" } - ''', + """, g.StringPrepend(prefix="test") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.StringTruncate", "length": 20, "ellipses": false } - ''', + """, g.StringTruncate(length=20, ellipses=False) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.ReverseString" } - ''', + """, g.ReverseString() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.DefaultIfNull", "defaultValue": "test" } - ''', + """, g.DefaultIfNull(default_value="test") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.DefaultIfEmpty", "defaultValue": "test" } - ''', + """, g.DefaultIfEmpty(default_value="test") ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.function.ToEntityId" } - ''', + """, g.ToEntityId() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.function.FromEntityId" } - ''', + """, g.FromEntityId() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.function.ToElementId" } - ''', + """, g.ToElementId() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.function.FromElementId" } - ''', + """, g.FromElementId() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.types.function.ToTypeValue" } - ''', + """, g.ToTypeValue() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.types.function.ToTypeSubTypeValue" } - ''', + """, g.ToTypeSubTypeValue() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.generator.MapGenerator", "fields" : { @@ -369,21 +369,21 @@ "A Constant" : "Some constant value" } } - ''', + """, g.MapGenerator( fields={ - 'VERTEX': 'Vertex Label', - 'count': 'Count Label', - 'GROUP': 'Group Label', - 'SOURCE': 'Source Label' + "VERTEX": "Vertex Label", + "count": "Count Label", + "GROUP": "Group Label", + "SOURCE": "Source Label" }, constants={ - 'A Constant': 'Some constant value' + "A Constant": "Some constant value" } ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.generator.CsvGenerator", "fields" : { @@ -398,40 +398,40 @@ "quoted" : true, "commaReplacement": "-" } - ''', + """, g.CsvGenerator( fields={ - 'VERTEX': 'Vertex Label', - 'count': 'Count Label', - 'GROUP': 'Group Label', - 'SOURCE': 'Source Label' + "VERTEX": "Vertex Label", + "count": "Count Label", + "GROUP": "Group Label", + "SOURCE": "Source Label" }, constants={ - 'A Constant': 'Some constant value' + "A Constant": "Some constant value" }, quoted=True, comma_replacement="-" ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.generator.JsonToElementGenerator" } - ''', + """, g.JsonToElementGenerator() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.types.function.FreqMapExtractor", "key" : "key1" } - ''', + """, g.FreqMapExtractor(key="key1") ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.function.FunctionMap", "function" : { @@ -439,133 +439,133 @@ "by" : 10 } } - ''', + """, g.FunctionMap( function=g.MultiplyBy(by=10) ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdges" } - ''', + """, g.ExtractWalkEdges() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEdgesFromHop", "hop" : 2 } - ''', + """, g.ExtractWalkEdgesFromHop( hop=2 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEntities" } - ''', + """, g.ExtractWalkEntities() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkEntitiesFromHop", "hop" : 1 } - ''', + """, g.ExtractWalkEntitiesFromHop( hop=1 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.graph.function.walk.ExtractWalkVertex" } - ''', + """, g.ExtractWalkVertex() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.Length", "maxLength" : 100000 } - ''', + """, g.Length( max_length=100000 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.ExtractId", "id" : "VERTEX" } - ''', + """, g.ExtractId( - id='VERTEX' + id="VERTEX" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.ExtractProperty", "name" : "countByVehicleType" } - ''', + """, g.ExtractProperty( name="countByVehicleType" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.ExtractGroup" } - ''', + """, g.ExtractGroup() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.CallMethod", "method": "someMethod" } - ''', + """, g.CallMethod(method="someMethod") ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.UnwrapEntityId" } - ''', + """, g.UnwrapEntityId() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.SetValue", "value": "value2" } - ''', + """, g.SetValue(value="value2") ], [ - ''' + """ { "class":"uk.gov.gchq.koryphe.impl.function.If", "predicate":{"class":"uk.gov.gchq.koryphe.impl.predicate.IsA","type":"java.lang.Integer"}, "then":{"class":"uk.gov.gchq.koryphe.impl.function.SetValue","value":"value2"}, "otherwise":{"class":"uk.gov.gchq.koryphe.impl.function.SetValue","value":"value3"} } - ''', + """, g.func.If( predicate=g.IsA(type="java.lang.Integer"), then=g.SetValue(value="value2"), @@ -573,39 +573,39 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToArray" } - ''', + """, g.func.ToArray() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToList" } - ''', + """, g.func.ToList() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToSet" } - ''', + """, g.func.ToSet() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.types.function.ToFreqMap" } - ''', + """, g.func.ToFreqMap() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.types.function.FreqMapPredicator", "predicate": { @@ -613,7 +613,7 @@ "type": "java.lang.String" } } - ''', + """, g.FreqMapPredicator( predicate=g.IsA( type="java.lang.String" @@ -621,7 +621,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.IterableFilter", "predicate": { @@ -629,21 +629,21 @@ "type": "java.lang.String" } } - ''', + """, g.func.IterableFilter( predicate=g.IsA(type="java.lang.String") ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.MapFilter" } - ''', + """, g.func.MapFilter() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.MapFilter", "keyPredicate": { @@ -652,7 +652,7 @@ "ignoreCase":false } } - ''', + """, g.func.MapFilter( key_predicate=g.pred.StringContains( value="someValue", @@ -661,7 +661,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.FirstValid", "predicate": { @@ -670,7 +670,7 @@ "ignoreCase":false } } - ''', + """, g.func.FirstValid( predicate=g.pred.StringContains( value="someValue", @@ -679,7 +679,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.FirstValid", "predicate": { @@ -688,7 +688,7 @@ "ignoreCase":false } } - ''', + """, g.func.FirstValid( predicate={ "class": "uk.gov.gchq.koryphe.impl.predicate.StringContains", @@ -698,7 +698,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.MapFilter", "keyPredicate": { @@ -712,7 +712,7 @@ "value" : 0 } } - ''', + """, g.func.MapFilter( key_predicate=g.pred.StringContains( value="someValue", @@ -725,31 +725,31 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.MapFilter", "keyValuePredicate": { "class": "uk.gov.gchq.koryphe.impl.predicate.AreEqual" } } - ''', + """, g.func.MapFilter( key_value_predicate=g.pred.AreEqual() ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.function.CreateObject", "objectClass" : "java.lang.Long" } - ''', + """, g.func.CreateObject( object_class="java.lang.Long" ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange", "startTime": { @@ -759,14 +759,14 @@ "java.lang.Long": 15400000000000 } } - ''', + """, g.func.MaskTimestampSetByTimeRange( start_time=g.long(15300000000000), end_time=g.long(15400000000000) ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange", "startTime": { @@ -777,7 +777,7 @@ }, "timeUnit": "SECOND" } - ''', + """, g.func.MaskTimestampSetByTimeRange( start_time=g.long(15300000000000), end_time=g.long(15400000000000), @@ -785,15 +785,15 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.Base64Decode" } - ''', + """, g.func.Base64Decode() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.CsvLinesToMaps", "delimiter": "|", @@ -802,12 +802,12 @@ "quoted": true, "quoteChar": "'" } - ''', - g.func.CsvLinesToMaps(delimiter='|', header=["my", "csv", "file"], first_row=1, quoted=True, - quote_char='\'') + """, + g.func.CsvLinesToMaps(delimiter="|", header=["my", "csv", "file"], first_row=1, quoted=True, + quote_char="\'") ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.CsvToMaps", "delimiter": "|", @@ -816,166 +816,166 @@ "quoted": true, "quoteChar": "'" } - ''', - g.func.CsvToMaps(delimiter='|', header=["my", "csv", "file"], first_row=1, quoted=True, quote_char='\'') + """, + g.func.CsvToMaps(delimiter="|", header=["my", "csv", "file"], first_row=1, quoted=True, quote_char="\'") ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.CurrentDate" } - ''', + """, g.func.CurrentDate() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.CurrentTime" } - ''', + """, g.func.CurrentTime() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.DeserialiseJson", "outputClass": "uk.gov.gchq.gaffer.data.element.Edge" } - ''', + """, g.func.DeserialiseJson(output_class=g.Edge.CLASS) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.DeserialiseJson" } - ''', + """, g.func.DeserialiseJson() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.DeserialiseXml" } - ''', + """, g.func.DeserialiseXml() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.Gunzip" } - ''', + """, g.func.Gunzip() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.Increment", "increment": { "java.lang.Long": 1000000 } } - ''', + """, g.Increment(increment=g.long(1000000)) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.MapToTuple" } - ''', + """, g.func.MapToTuple() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ParseDate", "timeZone": "BST", "format": "DD-MM-YYYY" } - ''', + """, g.func.ParseDate(time_zone="BST", format="DD-MM-YYYY") ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ParseTime", "timeZone": "EST", "format": "MM-DD-YYYY HH:mm:ss.SSS", "timeUnit": "MICROSECOND" } - ''', + """, g.func.ParseTime(time_zone="EST", format="MM-DD-YYYY HH:mm:ss.SSS", time_unit=g.TimeUnit.MICROSECOND) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToDateString", "format": "YYYY-MMM-dd" } - ''', + """, g.func.ToDateString(format="YYYY-MMM-dd") ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToBytes", "charset": "UTF-8" } - ''', + """, g.func.ToBytes(charset="UTF-8") ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ApplyBiFunction", "function": { "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" } } - ''', + """, g.func.ApplyBiFunction(function=g.gaffer_binaryoperators.Sum()) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ApplyBiFunction", "function": { "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Product" } } - ''', + """, g.func.ApplyBiFunction(function={ "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Product" }) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.ToTuple" } - ''', + """, g.func.ToTuple() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.element.function.ToPropertiesTuple" } - ''', + """, g.func.ToPropertiesTuple() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.element.function.ToElementTuple" } - ''', + """, g.func.ToElementTuple() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.ReduceRelatedElements", "vertexAggregator" : { @@ -987,7 +987,7 @@ "visibilityProperty" : "visibility", "relatedVertexGroups" : [ "relatesTo" ] } - ''', + """, g.func.ReduceRelatedElements( vertex_aggregator=g.gaffer_binaryoperators.Max(), visibility_aggregator=g.gaffer_binaryoperators.CollectionConcat(), @@ -996,32 +996,32 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.function.ToTrailingWildcardPair", "endOfRange" : "~" } - ''', + """, g.func.ToTrailingWildcardPair(end_of_range="~") ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.TypeValueToTuple" } - ''', + """, g.func.TypeValueToTuple() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.data.element.function.TypeSubTypeValueToTuple" } - ''', + """, g.func.TypeSubTypeValueToTuple() ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.FunctionChain", "functions": [ @@ -1035,14 +1035,14 @@ } ] } - ''', + """, g.FunctionChain(functions=[ g.Base64Decode(), g.CsvLinesToMaps(delimiter="|", quoted=True) ]) ], [ - ''' + """ { "class":"uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunction", "selection":[0], @@ -1051,11 +1051,11 @@ }, "projection": [1] } - ''', + """, g.TupleAdaptedFunction(selection=[0], function=g.ToEntityId(), projection=[1]) ], [ - ''' + """ { "class":"uk.gov.gchq.koryphe.impl.function.FunctionChain", "functions": [ @@ -1077,14 +1077,14 @@ } ] } - ''', + """, g.FunctionChain(functions=[ g.TupleAdaptedFunction(selection=[0], function=g.ToUpperCase(), projection=[1]), g.TupleAdaptedFunction(selection=[1], function=g.gaffer_functions.ToSet(), projection=[2]) ]) ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite", "functions": [ @@ -1097,7 +1097,7 @@ } ] } - ''', + """, g.TupleAdaptedFunctionComposite( functions=[g.FunctionContext(selection=["something"], function=g.ToUpperCase(), @@ -1108,7 +1108,7 @@ ], [ - ''' + """ { "class": "uk.gov.gchq.koryphe.impl.function.FunctionChain", "functions": [ @@ -1138,7 +1138,7 @@ } ] } - ''', + """, g.FunctionChain(functions=[ g.TupleAdaptedFunctionComposite( functions=[g.FunctionContext(selection=[0], function=g.ToUpperCase(), projection=[1])]), diff --git a/tests/unit/test_gaffer_operations.py b/tests/unit/test_gaffer_operations.py index abb0dcdd..d1df84a9 100755 --- a/tests/unit/test_gaffer_operations.py +++ b/tests/unit/test_gaffer_operations.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 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,7 +24,7 @@ "json_string,gafferpy_method", [ [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElements", "validate" : true, @@ -47,20 +47,20 @@ "class" : "uk.gov.gchq.gaffer.data.element.Edge" } ] } - ''', + """, g.AddElements( skip_invalid_elements=False, input=[ g.Entity( vertex=6, - properties={'count': 1}, + properties={"count": 1}, group="entity" ), g.Edge( destination=6, source=5, group="edge", - properties={'count': 1}, + properties={"count": 1}, directed=True ) ], @@ -68,7 +68,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromFile", "filename" : "filename", @@ -77,7 +77,7 @@ "validate" : true, "skipInvalidElements" : false } - ''', + """, g.AddElementsFromFile( parallelism=1, validate=True, @@ -88,7 +88,7 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromKafka", "topic" : "topic1", @@ -99,7 +99,7 @@ "validate" : true, "skipInvalidElements" : false } - ''', + """, g.AddElementsFromKafka( topic="topic1", parallelism=1, @@ -114,7 +114,7 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.add.AddElementsFromSocket", "hostname" : "localhost", @@ -125,7 +125,7 @@ "skipInvalidElements" : false, "delimiter" : "," } - ''', + """, g.AddElementsFromSocket( validate=True, element_generator="uk.gov.gchq.gaffer.doc.operation.generator.ElementGenerator", @@ -138,7 +138,7 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -147,7 +147,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.CountGroups" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -157,7 +157,7 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -167,7 +167,7 @@ "limit" : 5 } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -179,7 +179,7 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -193,7 +193,7 @@ "key" : "ALL" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -206,7 +206,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -219,7 +219,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -230,7 +230,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -239,7 +239,7 @@ "key" : "ALL" } ] } - ''', + """, g.OperationChain( operations=[ g.GetGafferResultCacheExport( @@ -250,7 +250,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -278,7 +278,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -305,7 +305,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -321,7 +321,7 @@ "graphId" : "graph2" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -342,7 +342,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -360,7 +360,7 @@ "parentStorePropertiesId" : "storePropsId1" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -385,7 +385,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -401,7 +401,7 @@ "graphId" : "newGraphId" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -422,7 +422,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -485,7 +485,7 @@ } } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -500,36 +500,36 @@ ) ), g.ExportToOtherGraph( - schema={'edges': { - 'edge': {'groupBy': [], 'directed': 'true', - 'properties': {'count': 'int'}, - 'destination': 'int', 'source': 'int'}}, - 'entities': { - 'entity': {'groupBy': [], 'vertex': 'int', - 'properties': {'count': 'int'}}}, - 'types': {'true': {'validateFunctions': [{ - 'class': 'uk.gov.gchq.koryphe.impl.predicate.IsTrue'}], - 'class': 'java.lang.Boolean'}, - 'int': {'aggregateFunction': { - 'class': 'uk.gov.gchq.koryphe.impl.binaryoperator.Sum'}, - 'class': 'java.lang.Integer'}}}, + schema={"edges": { + "edge": {"groupBy": [], "directed": "true", + "properties": {"count": "int"}, + "destination": "int", "source": "int"}}, + "entities": { + "entity": {"groupBy": [], "vertex": "int", + "properties": {"count": "int"}}}, + "types": {"true": {"validateFunctions": [{ + "class": "uk.gov.gchq.koryphe.impl.predicate.IsTrue"}], + "class": "java.lang.Boolean"}, + "int": {"aggregateFunction": { + "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum"}, + "class": "java.lang.Integer"}}}, store_properties={ - 'gaffer.store.job.tracker.enabled': 'true', - 'gaffer.cache.service.class': 'uk.gov.gchq.gaffer.cache.impl.HashMapCacheService', - 'gaffer.store.properties.class': 'uk.gov.gchq.gaffer.accumulostore.AccumuloProperties', - 'accumulo.instance': 'someInstanceName', - 'accumulo.zookeepers': 'localhost', - 'accumulo.password': 'password', - 'gaffer.store.operation.declarations': 'ExportToOtherGraphOperationDeclarations.json', - 'accumulo.user': 'user01', - 'gaffer.store.class': 'uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore'}, + "gaffer.store.job.tracker.enabled": "true", + "gaffer.cache.service.class": "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService", + "gaffer.store.properties.class": "uk.gov.gchq.gaffer.accumulostore.AccumuloProperties", + "accumulo.instance": "someInstanceName", + "accumulo.zookeepers": "localhost", + "accumulo.password": "password", + "gaffer.store.operation.declarations": "ExportToOtherGraphOperationDeclarations.json", + "accumulo.user": "user01", + "gaffer.store.class": "uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore"}, graph_id="newGraphId" ) ] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -552,7 +552,7 @@ } } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -568,17 +568,17 @@ ), g.ExportToOtherGraph( graph_id="otherGafferRestApiGraphId", - store_properties={'gaffer.context-root': '/rest/v1', - 'gaffer.store.class': 'uk.gov.gchq.gaffer.proxystore.ProxyStore', - 'gaffer.host': 'localhost', - 'gaffer.store.properties.class': 'uk.gov.gchq.gaffer.proxystore.ProxyProperties', - 'gaffer.port': '8081'} + store_properties={"gaffer.context-root": "/rest/v1", + "gaffer.store.class": "uk.gov.gchq.gaffer.proxystore.ProxyStore", + "gaffer.host": "localhost", + "gaffer.store.properties.class": "uk.gov.gchq.gaffer.proxystore.ProxyProperties", + "gaffer.port": "8081"} ) ] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -594,7 +594,7 @@ "graphId" : "exportGraphId" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -615,7 +615,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -633,7 +633,7 @@ "parentStorePropertiesId" : "exportStorePropertiesId" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements( @@ -658,7 +658,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -672,7 +672,7 @@ "start" : 0 } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -685,7 +685,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -700,7 +700,7 @@ "end" : 4 } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -714,7 +714,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -744,7 +744,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -773,7 +773,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", "elementGenerator" : { @@ -781,7 +781,7 @@ }, "input" : [ "1,1", "1,2,1" ] } - ''', + """, g.GenerateElements( element_generator=g.ElementGenerator( fields={}, @@ -794,7 +794,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateElements", "elementGenerator" : { @@ -811,24 +811,24 @@ "c" : 1 } ] } - ''', + """, g.GenerateElements( element_generator=g.ElementGenerator( class_name="uk.gov.gchq.gaffer.doc.operation.GenerateElementsExample$DomainObjectGenerator", fields={} ), input=[ - {'c': 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} + {"c": 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.operation.impl.generate.GenerateObjects", "elementGenerator" : { @@ -852,18 +852,18 @@ "class" : "uk.gov.gchq.gaffer.data.element.Edge" } ] } - ''', + """, g.GenerateObjects( input=[ g.Entity( - properties={'count': 1}, + properties={"count": 1}, vertex=6, group="entity" ), g.Edge( directed=True, source=5, - properties={'count': 1}, + properties={"count": 1}, group="edge", destination=6 ) @@ -875,7 +875,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects", "elementGenerator" : { @@ -899,7 +899,7 @@ "class" : "uk.gov.gchq.gaffer.data.element.Edge" } ] } - ''', + """, g.GenerateObjects( element_generator=g.ElementGenerator( class_name="uk.gov.gchq.gaffer.doc.operation.GenerateObjectsExample$DomainObjectGenerator", @@ -907,14 +907,14 @@ ), input=[ g.Entity( - properties={'count': 1}, + properties={"count": 1}, vertex=6, group="entity" ), g.Edge( directed=True, group="edge", - properties={'count': 1}, + properties={"count": 1}, source=5, destination=6 ) @@ -922,7 +922,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", "input" : [ { @@ -930,7 +930,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetAdjacentIds( input=[ g.EntitySeed( @@ -940,7 +940,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", "includeIncomingOutGoing" : "OUTGOING", @@ -949,7 +949,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetAdjacentIds( input=[ g.EntitySeed( @@ -960,7 +960,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds", "view" : { @@ -984,7 +984,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetAdjacentIds( view=g.View( entities=[ @@ -1015,15 +1015,15 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" } - ''', + """, g.GetAllElements() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements", "view" : { @@ -1053,7 +1053,7 @@ } } } - ''', + """, g.GetAllElements( view=g.View( entities=[ @@ -1088,15 +1088,15 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetAllJobDetails" } - ''', + """, g.GetAllJobDetails() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1110,7 +1110,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" } ] } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -1126,7 +1126,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1138,7 +1138,7 @@ "allEntities": true } } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -1152,7 +1152,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1163,7 +1163,7 @@ "allEdges": true } } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -1177,7 +1177,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1188,7 +1188,7 @@ "allEntities": true } } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -1201,7 +1201,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1241,7 +1241,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" } ] } - ''', + """, g.GetElements( view=g.View( edges=[ @@ -1287,7 +1287,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1295,7 +1295,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -1305,7 +1305,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -1316,7 +1316,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" } ] } - ''', + """, g.GetElements( input=[ g.EdgeSeed( @@ -1329,7 +1329,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1366,7 +1366,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" } ] } - ''', + """, g.GetElements( view=g.View( edges=[ @@ -1411,7 +1411,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1447,7 +1447,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EdgeSeed" } ] } - ''', + """, g.GetElements( view=g.View( edges=[ @@ -1491,7 +1491,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1529,7 +1529,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetElements( view=g.View( edges=[ @@ -1578,7 +1578,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1605,7 +1605,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetElements( view=g.View( edges=[ @@ -1615,7 +1615,7 @@ projection=[ "vertex|count" ], - function=g.Concat(separator='|'), + function=g.Concat(separator="|"), selection=[ "SOURCE", "count" @@ -1627,7 +1627,7 @@ "vertex|count" ], transient_properties={ - 'vertex|count': 'java.lang.String'} + "vertex|count": "java.lang.String"} ) ], entities=[ @@ -1641,7 +1641,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "view" : { @@ -1668,7 +1668,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetElements( view=g.View( entities=[ @@ -1679,14 +1679,14 @@ "count" ], transient_properties={ - 'vertex|count': 'java.lang.String'}, + "vertex|count": "java.lang.String"}, transform_functions=[ g.FunctionContext( selection=[ "SOURCE", "count" ], - function=g.Concat(separator='|'), + function=g.Concat(separator="|"), projection=[ "vertex|count" ] @@ -1704,16 +1704,16 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.get.GetFromEndpoint", "endpoint": "http://mydata.io" } - ''', + """, g.GetFromEndpoint(endpoint="http://mydata.io") ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1727,7 +1727,7 @@ "key" : "ALL" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1740,7 +1740,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1753,7 +1753,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails" } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1764,7 +1764,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1773,7 +1773,7 @@ "key" : "ALL" } ] } - ''', + """, g.OperationChain( operations=[ g.GetGafferResultCacheExport( @@ -1784,7 +1784,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1812,7 +1812,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1839,29 +1839,29 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobDetails", "jobId" : "18be2a20-5f36-4598-b522-1efc409b6b39" } - ''', + """, g.GetJobDetails( job_id="18be2a20-5f36-4598-b522-1efc409b6b39" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.job.GetJobResults", "jobId" : "92932856-be96-41b3-85d8-bba7b6886284" } - ''', + """, g.GetJobResults( job_id="92932856-be96-41b3-85d8-bba7b6886284" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1875,7 +1875,7 @@ "start" : 0 } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1888,7 +1888,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1903,7 +1903,7 @@ "end" : 4 } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1917,7 +1917,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1947,7 +1947,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1976,7 +1976,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -1987,7 +1987,7 @@ "truncate" : true } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -1999,7 +1999,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2010,7 +2010,7 @@ "truncate" : false } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -2022,7 +2022,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2033,7 +2033,7 @@ "truncate" : true } ] } - ''', + """, g.OperationChain( operations=[ g.GetAllElements(), @@ -2045,7 +2045,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2067,7 +2067,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2096,7 +2096,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2153,7 +2153,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2185,7 +2185,7 @@ ], group="edge", transient_properties={ - 'score': 'java.lang.Integer'} + "score": "java.lang.Integer"} ) ], entities=[ @@ -2207,7 +2207,7 @@ ], group="entity", transient_properties={ - 'score': 'java.lang.Integer'} + "score": "java.lang.Integer"} ) ] ) @@ -2236,7 +2236,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2258,7 +2258,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2287,7 +2287,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2344,7 +2344,7 @@ } ] } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2375,7 +2375,7 @@ ) ], transient_properties={ - 'score': 'java.lang.Integer'}, + "score": "java.lang.Integer"}, group="entity" ) ], @@ -2397,7 +2397,7 @@ ) ], transient_properties={ - 'score': 'java.lang.Integer'}, + "score": "java.lang.Integer"}, group="edge" ) ] @@ -2427,7 +2427,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", "operationName" : "2-hop", @@ -2446,7 +2446,7 @@ } ] } } - ''', + """, g.AddNamedOperation( operation_chain=g.OperationChainDAO( operations=[ @@ -2471,7 +2471,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", "operationName" : "2-hop-with-score", @@ -2490,7 +2490,7 @@ } ] } } - ''', + """, g.AddNamedOperation( operation_chain=g.OperationChainDAO( operations=[ @@ -2515,7 +2515,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", "operationName" : "2-hop-with-limit", @@ -2544,7 +2544,7 @@ } ] } } - ''', + """, g.AddNamedOperation( description="2 hop query with settable limit", parameters=[ @@ -2580,7 +2580,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.AddNamedOperation", "operationName" : "2-hop-with-limit", @@ -2609,7 +2609,7 @@ } ] } } - ''', + """, g.AddNamedOperation( read_access_roles=[ "read-user" @@ -2645,15 +2645,15 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.GetAllNamedOperations" } - ''', + """, g.GetAllNamedOperations() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", "operationName" : "2-hop", @@ -2663,7 +2663,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.NamedOperation( operation_name="2-hop", input=[ @@ -2674,7 +2674,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.NamedOperation", "operationName" : "2-hop-with-limit", @@ -2687,9 +2687,9 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.NamedOperation( - parameters={'param1': 2}, + parameters={"param1": 2}, input=[ g.EntitySeed( vertex=1 @@ -2699,18 +2699,18 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.operation.DeleteNamedOperation", "operationName" : "2-hop" } - ''', + """, g.DeleteNamedOperation( operation_name="2-hop" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2734,7 +2734,7 @@ "deduplicate" : true } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2765,7 +2765,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2789,7 +2789,7 @@ "deduplicate" : false } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2820,7 +2820,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2879,7 +2879,7 @@ "deduplicate" : true } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2911,7 +2911,7 @@ ], group="edge", transient_properties={ - 'score': 'java.lang.Integer'} + "score": "java.lang.Integer"} ) ], entities=[ @@ -2933,7 +2933,7 @@ ], group="entity", transient_properties={ - 'score': 'java.lang.Integer'} + "score": "java.lang.Integer"} ) ] ) @@ -2964,7 +2964,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -2980,7 +2980,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToArray" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -2998,7 +2998,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3025,7 +3025,7 @@ "includeHeader" : true } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3042,10 +3042,10 @@ include_header=True, csv_generator=g.CsvGenerator( fields={ - 'GROUP': 'Edge group', - 'VERTEX': 'vertex', - 'count': 'total count', - 'SOURCE': 'source' + "GROUP": "Edge group", + "VERTEX": "vertex", + "count": "total count", + "SOURCE": "source" }, quoted=False ) @@ -3054,7 +3054,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3070,7 +3070,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToEntitySeeds" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3088,7 +3088,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3104,7 +3104,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToList" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3122,7 +3122,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3147,7 +3147,7 @@ } } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3163,10 +3163,10 @@ g.ToMap( element_generator=g.MapGenerator( fields={ - 'SOURCE': 'source', - 'count': 'total count', - 'VERTEX': 'vertex', - 'GROUP': 'group' + "SOURCE": "source", + "count": "total count", + "VERTEX": "vertex", + "GROUP": "group" } ) ) @@ -3174,7 +3174,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetElements", "input" : [ { @@ -3185,7 +3185,7 @@ "class" : "uk.gov.gchq.gaffer.operation.data.EntitySeed" } ] } - ''', + """, g.GetElements( input=[ g.EntitySeed( @@ -3198,7 +3198,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3214,7 +3214,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3232,7 +3232,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3248,7 +3248,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToStream" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3266,7 +3266,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3291,7 +3291,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3321,7 +3321,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3347,7 +3347,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3378,7 +3378,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3404,7 +3404,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3435,7 +3435,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3461,7 +3461,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSet" } ] } - ''', + """, g.OperationChain( operations=[ g.GetElements( @@ -3492,7 +3492,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ { @@ -3512,7 +3512,7 @@ } } ] } - ''', + """, g.OperationChain( operations=[ g.GetJobResults( @@ -3535,7 +3535,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.function.Filter", "globalElements": { @@ -3648,7 +3648,7 @@ } } - ''', + """, g.Filter( global_edges=g.GlobalElementFilterDefinition( predicates=[ @@ -3741,7 +3741,7 @@ ) ], [ - ''' + """ { "operations": [ { @@ -3817,7 +3817,7 @@ ], "class": "uk.gov.gchq.gaffer.operation.OperationChain" } - ''', + """, g.OperationChain( operations=[ g.GetJobResults( @@ -3888,7 +3888,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.OperationChain", "operations": [ @@ -3965,7 +3965,7 @@ } ] } - ''', + """, g.OperationChain( operations=[ g.GetJobResults( @@ -4029,7 +4029,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain", "operationChain" : { @@ -4046,13 +4046,13 @@ } ] } } - ''', + """, g.ScoreOperationChain( operation_chain=g.OperationChain( operations=[ g.GetElements(), g.NamedOperation( - operation_name='namedOp' + operation_name="namedOp" ), g.Limit( truncate=True, @@ -4063,7 +4063,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.ScoreOperationChain", "operationChain" : { @@ -4080,7 +4080,7 @@ } ] } } - ''', + """, g.ScoreOperationChain( operation_chain={ "class": "uk.gov.gchq.gaffer.operation.OperationChain", @@ -4098,7 +4098,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.OperationChain", "operations": [{ @@ -4123,7 +4123,7 @@ }] }] } - ''', + """, g.OperationChain( operations=[ g.GetWalks( @@ -4154,7 +4154,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.GetWalks", "operations" : [ @@ -4242,7 +4242,7 @@ "vertex" : "A" } ] } - ''', + """, g.GetWalks( results_limit=1000000, operations=[ @@ -4355,7 +4355,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.OperationChain", "operations" : [ @@ -4377,7 +4377,7 @@ "key1": "value1" } } - ''', + """, g.OperationChain( operations=[ g.OperationChain( @@ -4391,18 +4391,18 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.store.operation.GetSchema", "compact": true } - ''', + """, GetSchema( compact=True ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.OperationChain", "operations": [{ @@ -4451,7 +4451,7 @@ "class": "uk.gov.gchq.gaffer.operation.impl.output.ToSet" }] } - ''', + """, g.OperationChain( operations=[ g.GetWalks( @@ -4504,25 +4504,25 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile", "inputPath": "path/to/file" } - ''', + """, g.SplitStoreFromFile( input_path="path/to/file" ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.SplitStoreFromIterable", "input": [ "1", "2", "3" ] } - ''', + """, g.SplitStoreFromIterable( input=[ "1", "2", "3" @@ -4530,7 +4530,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.SampleElementsForSplitPoints", "input" : [ { @@ -4553,19 +4553,19 @@ "numSplits": 5, "proportionToSample": 0.1 } - ''', + """, g.SampleElementsForSplitPoints( input=[ g.Entity( vertex=6, - properties={'count': 1}, + properties={"count": 1}, group="entity" ), g.Edge( destination=6, source=5, group="edge", - properties={'count': 1}, + properties={"count": 1}, directed=True ) ], @@ -4574,7 +4574,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.If", "input" : [{ @@ -4608,13 +4608,13 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" } } - ''', + """, g.If( input=g.Entity( - group='entity', - vertex='a1', + group="entity", + vertex="a1", properties={ - 'count': 5 + "count": 5 } ), conditional=g.Conditional( @@ -4625,7 +4625,7 @@ transform=g.Map( functions=[ g.ExtractProperty( - name='count' + name="count" ) ] ) @@ -4635,7 +4635,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", "name" : "testNamedView", @@ -4648,22 +4648,22 @@ "overwriteFlag" : true, "writeAccessRoles" : [ "auth1", "auth2" ] } - ''', + """, g.AddNamedView( - name='testNamedView', - description='example test NamedView', + name="testNamedView", + description="example test NamedView", view=g.View( edges=[ g.ElementDefinition( - group='testEdge' + group="testEdge" )] ), overwrite_flag=True, - write_access_roles=['auth1', 'auth2'] + write_access_roles=["auth1", "auth2"] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.named.view.AddNamedView", "view" : { @@ -4692,17 +4692,17 @@ "overwriteFlag" : true, "writeAccessRoles" : [ "auth1", "auth2" ] } - ''', + """, g.AddNamedView( - name='isMoreThan', - description='is more than', + name="isMoreThan", + description="is more than", view=g.View( edges=[ g.ElementDefinition( - group='testEdge', + group="testEdge", pre_aggregation_filter_functions=[ g.PredicateContext( - selection='count', + selection="count", predicate=g.IsMoreThan( value="${countThreshold}" ) @@ -4720,38 +4720,38 @@ ) ], overwrite_flag=True, - write_access_roles=['auth1', 'auth2'] + write_access_roles=["auth1", "auth2"] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph", "graphId" : "graph1" } - ''', + """, g.RemoveGraph( graph_id="graph1" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds" } - ''', + """, g.GetAllGraphIds() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo" } - ''', + """, g.GetAllGraphInfo() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraph", "graphId" : "graph1", @@ -4783,7 +4783,7 @@ "gaffer.cache.service.class" : "uk.gov.gchq.gaffer.cache.impl.HashMapCacheService" } } - ''', + """, g.AddGraph( graph_id="graph1", is_public=False, @@ -4816,7 +4816,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks", "graphId" : "graph1", @@ -4853,7 +4853,7 @@ } ] } - ''', + """, g.AddGraphWithHooks( graph_id="graph1", is_public=False, @@ -4889,7 +4889,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess", "graphId": "example_graph_id", @@ -4897,7 +4897,7 @@ "ownerUserId": "example_user_id", "isPublic": true } - ''', + """, g.ChangeGraphAccess( graph_id="example_graph_id", graph_auths=["Auth_1", "Auth_2"], @@ -4906,7 +4906,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.While", "maxRepeats" : 5, @@ -4921,7 +4921,7 @@ "class" : "uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds" } } - ''', + """, g.While( max_repeats=5, input=[ @@ -4934,7 +4934,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.While", "maxRepeats" : 10, @@ -4964,7 +4964,7 @@ }, "operation" : {"class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements"} } - ''', + """, g.While( max_repeats=10, input=[ @@ -4994,31 +4994,31 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.store.operation.HasTrait", "trait": "VISIBILITY", "currentTraits" : true } - ''', + """, g.HasTrait( trait="VISIBILITY", current_traits=True ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.store.operation.GetTraits", "currentTraits" : true } - ''', + """, g.GetTraits( current_traits=True ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.Reduce", "input" : [{ @@ -5036,7 +5036,7 @@ }, "identity": 10 } - ''', + """, g.Reduce( input=[ g.Edge( @@ -5057,7 +5057,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.ForEach", "input" : [{ @@ -5072,7 +5072,7 @@ }], "operation": {"class": "uk.gov.gchq.gaffer.operation.impl.get.GetElements"} } - ''', + """, g.ForEach( input=[ g.Edge( @@ -5089,7 +5089,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.output.ToSingletonList", "input" : [{ @@ -5103,7 +5103,7 @@ } }] } - ''', + """, g.ToSingletonList( input=[ g.Edge( @@ -5119,7 +5119,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", "operationChain" : { @@ -5134,7 +5134,7 @@ "key" : "value" } } - ''', + """, g.ValidateOperationChain( operation_chain=g.OperationChain( operations=[ @@ -5148,7 +5148,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain", "operationChain" : { @@ -5163,7 +5163,7 @@ "key" : "value" } } - ''', + """, g.ValidateOperationChain( operation_chain={ "class": "uk.gov.gchq.gaffer.operation.OperationChain", @@ -5179,7 +5179,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.SetVariable", "input" : "testVal", @@ -5188,7 +5188,7 @@ "key" : "value" } } - ''', + """, g.SetVariable( input="testVal", variable_name="testVarName", @@ -5198,7 +5198,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.GetVariable", "variableName" : "testVarName", @@ -5206,7 +5206,7 @@ "key" : "value" } } - ''', + """, g.GetVariable( variable_name="testVarName", options={ @@ -5215,7 +5215,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.operation.impl.GetVariables", "variableNames" : ["testVarName", "testVarName2"], @@ -5223,7 +5223,7 @@ "key" : "value" } } - ''', + """, g.GetVariables( variable_names=["testVarName", "testVarName2"], options={ @@ -5232,7 +5232,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.join.Join", "input": [ "test2" ], @@ -5252,17 +5252,17 @@ "joinType": "INNER", "collectionLimit": 10 } - ''', + """, g.Join( - input=['test2'], - operation=g.GetElements(input=[g.EntitySeed('test')]), + input=["test2"], + operation=g.GetElements(input=[g.EntitySeed("test")]), match_method=g.ElementMatch(), flatten=False, join_type=g.JoinType.INNER, collection_limit=10) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation", "operation": { @@ -5277,7 +5277,7 @@ "key" : "value" } } - ''', + """, g.FederatedOperation( operation=g.OperationChain([g.AddElements(), g.GetElements()]), options={ @@ -5286,7 +5286,7 @@ ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.join.Join", "input": [ "test2" ], @@ -5310,39 +5310,39 @@ "flatten": false, "joinType": "OUTER" } - ''', + """, g.Join( - input=['test2'], - operation=g.GetElements(input=[g.EntitySeed('test')]), + input=["test2"], + operation=g.GetElements(input=[g.EntitySeed("test")]), match_method=g.KeyFunctionMatch(first_key_function=g.ExtractId("DESTINATION")), match_key=g.MatchKey.RIGHT, flatten=False, join_type=g.JoinType.OUTER) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob", "jobId": "238492-2ad-fadf034-324-2a" } - ''', + """, g.CancelScheduledJob(job_id="238492-2ad-fadf034-324-2a") ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId", "graphId": "old_name", "newGraphId": "new_name" } - ''', + """, g.ChangeGraphId( graph_id="old_name", new_graph_id="new_name" ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.operation.OperationChain", "operations": [{ @@ -5384,7 +5384,7 @@ }] }] } - ''', + """, g.OperationChain( operations=[ g.GetWalks( @@ -5396,7 +5396,7 @@ transform=g.Map( functions=[ g.ExtractProperty( - name='count' + name="count" ) ] ) diff --git a/tests/unit/test_gaffer_predicates.py b/tests/unit/test_gaffer_predicates.py index c02a8714..4d58e76f 100755 --- a/tests/unit/test_gaffer_predicates.py +++ b/tests/unit/test_gaffer_predicates.py @@ -1,14 +1,14 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # -# Licensed under the Apache License, Version 2.0 (the 'License'); +# 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, +# 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. @@ -22,18 +22,18 @@ "json_string,gafferpy_method", [ [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.AgeOff", "ageOffTime" : 100000 } - ''', + """, g.AgeOff( age_off_time=100000 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.And", "predicates" : [ { @@ -46,7 +46,7 @@ "value" : 0 } ] } - ''', + """, g.And( predicates=[ g.IsLessThan( @@ -61,7 +61,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.And", "predicates" : [ { @@ -82,7 +82,7 @@ "selection" : [ 1 ] } ] } - ''', + """, g.And( predicates=[ g.NestedPredicate( @@ -107,12 +107,12 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.AreIn", "values" : [ 1, 2, 3 ] } - ''', + """, g.AreIn( values=[ 1, @@ -123,82 +123,82 @@ ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.CollectionContains", "value" : 1 } - ''', + """, g.CollectionContains( value=1 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.Exists" } - ''', + """, g.Exists() ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.sketches.clearspring.cardinality.predicate.HyperLogLogPlusIsLessThan", "orEqualTo" : false, "value" : 2 } - ''', + """, g.HyperLogLogPlusIsLessThan( value=2, or_equal_to=False ) ], [ - ''' + """ { "class" : "uk.gov.gchq.gaffer.sketches.datasketches.cardinality.predicate.HllSketchIsLessThan", "orEqualTo" : false, "value" : 2 } - ''', + """, g.HllSketchIsLessThan( value=2, or_equal_to=False ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsA", "type" : "java.lang.String" } - ''', + """, g.IsA( type="java.lang.String" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsEqual", "value" : 5 } - ''', + """, g.IsEqual( value=5 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsFalse" } - ''', + """, g.IsFalse() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsIn", "values" : [ 5, { @@ -207,106 +207,106 @@ "java.lang.Character" : "5" } ] } - ''', + """, g.IsIn( values=[ 5, - {'java.lang.Long': 5}, + {"java.lang.Long": 5}, "5", - {'java.lang.Character': '5'} + {"java.lang.Character": "5"} ] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", "orEqualTo" : false, "value" : 5 } - ''', + """, g.IsLessThan( value=5, or_equal_to=False ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", "orEqualTo" : true, "value" : 5 } - ''', + """, g.IsLessThan( value=5, or_equal_to=True ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsMoreThan", "orEqualTo" : false, "value" : 5 } - ''', + """, g.IsMoreThan( value=5, or_equal_to=False ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsShorterThan", "maxLength" : 4, "orEqualTo" : false } - ''', + """, g.IsShorterThan( or_equal_to=False, max_length=4 ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsTrue" } - ''', + """, g.IsTrue() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsXLessThanY" } - ''', + """, g.IsXLessThanY() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsXMoreThanY" } - ''', + """, g.IsXMoreThanY() ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.MapContains", "key" : "a" } - ''', + """, g.MapContains( key="a" ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.MapContainsPredicate", "keyPredicate" : { @@ -316,15 +316,15 @@ } } } - ''', + """, g.MapContainsPredicate( key_predicate=g.Regex( - value={'java.util.regex.Pattern': 'a.*'} + value={"java.util.regex.Pattern": "a.*"} ) ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.MultiRegex", "value" : [ { @@ -333,29 +333,29 @@ "java.util.regex.Pattern" : "[0-4]" } ] } - ''', + """, g.MultiRegex( value=[ - {'java.util.regex.Pattern': '[a-d]'}, - {'java.util.regex.Pattern': '[0-4]'} + {"java.util.regex.Pattern": "[a-d]"}, + {"java.util.regex.Pattern": "[0-4]"} ] ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.Not", "predicate" : { "class" : "uk.gov.gchq.koryphe.impl.predicate.Exists" } } - ''', + """, g.Not( predicate=g.Exists() ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.Or", "predicates" : [ { @@ -371,7 +371,7 @@ "value" : 10 } ] } - ''', + """, g.Or( predicates=[ g.IsLessThan( @@ -389,7 +389,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.Or", "predicates" : [ { @@ -410,7 +410,7 @@ "selection" : [ 1 ] } ] } - ''', + """, g.Or( predicates=[ g.NestedPredicate( @@ -435,7 +435,7 @@ ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.predicate.PredicateMap", "predicate" : { @@ -447,56 +447,56 @@ }, "key" : "key1" } - ''', + """, g.PredicateMap( key="key1", predicate=g.IsMoreThan( or_equal_to=False, - value={'java.lang.Long': 2} + value={"java.lang.Long": 2} ) ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.Regex", "value" : { "java.util.regex.Pattern" : "[a-d0-4]" } } - ''', + """, g.Regex( - value={'java.util.regex.Pattern': '[a-d0-4]'} + value={"java.util.regex.Pattern": "[a-d0-4]"} ) ], [ - ''' + """ { "class":"uk.gov.gchq.koryphe.impl.predicate.StringContains", "value":"someValue", "ignoreCase":false } - ''', + """, g.StringContains( - value='someValue', + value="someValue", ignore_case=False ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLongerThan", "minLength" : 10, "orEqualTo" : true } - ''', + """, g.IsLongerThan( min_length=10, or_equal_to=True ) ], [ - ''' + """ { "class" : "uk.gov.gchq.koryphe.impl.predicate.If", "predicate" : { @@ -514,10 +514,10 @@ "orEqualTo" : false } } - ''', + """, g.pred.If( predicate=g.MapContains( - key='testKey' + key="testKey" ), then=g.IsLongerThan( min_length=20, @@ -530,17 +530,17 @@ ) ], [ - ''' - { - "class" : "uk.gov.gchq.koryphe.impl.predicate.If", - "condition" : true, - "then" : { - "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLongerThan", - "minLength" : 20, - "orEqualTo" : true - } + """ + { + "class" : "uk.gov.gchq.koryphe.impl.predicate.If", + "condition" : true, + "then" : { + "class" : "uk.gov.gchq.koryphe.impl.predicate.IsLongerThan", + "minLength" : 20, + "orEqualTo" : true } - ''', + } + """, g.pred.If( condition=True, then=g.IsLongerThan( @@ -550,80 +550,80 @@ ) ], [ - ''' + """ {"class":"uk.gov.gchq.koryphe.impl.predicate.range.InTimeRangeDual","start":"2017/01/01","end":"2017/02/01","timeUnit":"MICROSECOND","startFullyContained":true,"endFullyContained":true,"timeZone":"Etc/GMT+0"} - ''', + """, g.InTimeRangeDual( - start='2017/01/01', - end='2017/02/01', - time_unit='MICROSECOND', + start="2017/01/01", + end="2017/02/01", + time_unit="MICROSECOND", start_fully_contained=True, end_fully_contained=True, - time_zone='Etc/GMT+0' + time_zone="Etc/GMT+0" ) ], [ - ''' + """ {"class":"uk.gov.gchq.koryphe.impl.predicate.range.InTimeRange","start":"2017/01/01","end":"2017/02/01","timeUnit":"MICROSECOND","timeZone":"Etc/GMT+0"} - ''', + """, g.InTimeRange( - start='2017/01/01', - end='2017/02/01', - time_unit='MICROSECOND', - time_zone='Etc/GMT+0' + start="2017/01/01", + end="2017/02/01", + time_unit="MICROSECOND", + time_zone="Etc/GMT+0" ) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.element.comparison.ElementJoinComparator" } - ''', + """, g.ElementJoinComparator() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.element.comparison.ElementJoinComparator", "groupByProperties": [ "test1", "test2" ] } - ''', + """, g.ElementJoinComparator(group_by_properties=["test1", "test2"]) ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.access.predicate.user.DefaultUserPredicate", "auths": [ "a", "test2" ], "creatingUserId": "user1" } - ''', + """, g.DefaultUserPredicate(auths=["a", "test2"], creating_user_id="user1") ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.access.predicate.user.UnrestrictedAccessUserPredicate" } - ''', + """, g.UnrestrictedAccessUserPredicate() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.access.predicate.user.NoAccessUserPredicate" } - ''', + """, g.NoAccessUserPredicate() ], [ - ''' + """ { "class": "uk.gov.gchq.gaffer.data.elementdefinition.view.access.predicate.user.NamedViewWriteUserPredicate", "auths": [ "a", "test2" ], "creatingUserId": "user1" } - ''', + """, g.NamedViewWriteUserPredicate(auths=["a", "test2"], creating_user_id="user1") ] ] diff --git a/tests/unit/test_json_converter.py b/tests/unit/test_json_converter.py index 5cec62d8..b438395f 100644 --- a/tests/unit/test_json_converter.py +++ b/tests/unit/test_json_converter.py @@ -1,5 +1,5 @@ # -# Copyright 2016-2023 Crown Copyright +# Copyright 2016-2024 Crown Copyright # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ def test_throw_improper_string_json(): with pytest.raises(json.JSONDecodeError): - JsonConverter.from_json('Not json') + JsonConverter.from_json("Not json") def test_throw_when_op():