diff --git a/src/ansys/dpf/core/data_sources.py b/src/ansys/dpf/core/data_sources.py index 847fad95cbc..42e28648007 100644 --- a/src/ansys/dpf/core/data_sources.py +++ b/src/ansys/dpf/core/data_sources.py @@ -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 -------- @@ -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 @@ -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, diff --git a/tests/test_datasources.py b/tests/test_datasources.py index 577aeac2cd0..e1719ac87e4 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -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):