|
1 | 1 | """pytest configuration with minimal Pooch fallback for CI""" |
2 | 2 |
|
3 | 3 | import os |
4 | | -import pytest |
5 | 4 | from pathlib import Path |
6 | 5 |
|
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 |
9 | 12 |
|
| 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: |
10 | 17 | # Lock to the known-good assets release (can be overridden via env if needed) |
11 | | - ver = os.getenv("ECHOPYPE_DATA_VERSION", "v0.11.1a2") |
12 | 18 | base = os.getenv( |
13 | 19 | "ECHOPYPE_DATA_BASEURL", |
14 | 20 | "https://github.com/OSOceanAcoustics/echopype/releases/download/{version}/", |
|
43 | 49 | "ek60.zip": "sha256:66735de0ac584ec8a150b54b1a54024a92195f64036134ffdc9d472d7e155bb2", |
44 | 50 | "ek60_calibrate_chunks.zip": "sha256:bf435b1f7fc055f51afd55c4548713ba8e1eb0e919a0d74f4b9dd5f60b7fe327", |
45 | 51 | "ek60_missing_channel_power.zip": "sha256:f3851534cdc6ad3ae1d7c52a11cb279305d316d0086017a305be997d4011e20e", |
46 | | - "ek80.zip": "sha256:1be2d6edc724e6ee79700551e8b8043017f68b9eb0f288d9ca9de225a6299ec2", |
| 52 | + "ek80.zip": "sha256:be0bab8bc18fa219098caf9d35b0186b003bc0b334897dbee75821c0388ce67e", |
47 | 53 | "ek80_bb_complex_multiplex.zip": "sha256:f4b23b872378e5b3b13e5536547fcb094f0230b2b0bef4de89ab18beff6c2d3e", |
48 | 54 | "ek80_bb_with_calibration.zip": "sha256:53f018b6dae051cc86180e13cb3f28848750014dfcf84d97cf2191be2b164ccb", |
49 | 55 | "ek80_duplicate_ping_times.zip": "sha256:11a2dcb5cf113fa1bb03a6724524ac17bdb0db66cb018b0a3ca7cad87067f4bb", |
50 | | - "ek80_ext.zip": "sha256:5404f2f155aee470a795bb4e370feaac3e557181229d0816842a177fc7abf076", |
| 56 | + "ek80_ext.zip": "sha256:c2caa4f4fa2d3b31d8cf1dc99ebd1db31077336d3831b68014ade320c7967413", |
51 | 57 | "ek80_invalid_env_datagrams.zip": "sha256:dece27d90f30d1a13b56d99350c3254e81622af3199fda0112d3b9e1d7db270c", |
52 | 58 | "ek80_missing_sound_velocity_profile.zip": "sha256:1635585026ae5c4ffdff09ca4d63aeff0b33471c5ee0e1b8a520f87469535852", |
53 | 59 | "ek80_new.zip": "sha256:f799cde453762c46ad03fee178c76cd9fbb00eec92a5d1038c32f6a9479b2e57", |
@@ -78,11 +84,16 @@ def _unpack(fname, action, pooch_instance): |
78 | 84 | flush=True, |
79 | 85 | ) |
80 | 86 |
|
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) |
83 | 94 |
|
84 | | - with ZipFile(z, "r") as f: |
85 | | - f.extractall(out) |
| 95 | + with ZipFile(z, "r") as f: |
| 96 | + f.extractall(out) |
86 | 97 |
|
87 | 98 | # flatten single nested dir if needed |
88 | 99 | try: |
@@ -120,8 +131,6 @@ def _unpack(fname, action, pooch_instance): |
120 | 131 | print(f"[echopype-ci] fetching bundle: {b}") |
121 | 132 | print(f"[echopype-ci] → URL: {url}") |
122 | 133 | EP.fetch(b, processor=_unpack, progressbar=False) |
123 | | - |
124 | | - TEST_DATA_FOLDER = Path(cache_dir) / ver |
125 | 134 |
|
126 | 135 | print( |
127 | 136 | "\n[echopype-ci] TEST_DATA_FOLDER\n" |
|
0 commit comments