Skip to content

Commit 56dd1d5

Browse files
committed
Update the test data at most once per process and warn on datalad's impossible status
1 parent 4ae2334 commit 56dd1d5

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎neo/utils/datasets.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
# set in home
1616
local_testing_data_folder = Path.home() / "ephy_testing_data"
1717

18+
# local copies already updated in this process, so each one asks its remote at most once
19+
_updated_folders = set()
20+
1821

1922
def get_local_testing_data_folder():
2023
global local_testing_data_folder
@@ -65,10 +68,12 @@ def download_dataset(repo=default_testing_repo, remote_path=None, local_folder=N
6568
# make sure git repo is in clean state
6669
repo = dataset.repo
6770
repo.call_git(["checkout", "--force", "master"])
68-
# the remote can be unreachable (gin answers 403 to CI runners at times), so keep the local copy then
69-
results = dataset.update(merge=True, on_failure="ignore")
70-
if any(result["status"] == "error" for result in results):
71-
warnings.warn(f"Could not update {local_folder} from its remote, using the local copy as it is")
71+
if local_folder not in _updated_folders:
72+
_updated_folders.add(local_folder)
73+
# the remote can be unreachable (gin answers 403 to CI runners at times), so keep the local copy then
74+
results = dataset.update(merge=True, on_failure="ignore")
75+
if any(result["status"] in ("impossible", "error") for result in results):
76+
warnings.warn(f"Could not update {local_folder} from its remote, using the local copy as it is")
7277
else:
7378
dataset = datalad.api.install(path=local_folder, source=repo)
7479

0 commit comments

Comments
 (0)