-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add WorkflowTopology class and workflow_to_workflow_topology operator #1902
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
Changes from 19 commits
feded14
4ff8c4e
f8467b6
2078cd0
46c79f8
9880d99
87aacb8
4dfcee5
2bc8fcd
0e59baf
09abcd7
5962788
f9ff71e
529909b
0d8d7fc
2ba8475
da60366
0b7522d
71f35ae
6052034
5a026b3
c047105
9e28ee6
1399247
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright (C) 2020 - 2024 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # 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. | ||
|
|
||
| """ | ||
| CustomContainerBase | ||
| =================== | ||
| This module contains the `CustomContainerBase` class, which serves as a base | ||
| for creating wrappers around `GenericDataContainer` objects. | ||
|
|
||
| These wrappers provide an interface for accessing and managing data in | ||
| generic containers, enabling more intuitive usage and the addition of custom | ||
| behaviors tailored to specific use cases. | ||
| """ | ||
|
|
||
| from ansys.dpf.core.generic_data_container import GenericDataContainer | ||
|
|
||
|
|
||
| class CustomContainerBase: | ||
| """ | ||
| Base class for custom container wrappers. | ||
|
|
||
| This class provides a common interface for managing an underlying | ||
| `GenericDataContainer` object. | ||
| """ | ||
|
|
||
| def __init__(self, container: GenericDataContainer) -> None: | ||
| """ | ||
| Initialize the base container with a `GenericDataContainer`. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| container : GenericDataContainer | ||
| The underlying data container to be wrapped by this class. | ||
| """ | ||
| self._container = container | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,6 +384,7 @@ def _type_to_output_method(self): | |
| mesh_info, | ||
| collection_base, | ||
| any, | ||
| custom_container_base, | ||
| ) | ||
|
|
||
| out = [ | ||
|
|
@@ -481,6 +482,15 @@ 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), | ||
| ), | ||
| ( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| custom_container_base.CustomContainerBase, | ||
| self._api.operator_getoutput_generic_data_container, | ||
| lambda obj, type: type( | ||
| container=generic_data_container.GenericDataContainer( | ||
| generic_data_container=obj, server=self._server | ||
| ) | ||
| ), | ||
| ), | ||
| ] | ||
| if hasattr(self._api, "operator_getoutput_generic_data_container"): | ||
| out.append( | ||
|
|
@@ -726,8 +736,10 @@ def default_config(name, server=None): | |
|
|
||
| def __del__(self): | ||
| try: | ||
| if self._internal_obj is not None: | ||
| self._deleter_func[0](self._deleter_func[1](self)) | ||
| if hasattr(self, "_deleter_func"): | ||
| obj = self._deleter_func[1](self) | ||
| if obj is not None: | ||
| self._deleter_func[0](obj) | ||
| except: | ||
| warnings.warn(traceback.format_exc()) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ | |
| from typing import Union | ||
|
|
||
| from ansys import dpf | ||
| from ansys.dpf.core import dpf_operator, inputs, outputs | ||
| from ansys.dpf.core import dpf_operator, errors, inputs, outputs | ||
| from ansys.dpf.core.check_version import ( | ||
| server_meet_version, | ||
| version_requires, | ||
|
|
@@ -333,6 +333,7 @@ | |
| collection_base, | ||
| streams_container, | ||
| ) | ||
| from ansys.dpf.core.custom_container_base import CustomContainerBase | ||
|
|
||
| out = [ | ||
| (streams_container.StreamsContainer, self._api.work_flow_getoutput_streams), | ||
|
|
@@ -421,6 +422,15 @@ | |
| self._api.work_flow_getoutput_as_any, | ||
| lambda obj, type: any.Any(server=self._server, any_dpf=obj).cast(type), | ||
| ), | ||
| ( | ||
| CustomContainerBase, | ||
| self._api.work_flow_getoutput_generic_data_container, | ||
| lambda obj, type: type( | ||
| container=generic_data_container.GenericDataContainer( | ||
| generic_data_container=obj, server=self._server | ||
| ) | ||
| ), | ||
| ), | ||
| ] | ||
| if hasattr(self._api, "work_flow_connect_generic_data_container"): | ||
| out.append( | ||
|
|
@@ -953,6 +963,27 @@ | |
| """Saves the workflow to a GraphViz file.""" | ||
| return self._api.work_flow_export_graphviz(self, str(path)) | ||
|
|
||
| def get_topology(self): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Matteo-Baussart-ANSYS same, missing a docstring and typehinting
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added docstring and typehinting |
||
| """Get the topology of the workflow. | ||
|
|
||
| Returns | ||
| ------- | ||
| workflow_topology : workflow_topology.WorkflowTopology | ||
|
|
||
| Notes | ||
| ----- | ||
| Available from 10.0 server version. | ||
| """ | ||
| if not self._server.meet_version("10.0"): | ||
| raise errors.DpfVersionNotSupported("10.0") | ||
| workflow_to_workflow_topology_op = dpf_operator.Operator( | ||
| "workflow_to_workflow_topology", server=self._server | ||
| ) | ||
| workflow_to_workflow_topology_op.inputs.workflow.connect(self) | ||
| workflow_topology = workflow_to_workflow_topology_op.outputs.workflow_topology() | ||
|
|
||
| return workflow_topology | ||
|
|
||
| def __del__(self): | ||
| try: | ||
| if hasattr(self, "_internal_obj"): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Copyright (C) 2020 - 2024 ANSYS, Inc. and/or its affiliates. | ||
| # SPDX-License-Identifier: MIT | ||
| # | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in all | ||
| # copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # 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. | ||
|
|
||
| from .workflow_topology import WorkflowTopology | ||
| from .operator_connection import OperatorConnection | ||
| from .data_connection import DataConnection | ||
| from .exposed_pin import ExposedPin |
Uh oh!
There was an error while loading. Please reload this page.