diff --git a/src/ansys/dpf/core/dpf_operator.py b/src/ansys/dpf/core/dpf_operator.py index 0780091893..c20274848d 100644 --- a/src/ansys/dpf/core/dpf_operator.py +++ b/src/ansys/dpf/core/dpf_operator.py @@ -127,6 +127,7 @@ def __init__(self, name=None, config=None, server=None, operator=None): self._internal_obj = None self._description = None self._inputs = None + self._id = None # step 1: get server self._server = server_module.get_or_create_server( @@ -661,6 +662,30 @@ def config(self, value): """ self._api.operator_set_config(self, value) + @property + @version_requires("10.0") + def id(self) -> int: + """Retrieve the unique identifier of the operator. + + This property returns the unique ID associated with the operator. + This property is lazily initialized. + + Returns + ------- + int + The unique identifier of the operator. + + Notes + ----- + Property available with server's version starting at 10.0. + """ + if self._id is None: + operator_id_op = Operator("operator_id", server=self._server) + operator_id_op.connect_operator_as_input(0, self) + self._id = operator_id_op.outputs.id() + + return self._id + @property def inputs(self): """Inputs connected to the operator. diff --git a/tests/test_operator.py b/tests/test_operator.py index 55e59c177d..64294c37e7 100644 --- a/tests/test_operator.py +++ b/tests/test_operator.py @@ -1483,3 +1483,16 @@ class TestContainer2(CustomContainerBase): record_derived_class(class_name, TestContainer2, overwrite=True) assert derived_classes[class_name] is TestContainer2 + + +@conftest.raises_for_servers_version_under("10.0") +def test_operator_id(server_type): + ids = set() + + for _ in range(10): + op = ops.utility.forward(server=server_type) + + assert op.id >= 0 + assert op.id not in ids + + ids.add(op.id)