Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 25 additions & 15 deletions src/ansys/dpf/core/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import os
from pathlib import Path
import traceback
from typing import Union
from typing import TypedDict, Union
import warnings

import numpy
Expand All @@ -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 All @@ -56,6 +57,13 @@
LOG.setLevel("DEBUG")


class WorkflowInfo(TypedDict):
"""Names of the workflow's operators, inputs and outputs."""
operator_names: list[str]
input_names: list[str]
output_names: list[str]


class Workflow:
"""Represents a workflow.

Expand Down Expand Up @@ -624,17 +632,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:
"""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,22 +669,22 @@ def get_recorded_workflow(id, server=None):
return wf

@property
def info(self):
def info(self) -> WorkflowInfo:
"""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,
"input_names": self.input_names,
"output_names": self.output_names,
}
return WorkflowInfo(
operator_names=self.operator_names,
input_names=self.input_names,
output_names=self.output_names
)

@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 +698,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 +712,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