-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into circuit-extensions
- Loading branch information
Showing
9 changed files
with
220 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,74 @@ | ||
name: Build Singularity Container | ||
|
||
on: | ||
schedule: | ||
- cron: '0 2 1 * *' | ||
push: | ||
branches-ignore: | ||
- master | ||
paths: | ||
- 'resources/retinal-rl.def' | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- 'resources/retinal-rl.def' | ||
workflow_call: | ||
inputs: | ||
deploy: | ||
type: boolean | ||
required: false | ||
default: true | ||
workflow_dispatch: | ||
inputs: | ||
deploy: | ||
type: boolean | ||
required: false | ||
default: true | ||
|
||
env: | ||
singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image | ||
sif_file: retinal-rl_singularity-image.sif | ||
|
||
jobs: | ||
singularity-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Fetch all branches | ||
run: git fetch --all | ||
- uses: eWaterCycle/setup-apptainer@v2 | ||
with: | ||
apptainer-version: 1.3.0 | ||
|
||
- name: Evaluate whether build should be deployed | ||
id: setup | ||
run: | | ||
if [[ "${{ inputs.deploy }}" != "" ]]; then | ||
echo "deploy=${{ inputs.deploy }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "deploy=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Cache Singularity Image | ||
id: cache-singularity | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.sif_file }} | ||
key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} | ||
restore-keys: | | ||
${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} | ||
- name: Build Singularity container | ||
run: apptainer build retinal-rl.sif resources/retinal-rl.def | ||
if: steps.cache-singularity.outputs.cache-hit != 'true' | ||
run: apptainer build ${{ env.sif_file }} resources/retinal-rl.def | ||
|
||
- name: Scan classification config / ensure minimal functionality | ||
- name: Scan configs | ||
run: | | ||
cp -r resources/config_templates/* config/ | ||
singularity exec retinal-rl.sif python main.py -m +experiment=classification command=scan system.device=cpu | ||
bash tests/ci/copy_configs.sh ${{ env.sif_file }} | ||
bash tests/ci/scan_configs.sh ${{ env.sif_file }} | ||
- name: Run code check | ||
run: bash tests/ci/pylint.sh ${{ env.sif_file }} | ||
|
||
- name: Push to ghcr.io | ||
- name: Deployment / Push to ghcr.io | ||
if: steps.setup.outputs.deploy == 'true' | ||
run: | | ||
singularity registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io | ||
singularity push retinal-rl.sif oras://ghcr.io/berenslab/retinal-rl:singularity-image-latest | ||
apptainer registry login --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} oras://ghcr.io | ||
apptainer push ${{ env.sif_file }} oras://ghcr.io/berenslab/retinal-rl:singularity-image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Update Master Cache | ||
|
||
on: | ||
schedule: | ||
- cron: '0 2 * * 0' # As cache is emptied if not accessed for 7 days, check after 7 days whether container has changed | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'resources/retinal-rl.def' | ||
workflow_call: | ||
|
||
env: | ||
singularity_image: oras://ghcr.io/berenslab/retinal-rl:singularity-image | ||
sif_file: retinal-rl_singularity-image.sif | ||
|
||
jobs: | ||
conditional-build: | ||
uses: ./.github/workflows/container_build.yml | ||
with: | ||
deploy: ${{ github.event_name == 'push' }} | ||
update-cache: | ||
needs: conditional-build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Apptainer | ||
uses: eWaterCycle/setup-apptainer@v2 | ||
with: | ||
apptainer-version: 1.3.0 | ||
- name: Cache Singularity Image | ||
id: cache-singularity | ||
uses: actions/cache@v4 | ||
with: | ||
path: ${{ env.sif_file }} | ||
key: ${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} | ||
restore-keys: | | ||
${{ runner.os }}-singularity-${{ hashFiles('~/resources/retinal-rl.def') }} | ||
- name: Pull Singularity container | ||
if: steps.cache-singularity.outputs.cache-hit != 'true' | ||
run: apptainer pull ${{ env.sif_file }} ${{ env.singularity_image }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
[MASTER] | ||
init-hook='import sys; sys.path.append(".")' | ||
init-hook='import sys; sys.path.append(".")' | ||
|
||
[MESSAGES CONTROL] | ||
|
||
# Enable the message, report, category or checker with the given id(s). You can | ||
# either give multiple identifier separated by comma (,) or put this option | ||
# multiple time. | ||
#enable= | ||
|
||
# Disable the message, report, category or checker with the given id(s). You | ||
# can either give multiple identifier separated by comma (,) or put this option | ||
# multiple time (only on the command line, not in the configuration file where | ||
# it should appear only once). | ||
disable=missing-function-docstring,missing-module-docstring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
#=============================================================================== | ||
# Description: Copies the config files from the resources dir to the config dir. | ||
# Thus creates the basic structure needed to setup or run | ||
# experiments. | ||
# | ||
# Usage: | ||
# tests/ci/copy_configs.sh | ||
# (run from top level directory!) | ||
#=============================================================================== | ||
|
||
cp -r resources/config_templates/* config/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
#=============================================================================== | ||
# Description: Runs pylint either on all Python files or only on changed files | ||
# compared to master branch using a specified Singularity container | ||
# | ||
# Arguments: | ||
# $1 - Path to Singularity (.sif) container | ||
# $2 - Optional: "--all" to run on all files, otherwise runs only on changed files | ||
# | ||
# Usage: | ||
# tests/ci/run_pylint.sh container.sif # Lint only changed Python files | ||
# tests/ci/run_pylint.sh container.sif --all # Lint all Python files | ||
# (run from top level directory!) | ||
# | ||
# Dependencies: | ||
# - Singularity/Apptainer + container | ||
# - Container must have pylint installed | ||
#=============================================================================== | ||
|
||
if [ "$2" = "--all" ]; then | ||
apptainer exec "$1" pylint . | ||
else | ||
changed_files=$(git diff --name-only origin/master...HEAD -- '*.py') | ||
if [ -n "$changed_files" ]; then | ||
apptainer exec "$1" pylint $(git diff --name-only origin/master...HEAD -- '*.py') | ||
else | ||
echo "No .py files changed" | ||
fi | ||
fi |
Oops, something went wrong.