From eabff4b40e4a9370e6977a336931fa047855daa8 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 6 Nov 2025 10:04:18 +0100 Subject: [PATCH 1/5] feat(workflow): add Workflow.required_plugins --- src/ansys/dpf/core/workflow.py | 28 ++++++++++++++++++++++++++++ tests/test_workflow.py | 12 ++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index 6895c654b3a..c67515105f2 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -1032,3 +1032,31 @@ def __str__(self): from ansys.dpf.core.core import _description return _description(self._internal_obj, self._server) + + def required_plugins(self) -> list[str]: + """List of plugins required by the workflow based on registered operators. + + Returns + ------- + plugins: + List of plugins used by the workflow. + The plugin name reported is the one set when loading the plugin. + + Examples + -------- + >>> from ansys.dpf import core as dpf + >>> wf = dpf.Workflow() + >>> op1 = dpf.Operator("html_doc") # from 'documentation' plugin + >>> op2 = dpf.Operator("U") # from 'core' plugin + >>> wf.add_operators([op1, op2]) + >>> wf.required_plugins() + ['documentation', 'core'] + """ + num = self._api.work_flow_number_of_operators(self) + out = [] + for i in range(num): + op_name = self._api.work_flow_operator_name_by_index(self, i) + spec = dpf.core.dpf_operator.Operator.operator_specification(op_name, self._server) + plugin_name = spec.properties["plugin"] + out.append(plugin_name) + return list(set(out)) diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 85c7eefec46..68836158e9c 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1101,6 +1101,18 @@ def test_workflow_get_output_derived_class(server_type): assert workflow_topology +def test_required_plugins(server_type): + wf = dpf.core.Workflow(server=server_type) + op1 = dpf.core.Operator("html_doc", server=server_type) # from 'documentation' plugin + op2 = dpf.core.Operator("U", server=server_type) # from 'core' plugin + wf.add_operators([op1, op2]) + plugins = wf.required_plugins() + assert isinstance(plugins, list) + assert op1.specification.properties["plugin"] in plugins + assert op2.specification.properties["plugin"] in plugins + assert len(plugins) >= 2 + + def main(): test_connect_field_workflow() velocity_acceleration = conftest.resolve_test_file("velocity_acceleration.rst", "rst_operators") From 64a0f74aa27b6a882d5e1e086ab8f75084b1559c Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 6 Nov 2025 10:35:43 +0100 Subject: [PATCH 2/5] Sort the plugin names --- src/ansys/dpf/core/workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index c67515105f2..30a923be2a1 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -1059,4 +1059,4 @@ def required_plugins(self) -> list[str]: spec = dpf.core.dpf_operator.Operator.operator_specification(op_name, self._server) plugin_name = spec.properties["plugin"] out.append(plugin_name) - return list(set(out)) + return sorted(list(set(out))) From 3b686d7d4e5906b37815562ce827ef10127d71f7 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 6 Nov 2025 11:17:38 +0100 Subject: [PATCH 3/5] Update the doctest --- src/ansys/dpf/core/workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index 30a923be2a1..81712a77c4c 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -1050,7 +1050,7 @@ def required_plugins(self) -> list[str]: >>> op2 = dpf.Operator("U") # from 'core' plugin >>> wf.add_operators([op1, op2]) >>> wf.required_plugins() - ['documentation', 'core'] + ['core', 'documentation'] """ num = self._api.work_flow_number_of_operators(self) out = [] From ad108fecb82ec6ca1ee73421357fe2471342ebd7 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 6 Nov 2025 11:18:12 +0100 Subject: [PATCH 4/5] Update the doctest --- src/ansys/dpf/core/workflow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index 81712a77c4c..84f3f92bbc8 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -1039,7 +1039,7 @@ def required_plugins(self) -> list[str]: Returns ------- plugins: - List of plugins used by the workflow. + List of plugins used by the workflow ordered alphabetically. The plugin name reported is the one set when loading the plugin. Examples From 6d77cab5b61a45569eded9c417268d303618a773 Mon Sep 17 00:00:00 2001 From: PProfizi Date: Thu, 6 Nov 2025 11:23:02 +0100 Subject: [PATCH 5/5] Use an operator from a plugin available with 222 --- src/ansys/dpf/core/workflow.py | 4 ++-- tests/test_workflow.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/core/workflow.py b/src/ansys/dpf/core/workflow.py index 84f3f92bbc8..97e3214d690 100644 --- a/src/ansys/dpf/core/workflow.py +++ b/src/ansys/dpf/core/workflow.py @@ -1046,11 +1046,11 @@ def required_plugins(self) -> list[str]: -------- >>> from ansys.dpf import core as dpf >>> wf = dpf.Workflow() - >>> op1 = dpf.Operator("html_doc") # from 'documentation' plugin + >>> op1 = dpf.Operator("csv_to_field") # from 'csv' plugin >>> op2 = dpf.Operator("U") # from 'core' plugin >>> wf.add_operators([op1, op2]) >>> wf.required_plugins() - ['core', 'documentation'] + ['core', 'csv'] """ num = self._api.work_flow_number_of_operators(self) out = [] diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 68836158e9c..a051af3301a 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -1103,7 +1103,7 @@ def test_workflow_get_output_derived_class(server_type): def test_required_plugins(server_type): wf = dpf.core.Workflow(server=server_type) - op1 = dpf.core.Operator("html_doc", server=server_type) # from 'documentation' plugin + op1 = dpf.core.Operator("csv_to_field", server=server_type) # from 'csv' plugin op2 = dpf.core.Operator("U", server=server_type) # from 'core' plugin wf.add_operators([op1, op2]) plugins = wf.required_plugins()