Skip to content

Commit c5d0cfb

Browse files
authored
Merge pull request #1938 from h-mayorquin/fix_CI
Fall back to the cached test data when gin cannot be reached in CI
2 parents 7e31fa2 + 56dd1d5 commit c5d0cfb

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎.github/workflows/io-test.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ jobs:
4242
# the key depend on the last commit repo https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git
4343
id: ephy_testing_data
4444
run: |
45+
# if gin cannot be reached the key matches no cache and the restore-keys below restore the most recent one
4546
set -o pipefail
4647
if ! hash="$(git ls-remote https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git HEAD | cut -f1)" || [ -z "$hash" ]; then
47-
echo "::error::could not resolve ephy_testing_data HEAD on gin; refusing to build a degenerate cache key"
48-
exit 1
48+
echo "::warning::could not resolve ephy_testing_data HEAD on gin; restoring the most recent dataset cache"
49+
hash=""
4950
fi
5051
echo "dataset_hash=$hash" >> "$GITHUB_OUTPUT"
5152

‎.github/workflows/plexon2-testing.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333
# the key depend on the last commit repo https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git
3434
id: ephy_testing_data
3535
run: |
36+
# if gin cannot be reached the key matches no cache and the restore-keys below restore the most recent one
3637
set -o pipefail
3738
if ! hash="$(git ls-remote https://gin.g-node.org/NeuralEnsemble/ephy_testing_data.git HEAD | cut -f1)" || [ -z "$hash" ]; then
38-
echo "::error::could not resolve ephy_testing_data HEAD on gin; refusing to build a degenerate cache key"
39-
exit 1
39+
echo "::warning::could not resolve ephy_testing_data HEAD on gin; restoring the most recent dataset cache"
40+
hash=""
4041
fi
4142
echo "dataset_hash=$hash" >> "$GITHUB_OUTPUT"
4243

‎neo/utils/datasets.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import os
6+
import warnings
67
from pathlib import Path
78

89
default_testing_repo = "https://gin.g-node.org/NeuralEnsemble/ephy_testing_data"
@@ -14,6 +15,9 @@
1415
# set in home
1516
local_testing_data_folder = Path.home() / "ephy_testing_data"
1617

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

1822
def get_local_testing_data_folder():
1923
global local_testing_data_folder
@@ -64,7 +68,12 @@ def download_dataset(repo=default_testing_repo, remote_path=None, local_folder=N
6468
# make sure git repo is in clean state
6569
repo = dataset.repo
6670
repo.call_git(["checkout", "--force", "master"])
67-
dataset.update(merge=True)
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")
6877
else:
6978
dataset = datalad.api.install(path=local_folder, source=repo)
7079

0 commit comments

Comments
 (0)