Skip to content

Commit 26e9b97

Browse files
default to 251 install. Fix test, and add option to download using docker cli
1 parent 19331bb commit 26e9b97

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/ansys/pyensight/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
66

77
VERSION = __version__
8-
DEFAULT_ANSYS_VERSION = "242"
8+
DEFAULT_ANSYS_VERSION = "251"
99

1010
# Ansys version number that this release is associated with
1111
__ansys_version__ = DEFAULT_ANSYS_VERSION

src/ansys/pyensight/core/dvs.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
to send data from the clients to the servers.
66
"""
77
import glob
8+
import io
89
import logging
910
import os
1011
import pathlib
1112
import platform
1213
import re
1314
import sys
15+
import tarfile
1416
import tempfile
1517
import threading
1618
import time
@@ -19,7 +21,7 @@
1921
import warnings
2022

2123
from ansys.api.pyensight.dvs_api import dvs_base
22-
from ansys.pyensight.core import LocalLauncher
24+
from ansys.pyensight.core import DockerLauncher, LocalLauncher
2325
import numpy
2426

2527
if TYPE_CHECKING:
@@ -767,11 +769,23 @@ def delete_item_on_clients(self, update_num, filter=""):
767769
client = self._clients[c]
768770
_ = self.delete_item(client["client_id"], update_num, client["rank"], filter)
769771

770-
def get_dvs_data_from_container(self, destination: str):
772+
def get_dvs_data_from_container(self, destination: str, use_docker=False):
771773
"""Utility to save the data from the container to a local destination.
772774
773775
destination: str
774776
the folder where to copy the files to
777+
use_docker: bool
778+
if True, download is done using the docker CLI
775779
"""
780+
if not isinstance(self._session._launcher, DockerLauncher):
781+
raise RuntimeError("Method only available for DockerLauncher instances.")
782+
if not os.path.exists(destination):
783+
os.makedirs(destination)
776784
posix_uri = pathlib.Path(destination).as_uri()
777-
self._session.copy_from_session(posix_uri, ["dvs_cache"])
785+
if use_docker:
786+
bits, stat = self._session._launcher._container.get_archive(self._cache_folder)
787+
with tarfile.open(fileobj=io.BytesIO(b"".join(bits)), mode="r") as tar:
788+
tar.extractall(path=destination)
789+
os.remove(bits)
790+
else:
791+
self._session.copy_from_session(posix_uri, ["dvs_cache"])

tests/example_tests/test_dvs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_dvs_data(tmpdir, pytestconfig: pytest.Config):
115115
dvs.end_updates()
116116
dvs.load_dataset_in_ensight()
117117
assert len(session.ensight.objs.core.PARTS) == 1
118-
if hasattr(launcher, "_install_path"):
118+
if not use_local:
119119
push_dir = tmpdir.mkdir("newdir")
120120
dvs.get_dvs_data_from_container(push_dir)
121121
assert os.path.isdir(os.path.join(push_dir, "dvs_cache"))

0 commit comments

Comments
 (0)