Skip to content

Commit 466c945

Browse files
committed
feat: add WorkflowInfo typed dict
1 parent 3b2127e commit 466c945

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/ansys/dpf/core/workflow.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import os
3030
from pathlib import Path
3131
import traceback
32-
from typing import Union
32+
from typing import TypedDict, Union
3333
import warnings
3434

3535
import numpy
@@ -41,7 +41,7 @@
4141
server_meet_version_and_raise,
4242
version_requires,
4343
)
44-
from ansys.dpf.core.server_types import BaseServer
44+
from ansys.dpf.core.server_types import AnyServerType
4545
from ansys.dpf.gate import (
4646
data_processing_capi,
4747
data_processing_grpcapi,
@@ -57,6 +57,12 @@
5757
LOG.setLevel("DEBUG")
5858

5959

60+
class WorkflowInfo(TypedDict):
61+
operator_names: list[str]
62+
input_names: list[str]
63+
output_names: list[str]
64+
65+
6066
class Workflow:
6167
"""Represents a workflow.
6268
@@ -625,7 +631,7 @@ def record(self, identifier="", transfer_ownership=True):
625631
return self._api.work_flow_record_instance(self, identifier, transfer_ownership)
626632

627633
@staticmethod
628-
def get_recorded_workflow(id: int, server: BaseServer | None = None) -> Workflow:
634+
def get_recorded_workflow(id: int, server: AnyServerType | None = None) -> Workflow:
629635
"""Retrieve a workflow registered (with workflow.record()).
630636
631637
Parameters
@@ -662,19 +668,19 @@ def get_recorded_workflow(id: int, server: BaseServer | None = None) -> Workflow
662668
return wf
663669

664670
@property
665-
def info(self) -> dict[str, list[str]]:
671+
def info(self) -> WorkflowInfo:
666672
"""Dictionary with the operator names and the exposed input and output names.
667673
668674
Returns
669675
-------
670-
info : dictionary str->list str
671-
Dictionary with ``"operator_names"``, ``"input_names"``, and ``"output_names"`` key.
676+
info :
677+
Dictionary with ``"operator_names"``, ``"input_names"``, and ``"output_names"`` keys.
672678
"""
673-
return {
674-
"operator_names": self.operator_names,
675-
"input_names": self.input_names,
676-
"output_names": self.output_names,
677-
}
679+
return WorkflowInfo(
680+
operator_names=self.operator_names,
681+
input_names=self.input_names,
682+
output_names=self.output_names
683+
)
678684

679685
@property
680686
def operator_names(self) -> list[str]:

0 commit comments

Comments
 (0)