Skip to content

Commit

Permalink
Fix test failures due to http rate limit (#62)
Browse files Browse the repository at this point in the history
* Fix test failures due to http rate limit

* Fix default arg in download_file_from_zip_url
  • Loading branch information
stes authored Sep 9, 2023
1 parent a21ba0e commit 16653e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cebra/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def download_file_from_url(url: str) -> str:
return filename


def download_file_from_zip_url(url, file="montblanc_tracks.h5"):
def download_file_from_zip_url(url, *, file):
"""Directly extract files without writing the archive to disk."""
with tempfile.TemporaryDirectory() as tf:
foldername = tf
Expand Down
18 changes: 14 additions & 4 deletions tests/test_dlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,19 @@
from cebra import CEBRA
from cebra import load_data

ANNOTATED_DLC_URL = "https://github.com/DeepLabCut/DeepLabCut/blob/main/examples/Reaching-Mackenzie-2018-08-30/labeled-data/reachingvideo1/CollectedData_Mackenzie.h5?raw=true"
# NOTE(stes): The original data URL is
# https://github.com/DeepLabCut/DeepLabCut/blob/main/examples
# /Reaching-Mackenzie-2018-08-30/labeled-data/reachingvideo1
# /CollectedData_Mackenzie.h5?raw=true
# which is replaced here due to rate limitations we observed in the past.
ANNOTATED_DLC_URL = "https://figshare.com/ndownloader/files/42303564?private_link=b917317bfab725e0b207"

# NOTE(stes): The original data URL is
# https://github.com/DeepLabCut/UnitTestData/raw/main/data.zip")
# which is replaced here due to rate limitations we observed in the past.
MULTISESSION_PRED_DLC_URL = (
"https://github.com/DeepLabCut/UnitTestData/raw/main/data.zip")
"https://figshare.com/ndownloader/files/42303561?private_link=b917317bfab725e0b207"
)

MULTISESSION_PRED_KEYPOINTS = ["head", "tail"]
ANNOTATED_KEYPOINTS = ["Hand", "Tongue"]
Expand Down Expand Up @@ -159,14 +169,14 @@ def test_load_data_dlc_invalid_keypoints(filename, keypoints):
### multi-animals
def test_multianimal_dlc_file():
filename = cebra.helper.download_file_from_zip_url(
url=MULTISESSION_PRED_DLC_URL)
url=MULTISESSION_PRED_DLC_URL, file="montblanc_tracks.h5")
with pytest.raises(NotImplementedError, match="Multi-animals.*"):
_ = cebra_dlc.load_deeplabcut(filename)


def test_multianimal_data_dlc_file():
filename = cebra.helper.download_file_from_zip_url(
url=MULTISESSION_PRED_DLC_URL)
url=MULTISESSION_PRED_DLC_URL, file="montblanc_tracks.h5")
with pytest.raises(NotImplementedError, match="Multi-animals.*"):
_ = load_data(filename)

Expand Down

0 comments on commit 16653e2

Please sign in to comment.