Skip to content

Commit 9279b69

Browse files
authored
Add action to automatically check for new NP probes (#27)
1 parent bf6bc78 commit 9279b69

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Check for new NP probes
2+
3+
on:
4+
schedule:
5+
- cron: '0 1 * * 1' # Every Monday at 01:00 UTC
6+
workflow_dispatch:
7+
8+
# Grant permissions for the job to write to contents (push) and create PRs.
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
build-and-pr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
18+
- name: Check out local repository
19+
uses: actions/checkout@v4
20+
21+
# Set up a Python environment
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.10'
26+
27+
# Clone dev version of probeinterface
28+
- name: Clone external repository
29+
run: |
30+
# --- USER ACTION REQUIRED ---
31+
# Replace this URL with the repository you want to clone.
32+
# If it's a private repo, your GH_PAT must have access.
33+
git clone https://github.com/spikeinterface/probeinterface ./probeinterface
34+
35+
- name: Install probeinterface and matplotlib
36+
run: pip install ./probeinterface matplotlib
37+
38+
- name: Generate full NP library
39+
run: |
40+
cd scripts/
41+
python ../probeinterface/resources/generate_neuropixels_library.py
42+
43+
# Check for any new probes
44+
- name: Run local script
45+
run: |
46+
# --- USER ACTION REQUIRED ---
47+
# Replace this path with the correct path to your local script
48+
ls
49+
cd scripts/
50+
python check_for_new_NP_probes.py
51+
rm -r neuropixels_library_generated/
52+
cd ..
53+
rm -r ./probeinterface
54+
55+
- name: Commit changes if any
56+
id: commit
57+
run: |
58+
git config --local user.email "[email protected]"
59+
git config --local user.name "GitHub Action"
60+
61+
git add imec/*
62+
63+
# Only commit if there are changes
64+
if git diff --staged --quiet; then
65+
echo "No changes to commit"
66+
echo "changes=false" >> $GITHUB_OUTPUT
67+
else
68+
git commit -m "Update imec library with new probes"
69+
echo "changes=true" >> $GITHUB_OUTPUT
70+
fi
71+
72+
- name: Create pull request to add probes
73+
if: steps.commit.outputs.changes == 'true'
74+
uses: peter-evans/create-pull-request@v7
75+
with:
76+
title: "Update library with new Neuropixels probes"
77+
body: "This PR updates the probeinterace library with new Neuropixel probes, auto-generated file from the ProbeTable repository."
78+
branch-suffix: short-commit-hash
79+
base: "main"

scripts/check_for_new_NP_probes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pathlib import Path
2+
import shutil
3+
4+
old_dir = Path('../imec')
5+
new_dir = Path('./neuropixels_library_generated')
6+
7+
existing_probes = list(probe_path.name for probe_path in old_dir.iterdir())
8+
9+
for temp_probe_path in new_dir.iterdir():
10+
if temp_probe_path.name not in existing_probes:
11+
shutil.copytree(f"{temp_probe_path}", f"../imec/{temp_probe_path.name}")

0 commit comments

Comments
 (0)