Skip to content

Commit 2e515b7

Browse files
Merge pull request #1620 from LOCEANlloydizard/test-fail-missing-raw-file
Change of test in test_mask.py and update conftest
2 parents 3b51955 + e461e8b commit 2e515b7

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

echopype/tests/conftest.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
"""pytest configuration with minimal Pooch fallback for CI"""
22

33
import os
4-
import pytest
54
from pathlib import Path
65

7-
if os.getenv("USE_POOCH") == "True":
8-
import pooch
6+
import pytest
7+
import pooch
8+
9+
from zipfile import ZipFile
10+
import shutil
11+
import time
912

13+
ver = os.getenv("ECHOPYPE_DATA_VERSION", "v0.11.1a2")
14+
TEST_DATA_FOLDER = Path(pooch.os_cache("echopype")) / ver
15+
16+
if os.getenv("USE_POOCH") == "True" and os.getenv("PYTEST_XDIST_WORKER") is None:
1017
# Lock to the known-good assets release (can be overridden via env if needed)
11-
ver = os.getenv("ECHOPYPE_DATA_VERSION", "v0.11.1a2")
1218
base = os.getenv(
1319
"ECHOPYPE_DATA_BASEURL",
1420
"https://github.com/OSOceanAcoustics/echopype/releases/download/{version}/",
@@ -43,11 +49,11 @@
4349
"ek60.zip": "sha256:66735de0ac584ec8a150b54b1a54024a92195f64036134ffdc9d472d7e155bb2",
4450
"ek60_calibrate_chunks.zip": "sha256:bf435b1f7fc055f51afd55c4548713ba8e1eb0e919a0d74f4b9dd5f60b7fe327",
4551
"ek60_missing_channel_power.zip": "sha256:f3851534cdc6ad3ae1d7c52a11cb279305d316d0086017a305be997d4011e20e",
46-
"ek80.zip": "sha256:1be2d6edc724e6ee79700551e8b8043017f68b9eb0f288d9ca9de225a6299ec2",
52+
"ek80.zip": "sha256:be0bab8bc18fa219098caf9d35b0186b003bc0b334897dbee75821c0388ce67e",
4753
"ek80_bb_complex_multiplex.zip": "sha256:f4b23b872378e5b3b13e5536547fcb094f0230b2b0bef4de89ab18beff6c2d3e",
4854
"ek80_bb_with_calibration.zip": "sha256:53f018b6dae051cc86180e13cb3f28848750014dfcf84d97cf2191be2b164ccb",
4955
"ek80_duplicate_ping_times.zip": "sha256:11a2dcb5cf113fa1bb03a6724524ac17bdb0db66cb018b0a3ca7cad87067f4bb",
50-
"ek80_ext.zip": "sha256:5404f2f155aee470a795bb4e370feaac3e557181229d0816842a177fc7abf076",
56+
"ek80_ext.zip": "sha256:c2caa4f4fa2d3b31d8cf1dc99ebd1db31077336d3831b68014ade320c7967413",
5157
"ek80_invalid_env_datagrams.zip": "sha256:dece27d90f30d1a13b56d99350c3254e81622af3199fda0112d3b9e1d7db270c",
5258
"ek80_missing_sound_velocity_profile.zip": "sha256:1635585026ae5c4ffdff09ca4d63aeff0b33471c5ee0e1b8a520f87469535852",
5359
"ek80_new.zip": "sha256:f799cde453762c46ad03fee178c76cd9fbb00eec92a5d1038c32f6a9479b2e57",
@@ -78,11 +84,16 @@ def _unpack(fname, action, pooch_instance):
7884
flush=True,
7985
)
8086

81-
if action in ("update", "download") or not out.exists():
82-
from zipfile import ZipFile
87+
if out.exists():
88+
for _ in range(3):
89+
try:
90+
shutil.rmtree(out)
91+
break
92+
except Exception:
93+
time.sleep(1)
8394

84-
with ZipFile(z, "r") as f:
85-
f.extractall(out)
95+
with ZipFile(z, "r") as f:
96+
f.extractall(out)
8697

8798
# flatten single nested dir if needed
8899
try:
@@ -120,8 +131,6 @@ def _unpack(fname, action, pooch_instance):
120131
print(f"[echopype-ci] fetching bundle: {b}")
121132
print(f"[echopype-ci] → URL: {url}")
122133
EP.fetch(b, processor=_unpack, progressbar=False)
123-
124-
TEST_DATA_FOLDER = Path(cache_dir) / ver
125134

126135
print(
127136
"\n[echopype-ci] TEST_DATA_FOLDER\n"

echopype/tests/mask/test_mask.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ def test_blackwell_vs_basic_close_local(ek80_path):
17761776
raw_path = ek80_path / "ncei-wcsd/SH2306/Hake-D20230811-T165727.raw"
17771777

17781778
if not raw_path.is_file():
1779-
pytest.skip(f"Missing EK80 RAW: {raw_path}")
1779+
pytest.fail(f"Missing EK80 RAW: {raw_path}")
17801780

17811781
ed = ep.open_raw(raw_path, sonar_model="EK80")
17821782
ds_Sv = ep.calibrate.compute_Sv(ed, waveform_mode="CW", encode_mode="power")
@@ -1797,6 +1797,7 @@ def test_blackwell_vs_basic_close_local(ek80_path):
17971797
ds=ds_Sv,
17981798
method="blackwell",
17991799
params={
1800+
"var_name": "Sv",
18001801
"channel": sel_channel,
18011802
"threshold": [-40, 702, 282],
18021803
"offset": 0.3,

0 commit comments

Comments
 (0)