Skip to content

Commit

Permalink
Add DataSources.add_domain_file_path (#1475)
Browse files Browse the repository at this point in the history
* Add DataSources.add_domain_file_path

Signed-off-by: paul.profizi <[email protected]>

* Add test_add_domain_file_path_data_sources

Signed-off-by: paul.profizi <[email protected]>

---------

Signed-off-by: paul.profizi <[email protected]>
  • Loading branch information
PProfizi authored Mar 22, 2024
1 parent 6a803b5 commit e4675cc
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ansys/dpf/core/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,36 @@ def add_file_path(self, filepath, key="", is_domain: bool = False, domain_id=0):
else:
self._api.data_sources_add_file_path_with_key_utf8(self, str(filepath), key)

def add_domain_file_path(self, filepath, key, domain_id):
"""Add a file path to the data sources.
Files not added as result files are accessory files, which contain accessory
information not present in the result files.
Parameters
----------
filepath:
Path of the file.
key:
Extension of the file, which is used as a key for choosing the correct
plugin when a result is requested by an operator.
domain_id:
Domain ID for the distributed files.
Examples
--------
>>> from ansys.dpf import core as dpf
>>> data_sources = dpf.DataSources()
>>> data_sources.add_domain_file_path('/tmp/ds.dat', "dat", 1)
"""
# The filename needs to be a fully qualified file name
if not os.path.dirname(filepath):
# append local path
filepath = os.path.join(os.getcwd(), os.path.basename(filepath))
self._api.data_sources_add_domain_file_path_with_key_utf8(
self, str(filepath), key, domain_id
)

def add_file_path_for_specified_result(self, filepath, key="", result_key=""):
"""Add a file path for a specified result file key to the data sources.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def test_addpath_data_sources(allkindofcomplexity, server_type):
data_sources.add_file_path(allkindofcomplexity)


def test_add_domain_file_path_data_sources(allkindofcomplexity, server_type):
data_sources = dpf.core.DataSources(server=server_type)
data_sources.add_domain_file_path(allkindofcomplexity, "rst", 1)


def test_adddomainpath_data_sources(allkindofcomplexity, server_type):
data_sources = dpf.core.DataSources(server=server_type)
data_sources.add_file_path(allkindofcomplexity, "rst", is_domain=True, domain_id=1)
Expand Down

0 comments on commit e4675cc

Please sign in to comment.