Skip to content

Commit

Permalink
use local path if possible. Otherwise try 5 times to download
Browse files Browse the repository at this point in the history
  • Loading branch information
mariostieriansys committed Feb 4, 2025
1 parent 45b3a5c commit 7f39da5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
17 changes: 15 additions & 2 deletions tests/example_tests/test_coverage_increase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import time

from ansys.pyensight.core import DockerLauncher, LocalLauncher, launch_ensight
from ansys.pyensight.core.enscontext import EnsContext
Expand Down Expand Up @@ -298,8 +299,20 @@ def test_coverage_increase(tmpdir, pytestconfig: pytest.Config):
if not use_local:
launcher.enshell_log_contents()
assert session.ensight.objs.core.PARTS[0] != session.ensight.objs.core.PARTS[1]
cas_file = session.download_pyansys_example("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
dat_file = session.download_pyansys_example("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
counter = 0
while True and counter < 5:
try:
cas_file = session.download_pyansys_example(
"mixing_elbow.cas.h5", "pyfluent/mixing_elbow"
)
dat_file = session.download_pyansys_example(
"mixing_elbow.dat.h5", "pyfluent/mixing_elbow"
)
except Exception:
counter += 1
time.sleep(60)
if counter == 5:
raise RuntimeError("Couldn't download data from github")
session.load_data(cas_file, result_file=dat_file)
#
assert session.ensight_version_check("2021 R1")
Expand Down
16 changes: 14 additions & 2 deletions tests/example_tests/test_dvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ def test_dvs_data(tmpdir, pytestconfig: pytest.Config):
else:
launcher = DockerLauncher(data_directory=data_dir, use_dev=True)
session = launcher.start()
cas_file = session.download_pyansys_example("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
dat_file = session.download_pyansys_example("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
counter = 0
while True and counter < 5:
try:
cas_file = session.download_pyansys_example(
"mixing_elbow.cas.h5", "pyfluent/mixing_elbow"
)
dat_file = session.download_pyansys_example(
"mixing_elbow.dat.h5", "pyfluent/mixing_elbow"
)
except Exception:
counter += 1
time.sleep(60)
if counter == 5:
raise RuntimeError("Couldn't download data from github")
session.load_data(cas_file, result_file=dat_file)
dvs = None
if use_local:
Expand Down
25 changes: 22 additions & 3 deletions tests/example_tests/test_libuserd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import glob
import os
import time

from ansys.pyensight.core.libuserd import LibUserd
import numpy
Expand All @@ -16,8 +18,20 @@ def test_libuserd_basic(tmpdir, pytestconfig: pytest.Config):
_ = libuserd.get_all_readers()
_ = libuserd.ansys_release_number()
_ = libuserd.ansys_release_string()
cas_file = libuserd.download_pyansys_example("mixing_elbow.cas.h5", "pyfluent/mixing_elbow")
dat_file = libuserd.download_pyansys_example("mixing_elbow.dat.h5", "pyfluent/mixing_elbow")
counter = 0
while True and counter < 5:
try:
cas_file = libuserd.download_pyansys_example(
"mixing_elbow.cas.h5", "pyfluent/mixing_elbow"
)
dat_file = libuserd.download_pyansys_example(
"mixing_elbow.dat.h5", "pyfluent/mixing_elbow"
)
except Exception:
counter += 1
time.sleep(60)
if counter == 5:
raise RuntimeError("Couldn't download data from github")
r = libuserd.query_format(cas_file, dat_file)
d = r[0].read_dataset(cas_file, dat_file)

Expand Down Expand Up @@ -92,7 +106,12 @@ def test_libuserd_userd_case(tmpdir, pytestconfig: pytest.Config):
assert len(readers) == 1
assert readers[0].name == "USERD EnSight Case"

casedir = libuserd.download_pyansys_example("RC_Plane", "pyensight", folder=True)
if use_local:
cei_path = os.path.dirname(os.path.dirname(libuserd._server_pathname))
suffix = glob.glob(os.path.join(cei_path, "apex???"))[-1][4:]
casedir = f"{cei_path}/ensight{suffix}/data/RC_Plane/"
else:
casedir = libuserd.download_pyansys_example("RC_Plane", "pyensight", folder=True)
casefile = os.path.join(casedir, "extra300_RC_Plane_nodal.case")

readers = libuserd.query_format(casefile)
Expand Down

0 comments on commit 7f39da5

Please sign in to comment.