File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -1032,3 +1032,31 @@ def __str__(self):
10321032 from ansys .dpf .core .core import _description
10331033
10341034 return _description (self ._internal_obj , self ._server )
1035+
1036+ def required_plugins (self ) -> list [str ]:
1037+ """List of plugins required by the workflow based on registered operators.
1038+
1039+ Returns
1040+ -------
1041+ plugins:
1042+ List of plugins used by the workflow.
1043+ The plugin name reported is the one set when loading the plugin.
1044+
1045+ Examples
1046+ --------
1047+ >>> from ansys.dpf import core as dpf
1048+ >>> wf = dpf.Workflow()
1049+ >>> op1 = dpf.Operator("html_doc") # from 'documentation' plugin
1050+ >>> op2 = dpf.Operator("U") # from 'core' plugin
1051+ >>> wf.add_operators([op1, op2])
1052+ >>> wf.required_plugins()
1053+ ['documentation', 'core']
1054+ """
1055+ num = self ._api .work_flow_number_of_operators (self )
1056+ out = []
1057+ for i in range (num ):
1058+ op_name = self ._api .work_flow_operator_name_by_index (self , i )
1059+ spec = dpf .core .dpf_operator .Operator .operator_specification (op_name , self ._server )
1060+ plugin_name = spec .properties ["plugin" ]
1061+ out .append (plugin_name )
1062+ return list (set (out ))
Original file line number Diff line number Diff line change @@ -1101,6 +1101,18 @@ def test_workflow_get_output_derived_class(server_type):
11011101 assert workflow_topology
11021102
11031103
1104+ def test_required_plugins (server_type ):
1105+ wf = dpf .core .Workflow (server = server_type )
1106+ op1 = dpf .core .Operator ("html_doc" , server = server_type ) # from 'documentation' plugin
1107+ op2 = dpf .core .Operator ("U" , server = server_type ) # from 'core' plugin
1108+ wf .add_operators ([op1 , op2 ])
1109+ plugins = wf .required_plugins ()
1110+ assert isinstance (plugins , list )
1111+ assert op1 .specification .properties ["plugin" ] in plugins
1112+ assert op2 .specification .properties ["plugin" ] in plugins
1113+ assert len (plugins ) >= 2
1114+
1115+
11041116def main ():
11051117 test_connect_field_workflow ()
11061118 velocity_acceleration = conftest .resolve_test_file ("velocity_acceleration.rst" , "rst_operators" )
You can’t perform that action at this time.
0 commit comments