Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add WorkflowTopology class and workflow_to_workflow_topology operator #1902

Merged
merged 24 commits into from
Dec 11, 2024

Conversation

Matteo-Baussart-ANSYS
Copy link
Collaborator

@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS commented Nov 15, 2024

This adds the PyDPF support of the WorkflowData class and workflow_to_workflow_topology operator,

@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS self-assigned this Nov 15, 2024
@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS changed the title feat: add WorkflowData class and workflow_to_workflow_data operator feat: add WorkflowTopology class and workflow_to_workflow_topology operator Nov 18, 2024
Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.40%. Comparing base (7b33c37) to head (1399247).
Report is 21 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1902      +/-   ##
==========================================
+ Coverage   86.62%   88.40%   +1.77%     
==========================================
  Files          83       89       +6     
  Lines        9973    10225     +252     
==========================================
+ Hits         8639     9039     +400     
+ Misses       1334     1186     -148     

@@ -481,6 +482,11 @@ def _type_to_output_method(self):
self._api.operator_getoutput_as_any,
lambda obj, type: any.Any(server=self._server, any_dpf=obj).cast(type),
),
(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Matteo-Baussart-ANSYS can a Workflow also potentially take in or output a WorkflowTopology object?
Can an operator take a WorkflowTopology as input?

Copy link
Collaborator Author

@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WorkflowTopology can be the output for an Operator and from a Workflow. Following syntaxes are tested:

# For operator outputs
workflow_to_workflow_topology_op.outputs.workflow_topology()
workflow_to_workflow_topology_op.get_output(0, WorkflowTopology)
# For workflow outputs
workflow_topology = dpf_workflow_wrapper.get_output("output", WorkflowTopology)

As for inputs, there is currently no operator requiring a CustomContainerBase as input.

@@ -48,3 +48,19 @@ def _sort_supported_kwargs(bound_method, **kwargs):
warnings.warn(txt)
# Return the accepted arguments
return kwargs_in


def indent(text, subsequent_indent="", initial_indent=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Matteo-Baussart-ANSYS this will need a docstring with description and parameters. Also typehinting?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added docstring and typehinting

@@ -953,6 +953,15 @@ def to_graphviz(self, path: Union[os.PathLike, str]):
"""Saves the workflow to a GraphViz file."""
return self._api.work_flow_export_graphviz(self, str(path))

def get_topology(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Matteo-Baussart-ANSYS same, missing a docstring and typehinting

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added docstring and typehinting

# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a title, reference tag and description. You can find examples of that being done in other modules.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added titles and descriptions

from ansys.dpf.core.custom_container_base import CustomContainerBase


class DataConnection(CustomContainerBase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Matteo-Baussart-ANSYS again, missing docstrings and typehinting everywhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added docstrings and typehinting

Copy link
Contributor

@PProfizi PProfizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some specific questions, but a general request is to add docstrings, module headers, typehinting, and improve coverage.

_derived_class_name_to_type = None


def derived_class_name_to_type():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a docstring here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a docstring and typehints

not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0,
reason="Operator `workflow_to_workflow_topology` does not exist below 10.0",
)
def test_workflow_get_topology(workflow):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for this test, could you please replace
@pytest.mark.skipif(
not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, by the decorator defined in conftest that checks that the error message would be meaningful if a use with a lower version uses get_topology

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the decorator @raises_for_servers_version_under("10.0"), and added a raise DpfVersionNotSupported("10.0") in Workflow.get_topology().

@cbellot000 cbellot000 requested a review from PProfizi December 11, 2024 07:02
@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS merged commit d2063fe into master Dec 11, 2024
46 checks passed
@Matteo-Baussart-ANSYS Matteo-Baussart-ANSYS deleted the mbaussar/feat/workflow_data branch December 11, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants