From 8d1c804c4f08cf1b110f33d7f7c7b512b35e49dc Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:12:14 +0000 Subject: [PATCH 01/11] initial action --- .github/workflows/check_for_new_probes.yml | 98 ++++++++++++++++++++++ scripts/check_for_new_NP_probes.py | 11 +++ 2 files changed, 109 insertions(+) create mode 100644 .github/workflows/check_for_new_probes.yml create mode 100644 scripts/check_for_new_NP_probes.py diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml new file mode 100644 index 0000000..ef75c26 --- /dev/null +++ b/.github/workflows/check_for_new_probes.yml @@ -0,0 +1,98 @@ +name: Clone, Run Scripts, and Create PR + + +on: + schedule: + - cron: '1 0 * * 1' # Every Monday at 00:00 UTC + workflow_dispatch: + +# Grant permissions for the job to write to contents (push) and create PRs. +permissions: + contents: write + pull-requests: write + +jobs: + build-and-pr: + runs-on: ubuntu-latest + steps: + # Step 1: Check out the code in your current (local) repository + # We use a Personal Access Token (PAT) so the action has permission + # to push a new branch and open a pull request. + - name: Check out local repository + uses: actions/checkout@v4 + # with: + # # --- USER ACTION REQUIRED --- + # # You MUST create a repository secret named GH_PAT. + # # Go to Settings > Secrets and Variables > Actions > New repository secret + # # The token needs the 'repo' (or 'public_repo') and 'workflow' scopes. + # token: ${{ secrets.GH_PAT }} + + # Step 2: Set up a Python environment + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' # Or your preferred version + cache: 'pip' # Caches dependencies to speed up future runs + + # --- (Optional) --- + # If your local script needs libraries, uncomment this step + - name: Install local dependencies + run: pip install probeinterface + + # Step 3: Clone the *other* repository into a subfolder named './other-repo' + - name: Clone external repository + run: | + # --- USER ACTION REQUIRED --- + # Replace this URL with the repository you want to clone. + # If it's a private repo, your GH_PAT must have access. + git clone https://github.com/spikeinterface/probeinterface ./probeinterface + + # --- (Optional) --- + # If the external script needs libraries, uncomment this step + # - name: Install external repo dependencies + # run: pip install -r ./other-repo/requirements.txt + + # Step 4: Run the Python script from the *external* repository + - name: Run external script + run: | + # --- USER ACTION REQUIRED --- + # Replace this path with the correct path to the script + # in the repository you just cloned. + cd tools/ + python ../../probeinterface/resources/generate_neuropixels_library.py + + # Step 5: Run the Python script from your *local* repository + # This is the script that should modify the files you want to PR. + - name: Run local script + run: | + # --- USER ACTION REQUIRED --- + # Replace this path with the correct path to your local script + python check_for_new_NP_probes.py + rm -r neuropixels_library_generated/ + cd .. + + - name: Commit changes if any + id: commit + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + git add imec/* + + # Only commit if there are changes + if git diff --staged --quiet; then + echo "No changes to commit" + echo "changes=false" >> $GITHUB_OUTPUT + else + git commit -m "Update neuropixels_probe_features from ProbeTable" + echo "changes=true" >> $GITHUB_OUTPUT + fi + + - name: Update imec library with new probes + if: steps.commit.outputs.changes == 'true' + uses: peter-evans/create-pull-request@v7 + with: + title: "Update library with new Neuropixels probes" + body: "This PR updates the probeinterace library with new Neuropixel probes, auto-generated file from the ProbeTable repository." + branch-suffix: short-commit-hash + base: "main" diff --git a/scripts/check_for_new_NP_probes.py b/scripts/check_for_new_NP_probes.py new file mode 100644 index 0000000..9b4b048 --- /dev/null +++ b/scripts/check_for_new_NP_probes.py @@ -0,0 +1,11 @@ +from pathlib import Path +import shutil + +old_dir = Path('../imec') +new_dir = Path('../../probeinterface/resources/test_np_lib') + +existing_probes = list(probe_path.name for probe_path in old_dir.iterdir()) + +for temp_probe_path in new_dir.iterdir(): + if temp_probe_path.name not in existing_probes: + shutil.copytree(f"{temp_probe_path}", f"../imec/{temp_probe_path.name}") \ No newline at end of file From f4afa1a55cdf3f9e109c6ae330e46b2ee4020e22 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:14:07 +0000 Subject: [PATCH 02/11] add pyproject toml --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b51bc30 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[project] +name = "probeinterface-library" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.9" +dependencies = [] From 5ee96d0fe9e0b2a014873feaee9d88df06936ab6 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:15:01 +0000 Subject: [PATCH 03/11] oups --- .github/workflows/check_for_new_probes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index ef75c26..27ffb42 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -58,7 +58,7 @@ jobs: # --- USER ACTION REQUIRED --- # Replace this path with the correct path to the script # in the repository you just cloned. - cd tools/ + cd scripts/ python ../../probeinterface/resources/generate_neuropixels_library.py # Step 5: Run the Python script from your *local* repository From d392454bd8ff52983b6d5459095512908b20243f Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:16:41 +0000 Subject: [PATCH 04/11] update action to point at correct pi folder --- .github/workflows/check_for_new_probes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index 27ffb42..5b4083f 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -59,7 +59,7 @@ jobs: # Replace this path with the correct path to the script # in the repository you just cloned. cd scripts/ - python ../../probeinterface/resources/generate_neuropixels_library.py + python ../probeinterface/resources/generate_neuropixels_library.py # Step 5: Run the Python script from your *local* repository # This is the script that should modify the files you want to PR. From 148ee949d5ebb0de5ad7cbf07507c77fc2f51aab Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:17:54 +0000 Subject: [PATCH 05/11] add matplotlib --- .github/workflows/check_for_new_probes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index 5b4083f..b732048 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -37,7 +37,7 @@ jobs: # --- (Optional) --- # If your local script needs libraries, uncomment this step - name: Install local dependencies - run: pip install probeinterface + run: pip install probeinterface matplotlib # Step 3: Clone the *other* repository into a subfolder named './other-repo' - name: Clone external repository From b905a856876d6528c484b4445c092ba01b4d2544 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:20:28 +0000 Subject: [PATCH 06/11] try again --- .github/workflows/check_for_new_probes.yml | 2 ++ scripts/check_for_new_NP_probes.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index b732048..0e5bb0b 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -67,6 +67,8 @@ jobs: run: | # --- USER ACTION REQUIRED --- # Replace this path with the correct path to your local script + ls + cd scripts/ python check_for_new_NP_probes.py rm -r neuropixels_library_generated/ cd .. diff --git a/scripts/check_for_new_NP_probes.py b/scripts/check_for_new_NP_probes.py index 9b4b048..1bd1771 100644 --- a/scripts/check_for_new_NP_probes.py +++ b/scripts/check_for_new_NP_probes.py @@ -2,7 +2,7 @@ import shutil old_dir = Path('../imec') -new_dir = Path('../../probeinterface/resources/test_np_lib') +new_dir = Path('../probeinterface/resources/test_np_lib') existing_probes = list(probe_path.name for probe_path in old_dir.iterdir()) From 0dbdad7ed18c51f5c7ed91067aaa6f4e8cdce1c7 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:22:42 +0000 Subject: [PATCH 07/11] use default pi folder --- scripts/check_for_new_NP_probes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_for_new_NP_probes.py b/scripts/check_for_new_NP_probes.py index 1bd1771..4c86f16 100644 --- a/scripts/check_for_new_NP_probes.py +++ b/scripts/check_for_new_NP_probes.py @@ -2,7 +2,7 @@ import shutil old_dir = Path('../imec') -new_dir = Path('../probeinterface/resources/test_np_lib') +new_dir = Path('../probeinterface/resources/neuropixels_library_generated') existing_probes = list(probe_path.name for probe_path in old_dir.iterdir()) From f603c1d548716f4cc46ef1782d4a64473cbf31bb Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:24:15 +0000 Subject: [PATCH 08/11] oups --- scripts/check_for_new_NP_probes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check_for_new_NP_probes.py b/scripts/check_for_new_NP_probes.py index 4c86f16..11c2cb2 100644 --- a/scripts/check_for_new_NP_probes.py +++ b/scripts/check_for_new_NP_probes.py @@ -2,7 +2,7 @@ import shutil old_dir = Path('../imec') -new_dir = Path('../probeinterface/resources/neuropixels_library_generated') +new_dir = Path('./neuropixels_library_generated') existing_probes = list(probe_path.name for probe_path in old_dir.iterdir()) From ab550c4ca2cf4421a73215c990dd664fde7f2de9 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:38:14 +0000 Subject: [PATCH 09/11] update action --- .github/workflows/check_for_new_probes.yml | 45 ++++++---------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index 0e5bb0b..4b5466a 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -1,9 +1,8 @@ -name: Clone, Run Scripts, and Create PR - +name: Check for new NP probes on: schedule: - - cron: '1 0 * * 1' # Every Monday at 00:00 UTC + - cron: '0 1 * * 1' # Every Monday at 01:00 UTC workflow_dispatch: # Grant permissions for the job to write to contents (push) and create PRs. @@ -15,31 +14,18 @@ jobs: build-and-pr: runs-on: ubuntu-latest steps: - # Step 1: Check out the code in your current (local) repository - # We use a Personal Access Token (PAT) so the action has permission - # to push a new branch and open a pull request. + - name: Check out local repository uses: actions/checkout@v4 - # with: - # # --- USER ACTION REQUIRED --- - # # You MUST create a repository secret named GH_PAT. - # # Go to Settings > Secrets and Variables > Actions > New repository secret - # # The token needs the 'repo' (or 'public_repo') and 'workflow' scopes. - # token: ${{ secrets.GH_PAT }} - # Step 2: Set up a Python environment + # Set up a Python environment - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' # Or your preferred version + python-version: '3.10' cache: 'pip' # Caches dependencies to speed up future runs - # --- (Optional) --- - # If your local script needs libraries, uncomment this step - - name: Install local dependencies - run: pip install probeinterface matplotlib - - # Step 3: Clone the *other* repository into a subfolder named './other-repo' + # Clone dev version of probeinterface - name: Clone external repository run: | # --- USER ACTION REQUIRED --- @@ -47,22 +33,15 @@ jobs: # If it's a private repo, your GH_PAT must have access. git clone https://github.com/spikeinterface/probeinterface ./probeinterface - # --- (Optional) --- - # If the external script needs libraries, uncomment this step - # - name: Install external repo dependencies - # run: pip install -r ./other-repo/requirements.txt + - name: Install probeinterface and matplotlib + run: pip install ./probeinterface matplotlib - # Step 4: Run the Python script from the *external* repository - - name: Run external script + - name: Generate full NP library run: | - # --- USER ACTION REQUIRED --- - # Replace this path with the correct path to the script - # in the repository you just cloned. cd scripts/ python ../probeinterface/resources/generate_neuropixels_library.py - # Step 5: Run the Python script from your *local* repository - # This is the script that should modify the files you want to PR. + # Check for any new probes - name: Run local script run: | # --- USER ACTION REQUIRED --- @@ -86,11 +65,11 @@ jobs: echo "No changes to commit" echo "changes=false" >> $GITHUB_OUTPUT else - git commit -m "Update neuropixels_probe_features from ProbeTable" + git commit -m "Update imec library with new probes" echo "changes=true" >> $GITHUB_OUTPUT fi - - name: Update imec library with new probes + - name: Create pull request to add probes if: steps.commit.outputs.changes == 'true' uses: peter-evans/create-pull-request@v7 with: From 210e1796d15cb1bba69a81404e32ee235204db52 Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:42:51 +0000 Subject: [PATCH 10/11] remove probeinterface so action doesnt add as submodule --- .github/workflows/check_for_new_probes.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index 4b5466a..d5cf204 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -51,6 +51,7 @@ jobs: python check_for_new_NP_probes.py rm -r neuropixels_library_generated/ cd .. + rm -r ./probeinterface - name: Commit changes if any id: commit From 352b3ef4f33a53658ed53d0a0278c739c48aef9e Mon Sep 17 00:00:00 2001 From: chrishalcrow Date: Mon, 27 Oct 2025 14:47:17 +0000 Subject: [PATCH 11/11] remove cache and pyproject.toml --- .github/workflows/check_for_new_probes.yml | 1 - pyproject.toml | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 pyproject.toml diff --git a/.github/workflows/check_for_new_probes.yml b/.github/workflows/check_for_new_probes.yml index d5cf204..47683d8 100644 --- a/.github/workflows/check_for_new_probes.yml +++ b/.github/workflows/check_for_new_probes.yml @@ -23,7 +23,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.10' - cache: 'pip' # Caches dependencies to speed up future runs # Clone dev version of probeinterface - name: Clone external repository diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index b51bc30..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,7 +0,0 @@ -[project] -name = "probeinterface-library" -version = "0.1.0" -description = "Add your description here" -readme = "README.md" -requires-python = ">=3.9" -dependencies = []