|
5 | 5 | to send data from the clients to the servers.
|
6 | 6 | """
|
7 | 7 | import glob
|
| 8 | +import io |
8 | 9 | import logging
|
9 | 10 | import os
|
10 | 11 | import pathlib
|
11 | 12 | import platform
|
12 | 13 | import re
|
13 | 14 | import sys
|
| 15 | +import tarfile |
14 | 16 | import tempfile
|
15 | 17 | import threading
|
16 | 18 | import time
|
|
19 | 21 | import warnings
|
20 | 22 |
|
21 | 23 | from ansys.api.pyensight.dvs_api import dvs_base
|
22 |
| -from ansys.pyensight.core import LocalLauncher |
| 24 | +from ansys.pyensight.core import DockerLauncher, LocalLauncher |
23 | 25 | import numpy
|
24 | 26 |
|
25 | 27 | if TYPE_CHECKING:
|
@@ -767,11 +769,23 @@ def delete_item_on_clients(self, update_num, filter=""):
|
767 | 769 | client = self._clients[c]
|
768 | 770 | _ = self.delete_item(client["client_id"], update_num, client["rank"], filter)
|
769 | 771 |
|
770 |
| - def get_dvs_data_from_container(self, destination: str): |
| 772 | + def get_dvs_data_from_container(self, destination: str, use_docker=False): |
771 | 773 | """Utility to save the data from the container to a local destination.
|
772 | 774 |
|
773 | 775 | destination: str
|
774 | 776 | the folder where to copy the files to
|
| 777 | + use_docker: bool |
| 778 | + if True, download is done using the docker CLI |
775 | 779 | """
|
| 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) |
776 | 784 | 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"]) |
0 commit comments