Skip to content

refactor: add typing for workflow record function #2479

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
21 changes: 12 additions & 9 deletions src/ansys/dpf/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
server_meet_version_and_raise,
version_requires,
)
from ansys.dpf.core.server_types import AnyServerType
from ansys.dpf.gate import (
data_processing_capi,
data_processing_grpcapi,
Expand Down Expand Up @@ -624,17 +625,19 @@ def record(self, identifier="", transfer_ownership=True):
return self._api.work_flow_record_instance(self, identifier, transfer_ownership)

@staticmethod
def get_recorded_workflow(id, server=None):
def get_recorded_workflow(id: int, server: AnyServerType | None = None) -> Workflow: # noqa W0622
"""Retrieve a workflow registered (with workflow.record()).

Parameters
----------
id : int
id:
ID given by the method "record".
server:
Server from which to get the recorded workflow.

Returns
-------
workflow : core.Workflow()
workflow:
workflow registered in dpf's registry (server side)

Examples
Expand All @@ -659,13 +662,13 @@ def get_recorded_workflow(id, server=None):
return wf

@property
def info(self):
def info(self) -> dict[str, list[str]]:
"""Dictionary with the operator names and the exposed input and output names.

Returns
-------
info : dictionarry str->list str
Dictionary with ``"operator_names"``, ``"input_names"``, and ``"output_names"`` key.
info:
Dictionary with ``"operator_names"``, ``"input_names"``, and ``"output_names"`` keys.
"""
return {
"operator_names": self.operator_names,
Expand All @@ -674,7 +677,7 @@ def info(self):
}

@property
def operator_names(self):
def operator_names(self) -> list[str]:
"""List of the names of operators added in the workflow.

Returns
Expand All @@ -688,7 +691,7 @@ def operator_names(self):
return out

@property
def input_names(self):
def input_names(self) -> list[str]:
"""List of the input names exposed in the workflow with set_input_name.

Returns
Expand All @@ -702,7 +705,7 @@ def input_names(self):
return out

@property
def output_names(self):
def output_names(self) -> list[str]:
"""List of the output names exposed in the workflow with set_output_name.

Returns
Expand Down
Loading