Skip to content

Commit 98fd10f

Browse files
authored
Don't update probe jsons if only the probeinterface version number has changed (#34)
1 parent 4196ff9 commit 98fd10f

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

.github/workflows/check_for_changes_in_NP_jsons.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ jobs:
2424
with:
2525
python-version: '3.10'
2626

27-
# Clone dev version of probeinterface
28-
- name: Clone external repository
27+
# we just the release probeinterface to get the version number
28+
- name: Install probeinterface and matplotlib
2929
run: |
30+
pip install probeinterface matplotlib
31+
PROBEINTERFACE_VERSION=$(pip show probeinterface | grep Version | awk '{print $2}')
32+
pip uninstall probeinterface --yes
3033
git clone https://github.com/spikeinterface/probeinterface ./probeinterface
34+
cd probeinterface
35+
git fetch
36+
git checkout tags/$PROBEINTERFACE_VERSION
37+
cd ..
38+
pip install ./probeinterface
3139
32-
- name: Install probeinterface and matplotlib
33-
run: pip install ./probeinterface matplotlib
3440
3541
- name: Generate full NP library
3642
run: |
@@ -40,8 +46,11 @@ jobs:
4046
# Check for any new probes
4147
- name: Run local script
4248
run: |
43-
rsync -av --include='*/' --include='*.json' --exclude='*' scripts/neuropixels_library_generated/ imec/
44-
rm -r scripts/neuropixels_library_generated/
49+
cd scripts/
50+
python check_for_json_changes_in_NP_probes.py
51+
rm -r neuropixels_library_generated/
52+
cd ..
53+
4554
rm -r ./probeinterface
4655
4756
- name: Commit changes if any
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from pathlib import Path
2+
import shutil
3+
4+
old_dir = Path('../imec')
5+
new_dir = Path('./neuropixels_library_generated')
6+
7+
for temp_probe_directory in new_dir.iterdir():
8+
9+
probe_name = str(temp_probe_directory.name)
10+
11+
temp_probe_json_path = temp_probe_directory / (probe_name + '.json')
12+
old_probe_json_path = old_dir / probe_name / (probe_name + '.json')
13+
14+
if old_probe_json_path.is_file():
15+
with open(temp_probe_json_path, 'r') as f1, open(old_probe_json_path, 'r') as f2:
16+
# Read in json files
17+
lines1 = f1.readlines()
18+
lines2 = f2.readlines()
19+
20+
# We don't want to update the probes just because of a probeinterface version update.
21+
# The probeinterface version is stored on the 3rd line of the json file, so we only
22+
# compare the json files from line 3 and down.
23+
if lines1[3:] == lines2[3:]:
24+
continue
25+
else:
26+
shutil.copy(f"{temp_probe_json_path}", f"../imec/{probe_name}")

0 commit comments

Comments
 (0)