From 6455f7942a2ccdb0d6a85aee43943bfd4eb4393e Mon Sep 17 00:00:00 2001 From: Paul Profizi <100710998+PProfizi@users.noreply.github.com> Date: Fri, 12 Dec 2025 17:48:08 +0100 Subject: [PATCH 1/3] feat(datasources): add the key argument to DataSources() --- src/ansys/dpf/core/data_sources.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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, From 57a70fda69e083f1935e7add475546e249217646 Mon Sep 17 00:00:00 2001 From: Paul Profizi <100710998+PProfizi@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:24:31 +0100 Subject: [PATCH 2/3] Add a test --- tests/test_datasources.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_datasources.py b/tests/test_datasources.py index 577aeac2cd0..483a417be7d 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -39,6 +39,10 @@ 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): From 20c27f447fc97d6e4cae84f9d9f5f8e9d89082b3 Mon Sep 17 00:00:00 2001 From: Paul Profizi <100710998+PProfizi@users.noreply.github.com> Date: Mon, 15 Dec 2025 10:33:22 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- tests/test_datasources.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_datasources.py b/tests/test_datasources.py index 483a417be7d..e1719ac87e4 100644 --- a/tests/test_datasources.py +++ b/tests/test_datasources.py @@ -42,7 +42,6 @@ def test_create_with_resultpath_data_sources(allkindofcomplexity, server_type): 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):