-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abstract single state runner #182
Merged
Merged
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3b3bfa8
modifying flatten_list_parameters to flatten any dim sampled parameters
arik-shurygin 8104f1d
first run at an abstract azure runner class
arik-shurygin 78c9443
checkpoint, load_posterior_particle half way
arik-shurygin b4d1ac3
redesigning the load_posterior_particles to use numpyro.handlers.subs…
arik-shurygin 4d7bb2a
Merge branch 'run-posterior-particle' of https://github.com/cdcent/cf…
arik-shurygin 9e03f4b
adding type hinting
arik-shurygin 0af3ab5
Merge branch 'run-posterior-particle' of https://github.com/cdcent/cf…
arik-shurygin 42973d3
checkpoint, merging in another branch
arik-shurygin 79e5ae6
installing pre-commit on this wsl
arik-shurygin 2522e74
implementing PR feedback
arik-shurygin 9ddfc85
tests caught a bug!
arik-shurygin 09ae7e9
merging main into this branch
arik-shurygin dd26d21
Merge branch 'run-posterior-particle' of https://github.com/cdcent/cf…
arik-shurygin 7b87be1
checkpoint, working on example
arik-shurygin 760d253
forgot to add example
arik-shurygin a2425e2
turning on pre-commit
arik-shurygin 7c7d93b
Merge branch 'main' of https://github.com/cdcent/cfa-scenarios-model …
arik-shurygin c1df54b
better type aliasing, completed setup of abstrac_azure_runner class
arik-shurygin 28d4284
Merge branch 'main' of https://github.com/cdcent/cfa-scenarios-model …
arik-shurygin 139ac8e
fixing type hint
arik-shurygin ead9038
adding save_config function to easily save config classes
arik-shurygin c2336b1
fixing bug with save_config
arik-shurygin 36e9805
implementing changes requested
arik-shurygin 410187b
small bugfix
arik-shurygin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,7 +1,50 @@ | ||
{ | ||
"INITALIZER_NAME": "base initializer covid", | ||
"SEROLOGICAL_DATA_PATH": "/input/data/serological-data/", | ||
"SIM_DATA_PATH": "/input/data/abm-data/abm_population.csv", | ||
"SEROLOGICAL_DATA_PATH": "/input/data/serological-data/sero-initializer-csvs", | ||
"CONTACT_MATRIX_PATH": "/input/data/demographic-data/contact_matrices", | ||
"POP_SIZE": 1000000, | ||
"INITIAL_INFECTIONS": 32000 | ||
"INITIAL_INFECTIONS": 32000, | ||
"WANING_PROTECTIONS": [ | ||
1.0, | ||
0.942, | ||
0.942, | ||
0.942, | ||
0.0 | ||
], | ||
"INFECTIOUS_PERIOD": 7.0, | ||
"EXPOSED_TO_INFECTIOUS": 3.6, | ||
"STRAIN_INTERACTIONS": [ | ||
[ | ||
1.0, | ||
0.7, | ||
0.49 | ||
], | ||
[ | ||
0.7, | ||
1.0, | ||
0.7 | ||
], | ||
[ | ||
0.49, | ||
0.7, | ||
1.0 | ||
] | ||
], | ||
"VACCINE_EFF_MATRIX": [ | ||
[ | ||
0, | ||
0.34, | ||
0.68 | ||
], | ||
[ | ||
0, | ||
0.24, | ||
0.48 | ||
], | ||
[ | ||
0, | ||
0.14, | ||
0.28 | ||
] | ||
] | ||
} |
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
85 changes: 85 additions & 0 deletions
85
exp/example_azure_experiment/example_single_state_runner.py
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,85 @@ | ||
""" | ||
An example script similar to example_end_to_end_run.py | ||
but adapted to show the differences between Azure runs and local ones. | ||
""" | ||
|
||
import argparse | ||
|
||
from mechanistic_model.abstract_azure_runner import AbstractAzureRunner | ||
from mechanistic_model.covid_sero_initializer import CovidSeroInitializer | ||
from mechanistic_model.mechanistic_runner import MechanisticRunner | ||
from mechanistic_model.static_value_parameters import StaticValueParameters | ||
from model_odes.seip_model import seip_ode | ||
|
||
|
||
class ExampleRunner(AbstractAzureRunner): | ||
# __init__ already implemented by the abstract case | ||
def __init__(self, azure_output_dir): | ||
super().__init__(azure_output_dir) | ||
|
||
# override the process state command since this is what | ||
# each individual runner must figure out for itself | ||
def process_state(self, state): | ||
""" | ||
A similar version to example_end_to_end_run.py but modified to run on Azure batch | ||
|
||
Parameters | ||
--------------- | ||
state: str | ||
the USPS postal code of the state, e.g. CA, OR, NY, TX | ||
""" | ||
# step 1: define your paths NOTE: These are all within the docker container! | ||
# /input is a MOUNTED drive that we upload these files into right before the job launched | ||
config_path = "/app/exp/example_azure_experiment/states/%s/" % state | ||
# global_config include definitions such as age bin bounds and strain definitions | ||
# Any value or data structure that needs context to be interpretted is here. | ||
GLOBAL_CONFIG_PATH = config_path + "config_global.json" | ||
# defines the init conditions of the scenario: pop size, initial infections etc. | ||
INITIALIZER_CONFIG_PATH = config_path + "config_initializer_covid.json" | ||
# defines the running variables, strain R0s, external strain introductions etc. | ||
RUNNER_CONFIG_PATH = config_path + "config_runner_covid.json" | ||
# sets up the initial conditions, initializer.get_initial_state() passed to runner | ||
initializer = CovidSeroInitializer( | ||
INITIALIZER_CONFIG_PATH, GLOBAL_CONFIG_PATH | ||
) | ||
# reads and interprets values from config, sets up downstream parameters | ||
# like beta = STRAIN_R0s / INFECTIOUS_PERIOD | ||
static_params = StaticValueParameters( | ||
initializer.get_initial_state(), | ||
RUNNER_CONFIG_PATH, | ||
GLOBAL_CONFIG_PATH, | ||
) | ||
# A runner that does ODE solving of a single run. | ||
runner = MechanisticRunner(seip_ode) | ||
# run for 200 days, using init state and parameters from StaticValueParameters | ||
solution = runner.run( | ||
initializer.get_initial_state(), | ||
tf=200, | ||
args=static_params.get_parameters(), | ||
) | ||
self.save_static_run_timelines(static_params, solution) | ||
return solution | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"-s", | ||
"--state", | ||
type=str, | ||
help="directory for the state to run, resembles USPS code of the state", | ||
required=True, | ||
) | ||
|
||
parser.add_argument( | ||
"-j", | ||
"--jobid", | ||
type=str, | ||
help="job-id of the state being run on Azure", | ||
required=True, | ||
) | ||
args = parser.parse_args() | ||
state = args.state | ||
jobid = args.jobid | ||
save_path = "/output/example_output/%s/%s/" % (jobid, state) | ||
runner = ExampleRunner(save_path) | ||
runner.process_state(state) |
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 +1,9 @@ | ||
# needs to exist to define a module | ||
import jax | ||
|
||
SEIC_Compartments = tuple[ | ||
jax.Array, | ||
jax.Array, | ||
jax.Array, | ||
jax.Array, | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't actually used this before... wonder if we should just remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will keep for now because we will eventually want to implement this rather than hardcoding in the runner like we did during SMH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. It's up to the person designing the inferer (likelihood and whatnot) to decide what's being pass into it... Just thought it being there is more confusing than useful