From e1fcb23477fe97e9e39793748b8a0bd98b7c2f44 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Fri, 27 Oct 2023 11:35:15 +0200 Subject: [PATCH 1/4] remove apply and reduce_dimension processes from implicitly_supported_processes list as they have js files --- src/pg_to_evalscript/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pg_to_evalscript/utils.py b/src/pg_to_evalscript/utils.py index aef24ed7..11bba32f 100644 --- a/src/pg_to_evalscript/utils.py +++ b/src/pg_to_evalscript/utils.py @@ -3,7 +3,7 @@ def list_supported_processes(): process_definitions_directory = "javascript_processes" - implicitly_supported_processes = ["load_collection", "save_result", "reduce_dimension", "apply"] + implicitly_supported_processes = ["load_collection", "save_result"] process_definition_files = pkg_resources.resource_listdir("pg_to_evalscript", f"{process_definitions_directory}") supported_processes_with_files = [ process_definition_file.replace(".js", "") for process_definition_file in process_definition_files From 613b831df558788d9067777970d67fe791bd734e Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Fri, 27 Oct 2023 11:40:14 +0200 Subject: [PATCH 2/4] expose implicitly_supported_processes from pg_to_evalscript/utils.py to avoid code duplication --- src/pg_to_evalscript/utils.py | 2 +- tests/integration_tests/test_integration.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pg_to_evalscript/utils.py b/src/pg_to_evalscript/utils.py index 11bba32f..5a1e84e0 100644 --- a/src/pg_to_evalscript/utils.py +++ b/src/pg_to_evalscript/utils.py @@ -1,9 +1,9 @@ import pkg_resources +implicitly_supported_processes = ["load_collection", "save_result"] def list_supported_processes(): process_definitions_directory = "javascript_processes" - implicitly_supported_processes = ["load_collection", "save_result"] process_definition_files = pkg_resources.resource_listdir("pg_to_evalscript", f"{process_definitions_directory}") supported_processes_with_files = [ process_definition_file.replace(".js", "") for process_definition_file in process_definition_files diff --git a/tests/integration_tests/test_integration.py b/tests/integration_tests/test_integration.py index fcfc07e2..7ffc2d39 100644 --- a/tests/integration_tests/test_integration.py +++ b/tests/integration_tests/test_integration.py @@ -2,6 +2,7 @@ import pytest from pg_to_evalscript import convert_from_process_graph, list_supported_processes +from pg_to_evalscript.utils import implicitly_supported_processes from tests.utils import ( get_process_graph_json, @@ -261,10 +262,7 @@ def test_process_graphs_with_scenes(pg_name, example_input, scenes, expected_out def test_list_supported_processes(): known_supported_processes = [ - "load_collection", - "save_result", - "reduce_dimension", - "apply", + *implicitly_supported_processes, *get_defined_processes_from_files(), ] supported_processes = list_supported_processes() From d1842822f9b51f9f2d5a784a9b6e80f431f596a4 Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Fri, 27 Oct 2023 11:58:44 +0200 Subject: [PATCH 3/4] return only unique processes in list_supported_processes --- src/pg_to_evalscript/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pg_to_evalscript/utils.py b/src/pg_to_evalscript/utils.py index 5a1e84e0..0b2f6cce 100644 --- a/src/pg_to_evalscript/utils.py +++ b/src/pg_to_evalscript/utils.py @@ -8,4 +8,5 @@ def list_supported_processes(): supported_processes_with_files = [ process_definition_file.replace(".js", "") for process_definition_file in process_definition_files ] - return [*implicitly_supported_processes, *supported_processes_with_files] + unique_supported_processes = list(set([*implicitly_supported_processes, *supported_processes_with_files])) + return unique_supported_processes From 9387ee8bdec7eac49da1f3786268b829bcd39dfd Mon Sep 17 00:00:00 2001 From: Ziga Cernigoj Date: Fri, 27 Oct 2023 12:10:28 +0200 Subject: [PATCH 4/4] make sure the known processes in test_list_supported_processes are also unique --- tests/integration_tests/test_integration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests/test_integration.py b/tests/integration_tests/test_integration.py index 7ffc2d39..7b736055 100644 --- a/tests/integration_tests/test_integration.py +++ b/tests/integration_tests/test_integration.py @@ -261,10 +261,10 @@ def test_process_graphs_with_scenes(pg_name, example_input, scenes, expected_out def test_list_supported_processes(): - known_supported_processes = [ + known_supported_processes = list(set([ *implicitly_supported_processes, *get_defined_processes_from_files(), - ] + ])) supported_processes = list_supported_processes() assert len(known_supported_processes) == len(supported_processes) assert set(known_supported_processes) == set(supported_processes)