diff --git a/src/python_workflow_definition/aiida.py b/src/python_workflow_definition/aiida.py index 62305bc..680b71b 100644 --- a/src/python_workflow_definition/aiida.py +++ b/src/python_workflow_definition/aiida.py @@ -30,10 +30,15 @@ def load_workflow_json(file_name: str) -> WorkGraph: wg = WorkGraph() task_name_mapping = {} + nodes_types_dict = {int(n["id"]): n["type"] for n in data[NODES_LABEL]} for id, identifier in convert_nodes_list_to_dict( nodes_list=data[NODES_LABEL] ).items(): - if isinstance(identifier, str) and "." in identifier: + if ( + nodes_types_dict[int(id)] == "function" + and isinstance(identifier, str) + and "." in identifier + ): p, m = identifier.rsplit(".", 1) mod = import_module(p) func = getattr(mod, m) diff --git a/src/python_workflow_definition/executorlib.py b/src/python_workflow_definition/executorlib.py index 3a494cd..b082b75 100644 --- a/src/python_workflow_definition/executorlib.py +++ b/src/python_workflow_definition/executorlib.py @@ -47,8 +47,9 @@ def load_workflow_json(file_name: str, exe: Executor): edges_new_lst = content[EDGES_LABEL] nodes_new_dict = {} + nodes_types_dict = {int(n["id"]): n["type"] for n in content[NODES_LABEL]} for k, v in convert_nodes_list_to_dict(nodes_list=content[NODES_LABEL]).items(): - if isinstance(v, str) and "." in v: + if nodes_types_dict[int(k)] == "function" and isinstance(v, str) and "." in v: p, m = v.rsplit(".", 1) mod = import_module(p) nodes_new_dict[int(k)] = getattr(mod, m) diff --git a/src/python_workflow_definition/jobflow.py b/src/python_workflow_definition/jobflow.py index 969251c..4a39490 100644 --- a/src/python_workflow_definition/jobflow.py +++ b/src/python_workflow_definition/jobflow.py @@ -295,8 +295,9 @@ def load_workflow_json(file_name: str) -> Flow: ) nodes_new_dict = {} + nodes_types_dict = {int(n["id"]): n["type"] for n in content[NODES_LABEL]} for k, v in convert_nodes_list_to_dict(nodes_list=content[NODES_LABEL]).items(): - if isinstance(v, str) and "." in v: + if nodes_types_dict[int(k)] == "function" and isinstance(v, str) and "." in v: p, m = v.rsplit(".", 1) mod = import_module(p) nodes_new_dict[int(k)] = getattr(mod, m) diff --git a/src/python_workflow_definition/purepython.py b/src/python_workflow_definition/purepython.py index 3fec845..d8af187 100644 --- a/src/python_workflow_definition/purepython.py +++ b/src/python_workflow_definition/purepython.py @@ -75,8 +75,9 @@ def load_workflow_json(file_name: str): edges_new_lst = content[EDGES_LABEL] nodes_new_dict = {} + nodes_types_dict = {int(n["id"]): n["type"] for n in content[NODES_LABEL]} for k, v in convert_nodes_list_to_dict(nodes_list=content[NODES_LABEL]).items(): - if isinstance(v, str) and "." in v: + if nodes_types_dict[int(k)] == "function" and isinstance(v, str) and "." in v: p, m = v.rsplit(".", 1) mod = import_module(p) nodes_new_dict[int(k)] = getattr(mod, m) diff --git a/src/python_workflow_definition/pyiron_base.py b/src/python_workflow_definition/pyiron_base.py index a362fea..00cc2b1 100644 --- a/src/python_workflow_definition/pyiron_base.py +++ b/src/python_workflow_definition/pyiron_base.py @@ -239,9 +239,10 @@ def load_workflow_json(file_name: str, project: Optional[Project] = None): ) edges_new_lst = content[EDGES_LABEL] + nodes_types_dict = {int(n["id"]): n["type"] for n in content[NODES_LABEL]} nodes_new_dict = {} for k, v in convert_nodes_list_to_dict(nodes_list=content[NODES_LABEL]).items(): - if isinstance(v, str) and "." in v: + if nodes_types_dict[int(k)] == "function" and isinstance(v, str) and "." in v: p, m = v.rsplit(".", 1) if p == "python_workflow_definition.shared": p = "python_workflow_definition.pyiron_base"