Skip to content

Commit 1b201a2

Browse files
committed
improve test download script
1 parent fda76e2 commit 1b201a2

File tree

5 files changed

+46
-23
lines changed

5 files changed

+46
-23
lines changed

.github/workflows/gpu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
pip install pytest pytest-cov
4040
python setup.py develop
4141
42+
- name: Setup test data
43+
run: |
44+
python setup_tests.py
45+
4246
- name: GPU Tests
4347
run: |
4448
pytest -v -m "gpu" tests/

.github/workflows/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: [ubuntu-20.04, windows-latest, macos-12]
16+
os: [ubuntu-20.04, windows-latest, macos-13]
1717

1818
steps:
1919
- uses: actions/checkout@v3
@@ -35,7 +35,7 @@ jobs:
3535
choco install ffmpeg
3636
3737
- name: Install FFMPEG (macOS)
38-
if: matrix.os == 'macos-12'
38+
if: matrix.os == 'macos-13'
3939
run: |
4040
brew install ffmpeg
4141
@@ -55,6 +55,10 @@ jobs:
5555
pip install pytest pytest-cov
5656
python setup.py develop
5757
58+
- name: Setup test data
59+
run: |
60+
python setup_tests.py
61+
5862
- name: Run CPU tests
5963
run: |
6064
pytest -v -m "not gpu" tests/

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ pytorch_lightning==1.6.5
1717
ruff>=0.1.0
1818
pre-commit>=2.20.0,<3.0.0
1919
setuptools
20+
gdown

reset_venv.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ uv pip install pytest pytest-cov
2626
echo "Installing package in editable mode..."
2727
uv pip install -e .
2828

29+
# Setup test data
30+
echo "Setting up test data..."
31+
python setup_tests.py
32+
2933
# Run tests
3034
echo "Running tests..."
3135
pytest -v tests/

setup_tests.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,39 +38,49 @@ def download_file(url, destination):
3838

3939
def setup_tests():
4040
"""Sets up the testing environment for DeepEthogram."""
41-
42-
# Create tests/DATA directory if it doesn't exist
43-
tests_dir = Path("tests")
44-
data_dir = tests_dir / "DATA"
45-
data_dir.mkdir(parents=True, exist_ok=True)
46-
47-
# Download the test archive
48-
zip_path = data_dir / "testing_deepethogram_archive.zip"
49-
5041
try:
51-
print("Downloading test data archive...")
52-
gdown.download(id="1IFz4ABXppVxyuhYik8j38k9-Fl9kYKHo", output=str(zip_path), quiet=False)
42+
# Create tests/DATA directory if it doesn't exist
43+
tests_dir = Path("tests")
44+
data_dir = tests_dir / "DATA"
45+
data_dir.mkdir(parents=True, exist_ok=True)
5346

54-
print("Extracting archive...")
55-
with zipfile.ZipFile(zip_path, "r") as zip_ref:
56-
zip_ref.extractall(data_dir)
57-
58-
# Verify the extraction
47+
# Define paths and requirements
5948
archive_path = data_dir / "testing_deepethogram_archive"
49+
zip_path = data_dir / "testing_deepethogram_archive.zip"
6050
required_items = ["DATA", "models", "project_config.yaml"]
6151

52+
# Check if test data already exists and is complete
53+
if archive_path.exists():
54+
missing_items = [item for item in required_items if not (archive_path / item).exists()]
55+
if not missing_items:
56+
print("Test data already exists and appears complete. Skipping download.")
57+
return True
58+
print("Test data exists but is incomplete. Re-downloading...")
59+
60+
# Download and extract if needed
61+
if not archive_path.exists() or not all((archive_path / item).exists() for item in required_items):
62+
# Download if zip doesn't exist
63+
if not zip_path.exists():
64+
print("Downloading test data archive...")
65+
gdown.download(id="1IFz4ABXppVxyuhYik8j38k9-Fl9kYKHo", output=str(zip_path), quiet=False)
66+
67+
# Extract archive
68+
print("Extracting archive...")
69+
with zipfile.ZipFile(zip_path, "r") as zip_ref:
70+
zip_ref.extractall(data_dir)
71+
72+
# Clean up zip file after successful extraction
73+
zip_path.unlink()
74+
75+
# Final verification
6276
missing_items = [item for item in required_items if not (archive_path / item).exists()]
63-
6477
if missing_items:
6578
print(f"Warning: The following items are missing: {missing_items}")
6679
return False
6780

6881
print("Setup completed successfully!")
6982
print("\nYou can now run the tests using: pytest tests/")
70-
print("Note: The zz_commandline test module will take a few minutes to complete.")
71-
72-
# Clean up the zip file
73-
zip_path.unlink()
83+
print("Note: The gpu tests will take a few minutes to complete.")
7484
return True
7585

7686
except Exception as e:

0 commit comments

Comments
 (0)