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
5 changes: 4 additions & 1 deletion src/ansys/dpf/core/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class DataSources:
Server with the channel connected to the remote or local instance. The
default is ``None``, in which case an attempt is made to use the global
server.
key:
Explicit key to associate to the result file given as ``result_path``.

Examples
--------
Expand All @@ -85,6 +87,7 @@ def __init__(
result_path: Union[str, os.PathLike] = None,
data_sources: Union[dpf.DataSources, int, data_sources_pb2.DataSources] = None,
server: AnyServerType = None,
key: str = "",
):
"""Initialize a connection with the server."""
# step 1: get server
Expand Down Expand Up @@ -127,7 +130,7 @@ def __init__(
self._internal_obj = self._api.data_sources_new("data_sources")

if result_path is not None:
self.set_result_file_path(result_path)
self.set_result_file_path(result_path, key=key)

def set_result_file_path(
self,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_create_data_sources(server_type):
def test_create_with_resultpath_data_sources(allkindofcomplexity, server_type):
data_sources = dpf.core.DataSources(allkindofcomplexity, server=server_type)
assert data_sources._internal_obj
assert data_sources.result_key == "rst"
data_sources = dpf.core.DataSources(allkindofcomplexity, server=server_type, key="test")
assert data_sources.result_key == "test"


def test_setresultpath_data_sources(allkindofcomplexity, server_type):
Expand Down