flysim-malecns / workflows /engine-check.yml
DevNexon's picture
flysim-malecns: connectome-v1 release
aecbd27 verified
Raw History Blame Contribute Delete
6.33 kB
# Kept for reference. It ran on GitHub Actions in the development repository and is not
# run from this dataset. Paths and names are updated to this release's layout, where the
# package lives in flysim/.
#
name: Engine check against Brian2
# Run by hand. Brian2 reference runs (Shiu et al.'s model.py, unmodified, n_run = 60),
# our engine on seed set A, then the report under the original rule
# (records/preregistration.md, section 2.3). rule = recalibrated with seed_set = fresh is
# the exploratory run of section 9: a new Brian2 sample (model.py draws unseeded), our
# engine on trials 1000-1029. It never changes the engine-check verdict.
on:
workflow_dispatch:
inputs:
only:
description: "Case ids or condition keys to run (space-separated); empty = all of E1-E4"
required: false
default: ""
rule:
description: "original = section 2.3, decides the check (default); recalibrated = exploratory (section 9)"
type: choice
options: [original, recalibrated]
default: original
seed_set:
description: "Our engine's trials: A = 0-29 (the check); fresh = 1000-1029 (recalibrated rule)"
type: choice
options: [A, fresh]
default: A
permissions:
contents: read
env:
SHIU_REPO: https://github.com/philshiu/Drosophila_brain_model
SHIU_COMMIT: 91bdd1e7dcf193f3e7ca5a8933497fcef63b7960
jobs:
conditions:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
keys: ${{ steps.keys.outputs.keys }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: "0.11.32"
- id: keys
env:
ONLY: ${{ inputs.only }}
run: |
keys=$(uv run --project flysim python -c "
import json, os
from flysim.validation.manifest import conditions
only = os.environ['ONLY'].split()
print(json.dumps([c.key for c in conditions()
if not only or c.key in only or c.case in only]))")
echo "keys=$keys" >> "$GITHUB_OUTPUT"
brian:
needs: conditions
runs-on: ubuntu-latest
timeout-minutes: 350
strategy:
fail-fast: false
matrix:
key: ${{ fromJSON(needs.conditions.outputs.keys) }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: "0.11.32"
- name: Shiu et al. at the pinned commit
run: |
git clone --quiet "$SHIU_REPO" shiu
git -C shiu checkout --quiet "$SHIU_COMMIT"
- name: Brian2 reference (60 trials)
env:
KEY: ${{ matrix.key }}
run: uv run --python 3.10 flysim/scripts/brian_reference.py --shiu shiu --out runs/brian --only "$KEY" --n-proc 4
- id: name
env:
KEY: ${{ matrix.key }}
run: echo "stem=${KEY//\//__}" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: brian-${{ steps.name.outputs.stem }}
path: runs/brian/
ours:
needs: conditions
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: "0.11.32"
- run: uv sync --locked --project flysim
- name: FAFB v630 tables
run: |
mkdir -p fafb
for f in 2023_03_23_completeness_630_final.csv 2023_03_23_connectivity_630_final.parquet; do
curl -sSfL -o "fafb/$f" "https://raw.githubusercontent.com/philshiu/Drosophila_brain_model/$SHIU_COMMIT/$f"
done
- name: Our engine, seed set ${{ inputs.seed_set || 'A' }}
env:
ONLY: ${{ inputs.only }}
SEED_SET: ${{ inputs.seed_set || 'A' }}
run: uv run --project flysim python -m flysim.validation.engine_check run --fafb fafb --out runs/ours --jobs 4 --seed-set "$SEED_SET" ${ONLY:+--only $ONLY}
- uses: actions/upload-artifact@v4
with:
name: ours
path: runs/ours/
compare:
needs: [brian, ours]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
with:
version: "0.11.32"
- run: uv sync --locked --project flysim
- uses: actions/download-artifact@v4
with:
pattern: brian-*
path: runs/brian
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: ours
path: runs/ours
- name: Data
run: |
mkdir -p fafb
base="https://raw.githubusercontent.com/philshiu/Drosophila_brain_model/$SHIU_COMMIT"
curl -sSfL -o fafb/2023_03_23_completeness_630_final.csv "$base/2023_03_23_completeness_630_final.csv"
curl -sSfL -o sugarR.parquet "$base/results/example/sugarR.parquet"
- name: Report
env:
ONLY: ${{ inputs.only }}
RULE: ${{ inputs.rule || 'original' }}
SEED_SET: ${{ inputs.seed_set || 'A' }}
run: |
crosscheck=""
[ -f runs/brian/E1__sugarR__200Hz.parquet ] && [ -f runs/brian/E1__sugarR__150Hz.parquet ] && crosscheck="--crosscheck sugarR.parquet"
set +e
uv run --project flysim python -m flysim.validation.engine_check compare --fafb fafb --ours runs/ours \
--brian runs/brian $crosscheck ${ONLY:+--only $ONLY} --rule "$RULE" \
--seed-set "$SEED_SET" --out engine-check.md
echo "exit=$?" >> "$GITHUB_ENV"
cat engine-check.md >> "$GITHUB_STEP_SUMMARY"
if [ "$RULE" != original ]; then
# the same data under the original rule (section 2.3), for reference only
uv run --project flysim python -m flysim.validation.engine_check compare --fafb fafb --ours runs/ours \
--brian runs/brian ${ONLY:+--only $ONLY} --rule original --seed-set "$SEED_SET" \
--out engine-check-original-rule.md
cat engine-check-original-rule.md >> "$GITHUB_STEP_SUMMARY"
fi
- uses: actions/upload-artifact@v4
with:
name: engine-check
path: |
engine-check*.md
runs/brian/brian_env.json
- name: Result
run: test "$exit" = 0