@@ -38,39 +38,49 @@ def download_file(url, destination):
3838
3939def 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 ("\n You 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