[TST] add workflow #1
This file contains hidden or 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
name: Run Notebook | |
on: | |
workflow_dispatch: | |
schedule: | |
# Runs at 9:00 AM Central (14:00 UTC) | |
- cron: '0 14 * * *' | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
run-notebook: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Extract dependencies from colabtools | |
run: | | |
# Download setup.py | |
curl -s https://raw.githubusercontent.com/googlecolab/colabtools/refs/heads/main/setup.py > setup.py | |
# Extract DEPENDENCIES using Python | |
python3 - <<EOF | |
with open('setup.py', 'r') as f: | |
content = f.read() | |
# Find DEPENDENCIES tuple | |
start = content.find('DEPENDENCIES = (') | |
end = content.find(')', start) | |
deps = content[start:end+1] | |
# Execute the tuple to get the values | |
exec(deps) | |
# Write dependencies to requirements file | |
with open('colab_requirements.txt', 'w') as f: | |
for dep in DEPENDENCIES: | |
f.write(f"{dep}\n") | |
EOF | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
# Install colabtools dependencies | |
pip install -r colab_requirements.txt | |
# Install additional required packages | |
pip install -r requirements.txt | |
- name: Modify notebook | |
run: | | |
# Convert notebook to Python script for easier text processing | |
jupyter nbconvert --to script run_and_explore.ipynb | |
# Replace META_ID | |
sed -i 's/META_ID = ""/META_ID = "36Dm86NVjoTJ"/' run_and_explore.py | |
# Add no_upload parameter to run function | |
sed -i 's/url, meta_result = run(META_ID)/url, meta_result = run(META_ID, no_upload=True)/' run_and_explore.py | |
# Remove View the Report section (everything after the line containing "## View the Report") | |
sed -i '/^## View the Report/,$d' run_and_explore.py | |
# Convert back to notebook | |
jupyter nbconvert --to notebook run_and_explore.py | |
# Move converted notebook back to original name | |
mv run_and_explore.nbconvert.ipynb run_and_explore.ipynb | |
- name: Execute notebook | |
run: | | |
jupyter nbconvert --to notebook --execute run_and_explore.ipynb --output executed_notebook.ipynb | |
- name: Upload notebook | |
uses: actions/upload-artifact@v3 | |
with: | |
name: executed-notebook | |
path: executed_notebook.ipynb |