Skip to content

Commit

Permalink
default to 251 install. Fix test, and add option to download using do…
Browse files Browse the repository at this point in the history
…cker cli
  • Loading branch information
mariostieriansys committed Jan 8, 2025
1 parent 19331bb commit 26e9b97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ansys/pyensight/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__version__ = importlib_metadata.version(__name__.replace(".", "-"))

VERSION = __version__
DEFAULT_ANSYS_VERSION = "242"
DEFAULT_ANSYS_VERSION = "251"

# Ansys version number that this release is associated with
__ansys_version__ = DEFAULT_ANSYS_VERSION
Expand Down
20 changes: 17 additions & 3 deletions src/ansys/pyensight/core/dvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
to send data from the clients to the servers.
"""
import glob
import io
import logging
import os
import pathlib
import platform
import re
import sys
import tarfile
import tempfile
import threading
import time
Expand All @@ -19,7 +21,7 @@
import warnings

from ansys.api.pyensight.dvs_api import dvs_base
from ansys.pyensight.core import LocalLauncher
from ansys.pyensight.core import DockerLauncher, LocalLauncher
import numpy

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

def get_dvs_data_from_container(self, destination: str):
def get_dvs_data_from_container(self, destination: str, use_docker=False):
"""Utility to save the data from the container to a local destination.
destination: str
the folder where to copy the files to
use_docker: bool
if True, download is done using the docker CLI
"""
if not isinstance(self._session._launcher, DockerLauncher):
raise RuntimeError("Method only available for DockerLauncher instances.")
if not os.path.exists(destination):
os.makedirs(destination)
posix_uri = pathlib.Path(destination).as_uri()
self._session.copy_from_session(posix_uri, ["dvs_cache"])
if use_docker:
bits, stat = self._session._launcher._container.get_archive(self._cache_folder)
with tarfile.open(fileobj=io.BytesIO(b"".join(bits)), mode="r") as tar:
tar.extractall(path=destination)
os.remove(bits)
else:
self._session.copy_from_session(posix_uri, ["dvs_cache"])
2 changes: 1 addition & 1 deletion tests/example_tests/test_dvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_dvs_data(tmpdir, pytestconfig: pytest.Config):
dvs.end_updates()
dvs.load_dataset_in_ensight()
assert len(session.ensight.objs.core.PARTS) == 1
if hasattr(launcher, "_install_path"):
if not use_local:
push_dir = tmpdir.mkdir("newdir")
dvs.get_dvs_data_from_container(push_dir)
assert os.path.isdir(os.path.join(push_dir, "dvs_cache"))
Expand Down

0 comments on commit 26e9b97

Please sign in to comment.