Skip to content

Commit

Permalink
Fix example_end_to_end_run.py so it can be run with poetry run (#257)
Browse files Browse the repository at this point in the history
- Fix permissions to make it executable
- Add hash-bang
- Automatically make output/

I also added testing the example to CI.
  • Loading branch information
ekr-cfa authored Oct 1, 2024
1 parent 92ab598 commit f8b9ea7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .github/workflows/test-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run example

on:
pull_request:
push:
branches: [main]

jobs:
example:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install global dependencies
run: |
pip install poetry
- name: Run Example
run: |
poetry install
poetry run examples/example_end_to_end_run.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Subject to change, current transmission dynamics follow this basic model

## Quick Start

As a first pass at running model ODEs and inference of parameters, take a look at `example_end_to_end_run.py` to see the process of running our model. You will probably need to `poetry install` to get started as well.
As a first pass at running model ODEs and inference of parameters, take a look at `example_end_to_end_run.py` to see the process of running our model. You will probably need to `poetry install` to get started as well, and then run it with `poetry run examples/example_end_to_end_run.py`.

Within `example_end_to_end_run.py` there is an optional `--infer` flag added from the terminal. This will kick off an example inference on synthetic data generated by the model itself and will produce different output.

Expand Down
6 changes: 6 additions & 0 deletions examples/example_end_to_end_run.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
A basic local covid example meant to show off the flow of running the mechanistic model
Expand All @@ -10,6 +11,7 @@
"""

import argparse
import os

import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -37,6 +39,10 @@
args = parser.parse_args()
infer = args.infer

# Make the output directory.
if not os.path.exists("output"):
os.mkdir("output")

# step 1: define your paths
config_path = "config/"
# global_config include definitions such as age bin bounds and strain definitions
Expand Down

0 comments on commit f8b9ea7

Please sign in to comment.