diff --git a/.github/workflows/check_for_changes_in_NP_jsons.yml b/.github/workflows/check_for_changes_in_NP_jsons.yml index a640fa2..4256a4e 100644 --- a/.github/workflows/check_for_changes_in_NP_jsons.yml +++ b/.github/workflows/check_for_changes_in_NP_jsons.yml @@ -24,13 +24,22 @@ jobs: with: python-version: '3.10' + # we just probeinterface to get the version number + - name: Install probeinterface and matplotlib + run: | + pip install probeinterface matplotlib + PROBEINTERFACE_VERSION=$(pip show pip | grep Version | awk '{print $2}') + pip uninstall probeinterface + + # Clone dev version of probeinterface - name: Clone external repository run: | git clone https://github.com/spikeinterface/probeinterface ./probeinterface + git fetch + git checkout tags/$PROBEINTERFACE_VERSION + pip install ./probeinterface - - name: Install probeinterface and matplotlib - run: pip install ./probeinterface matplotlib - name: Generate full NP library run: | @@ -40,8 +49,11 @@ jobs: # Check for any new probes - name: Run local script run: | - rsync -av --include='*/' --include='*.json' --exclude='*' scripts/neuropixels_library_generated/ imec/ - rm -r scripts/neuropixels_library_generated/ + cd scripts/ + python check_for_json_changes_in_NP_probes.py + rm -r neuropixels_library_generated/ + cd .. + rm -r ./probeinterface - name: Commit changes if any diff --git a/scripts/check_for_json_changes_in_NP_probes.py b/scripts/check_for_json_changes_in_NP_probes.py new file mode 100644 index 0000000..a253067 --- /dev/null +++ b/scripts/check_for_json_changes_in_NP_probes.py @@ -0,0 +1,28 @@ +from pathlib import Path +import shutil + +old_dir = Path('../imec') +new_dir = Path('./neuropixels_library_generated') + +new_dir = Path("/Users/christopherhalcrow/Work/fromgit/probeinterface/neuropixels_library_generated") + +for temp_probe_directory in new_dir.iterdir(): + + probe_name = str(temp_probe_directory.name) + + temp_probe_json_path = temp_probe_directory / (probe_name + '.json') + old_probe_json_path = old_dir / probe_name / (probe_name + '.json') + + if old_probe_json_path.is_file(): + with open(temp_probe_json_path, 'r') as f1, open(old_probe_json_path, 'r') as f2: + # Read in json files + lines1 = f1.readlines() + lines2 = f2.readlines() + + # We don't want to update the probes just because of a probeinterface version update. + # The probeinterface version is stored on the 3rd line of the json file, so we only + # compare the json files from line 3 and down. + if lines1[3:] == lines2[3:]: + continue + else: + shutil.copy(f"{temp_probe_json_path}", f"../imec/{probe_name}") \ No newline at end of file