Skip to content

Commit ad5fe42

Browse files
PProfizimoe-ad
andauthored
feat(datasources): add the key argument to DataSources() (#2839)
Co-authored-by: Muhammed Adedigba <[email protected]>
1 parent acb7d20 commit ad5fe42

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ansys/dpf/core/data_sources.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class DataSources:
6666
Server with the channel connected to the remote or local instance. The
6767
default is ``None``, in which case an attempt is made to use the global
6868
server.
69+
key:
70+
Explicit key to associate to the result file given as ``result_path``.
6971
7072
Examples
7173
--------
@@ -85,6 +87,7 @@ def __init__(
8587
result_path: Union[str, os.PathLike] = None,
8688
data_sources: Union[dpf.DataSources, int, data_sources_pb2.DataSources] = None,
8789
server: AnyServerType = None,
90+
key: str = "",
8891
):
8992
"""Initialize a connection with the server."""
9093
# step 1: get server
@@ -127,7 +130,7 @@ def __init__(
127130
self._internal_obj = self._api.data_sources_new("data_sources")
128131

129132
if result_path is not None:
130-
self.set_result_file_path(result_path)
133+
self.set_result_file_path(result_path, key=key)
131134

132135
def set_result_file_path(
133136
self,

tests/test_datasources.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def test_create_data_sources(server_type):
3939
def test_create_with_resultpath_data_sources(allkindofcomplexity, server_type):
4040
data_sources = dpf.core.DataSources(allkindofcomplexity, server=server_type)
4141
assert data_sources._internal_obj
42+
assert data_sources.result_key == "rst"
43+
data_sources = dpf.core.DataSources(allkindofcomplexity, server=server_type, key="test")
44+
assert data_sources.result_key == "test"
4245

4346

4447
def test_setresultpath_data_sources(allkindofcomplexity, server_type):

0 commit comments

Comments
 (0)