Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions src/ansys/dpf/core/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
data_tree,
custom_type_field,
collection,
workflow,
)

if issubclass(obj, int):
Expand Down Expand Up @@ -185,6 +186,11 @@
self._api.any_new_from_any_collection,
self._api.any_get_as_any_collection,
)
elif issubclass(obj, workflow.Workflow):
return (

Check warning on line 190 in src/ansys/dpf/core/any.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/any.py#L189-L190

Added lines #L189 - L190 were not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbellot000 is it normal for it to say it is not covered by testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum no but I don't see it

self._api.any_new_from_workflow,
self._api.any_get_as_workflow,
)
elif issubclass(obj, dpf_vector.DPFVectorInt):
return (
self._api.any_new_from_int_collection,
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def has_local_server():
return dpf.core.SERVER is not None


def _global_server():
def _global_server() -> BaseServer:
"""Retrieve the global server if it exists.

If the global server has not been specified, check the expected server type in
Expand Down
10 changes: 10 additions & 0 deletions src/ansys/dpf/gate/any_grpcapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def _type_to_message_type():
data_tree,
custom_type_field,
collection_base,
workflow,
)

return [(int, base_pb2.Type.INT),
Expand All @@ -54,6 +55,7 @@ def _type_to_message_type():
(generic_data_container.GenericDataContainer, base_pb2.Type.GENERIC_DATA_CONTAINER),
(scoping.Scoping, base_pb2.Type.SCOPING),
(data_tree.DataTree, base_pb2.Type.DATA_TREE),
(workflow.Workflow, base_pb2.Type.WORKFLOW),
(collection_base.CollectionBase, base_pb2.Type.COLLECTION, base_pb2.Type.ANY),
(dpf_vector.DPFVectorInt, base_pb2.Type.COLLECTION, base_pb2.Type.INT),
]
Expand Down Expand Up @@ -139,6 +141,10 @@ def any_get_as_any_collection(any):
def any_get_as_int_collection(any):
return AnyGRPCAPI._get_as(any).collection

@staticmethod
def any_get_as_workflow(any):
return AnyGRPCAPI._get_as(any).workflow

@staticmethod
def _new_from(any, client=None):
from ansys.grpc.dpf import dpf_any_pb2
Expand Down Expand Up @@ -220,3 +226,7 @@ def any_new_from_scoping(any):
@staticmethod
def any_new_from_data_tree(any):
return AnyGRPCAPI._new_from(any, any._server)

@staticmethod
def any_new_from_workflow(any):
return AnyGRPCAPI._new_from(any, any._server)
12 changes: 12 additions & 0 deletions tests/test_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,15 @@ def test_cast_scoping_any(server_type):
new_entity = any_dpf.cast()

assert entity.location == new_entity.location


@pytest.mark.skipif(
not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0,
reason="for_each not implemented below 8.0",
)
def test_cast_workflow_any(server_type):
entity = dpf.Workflow(server=server_type)
any_dpf = dpf.Any.new_from(entity)
new_entity = any_dpf.cast()

assert new_entity.input_names == []
Loading