Skip to content

Commit 856c855

Browse files
authored
Merge pull request #8 from neurostuff/tst/add_workflow
[TST] add workflow
2 parents 359646e + 370037a commit 856c855

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/run_notebook.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Run Notebook
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Runs at 9:00 AM Central (14:00 UTC)
7+
- cron: '0 14 * * *'
8+
push:
9+
branches: [ main ]
10+
pull_request:
11+
branches: [ main ]
12+
13+
jobs:
14+
run-notebook:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python 3.11
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.11'
23+
24+
- name: Extract dependencies from colabtools
25+
run: |
26+
# Download setup.py
27+
curl -s https://raw.githubusercontent.com/googlecolab/colabtools/refs/heads/main/setup.py > setup.py
28+
# Extract DEPENDENCIES using Python
29+
python3 - <<EOF
30+
with open('setup.py', 'r') as f:
31+
content = f.read()
32+
33+
# Find DEPENDENCIES tuple
34+
start = content.find('DEPENDENCIES = (')
35+
end = content.find(')', start)
36+
deps = content[start:end+1]
37+
38+
# Execute the tuple to get the values
39+
exec(deps)
40+
41+
# Write dependencies to requirements file
42+
with open('colab_requirements.txt', 'w') as f:
43+
for dep in DEPENDENCIES:
44+
f.write(f"{dep}\n")
45+
EOF
46+
47+
- name: Install dependencies
48+
run: |
49+
python -m pip install --upgrade pip
50+
# Install colabtools dependencies
51+
pip install -r colab_requirements.txt
52+
# Install additional required packages
53+
pip install -r requirements.txt
54+
55+
- name: Modify notebook
56+
run: |
57+
# Convert notebook to Python script for easier text processing
58+
jupyter nbconvert --to script run_and_explore.ipynb
59+
60+
# Remove Setup environment section
61+
sed -i '/#@title Setup environment/,/# In\[ \]:/d' run_and_explore.py
62+
63+
# Replace META_ID
64+
sed -i 's/META_ID = ""/META_ID = "36Dm86NVjoTJ"/' run_and_explore.py
65+
66+
# Add no_upload parameter to run function
67+
sed -i 's/url, meta_result = run(META_ID)/url, meta_result = run(META_ID, no_upload=True)/' run_and_explore.py
68+
69+
# Remove View the Report section (everything after the line containing "# View")
70+
sed -i '/^#@title View/,$d' run_and_explore.py
71+
72+
- name: Execute Python script
73+
run: |
74+
python run_and_explore.py
75+
76+
- name: Upload results
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: analysis-results
80+
path: |
81+
results/
82+
report/

0 commit comments

Comments
 (0)