Skip to content
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

Add running examples snakemake #78

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3017b44
small fixes
stitova-idm Sep 15, 2023
4b89048
Merge branch 'idm-main' into add_running_examples_snakemake
stitova-idm Sep 15, 2023
870508e
adding check that experiment succeeded before writing out experiment …
stitova-idm Sep 15, 2023
7d865a3
removing "wait_on_done" parameter as it's default and will be removed…
stitova-idm Sep 18, 2023
0ff0801
changing to cores = 1, because of the race condition
stitova-idm Sep 18, 2023
3452a44
updating requirements so jenkins works (gets the older urlib3)
stitova-idm Sep 18, 2023
ae26110
i think it's the slashes
stitova-idm Sep 18, 2023
6639a1c
debug and path cleanup
stitova-idm Sep 18, 2023
45e1bed
adding dowloand folder
stitova-idm Sep 18, 2023
b49cd1c
stalling from staging because emodpy-snt needs not-yet-released emodp…
stitova-idm Sep 18, 2023
0f0facc
to pick up unreleased malaria
stitova-idm Sep 18, 2023
d37f7b8
credentials update
stitova-idm Sep 18, 2023
f553e54
small updates. Thanks, @Zhaowei!
stitova-idm Sep 19, 2023
b6b4436
oops
stitova-idm Sep 19, 2023
6761884
adjustments
stitova-idm Sep 20, 2023
089a50e
commenting out analyzer that's failing because of comps login issues …
stitova-idm Sep 20, 2023
81aa6cf
deleting output files on start and at the end.
stitova-idm Sep 21, 2023
1f8d20b
testing
stitova-idm Sep 21, 2023
f298876
for debugging help
stitova-idm Sep 21, 2023
44d479b
fix paht
stitova-idm Sep 21, 2023
3cf478f
testing
stitova-idm Sep 21, 2023
e9f7b07
aaaahhhhhhhhh
stitova-idm Sep 21, 2023
be77dd3
gvsdgfserw
stitova-idm Sep 21, 2023
841a491
afadfas
stitova-idm Sep 21, 2023
98c8a2e
is it the touching?
stitova-idm Sep 21, 2023
b790614
sdfsaf
stitova-idm Sep 21, 2023
777df6e
IT WAS THE TOUCHING
stitova-idm Sep 21, 2023
2887af4
typo
stitova-idm Sep 21, 2023
757904a
making sims smaller
stitova-idm Sep 21, 2023
e1a3b5a
cleaning up before the run
stitova-idm Sep 21, 2023
20eb816
AGAIN
stitova-idm Sep 22, 2023
77330e3
das
stitova-idm Sep 22, 2023
38de13c
this runs please run
stitova-idm Sep 22, 2023
599dab4
THIS runs, why
stitova-idm Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/staging-snt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ podTemplate(
def wheelFile = sh(returnStdout: true, script: "find ./dist -name '*.whl'").toString().trim()
//def wheelFile = sh(returnStdout: true, script: "python3 ./.github/scripts/get_wheel_filename.py --package-file package_setup.py").toString().trim()
echo "This is the package file: ${wheelFile}"
sh "pip3 install $wheelFile --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple"
//sh "pip3 install $wheelFile --index-url=https://packages.idmod.org/api/pypi/pypi-production/simple"
sh "pip3 install $wheelFile --index-url=https://[email protected]:[email protected]/api/pypi/pypi-staging/simple --pre"
//sh "pip3 install dataclasses"
sh 'pip3 install keyrings.alt'
sh "pip3 freeze"
Expand Down Expand Up @@ -108,7 +108,7 @@ podTemplate(
echo "Running examples"
dir('examples') {
sh 'pip3 install snakemake'
sh 'snakemake --cores=10 --config python_version=python3'
sh 'snakemake --cores=1 --config python_version=python3'
}
}

Expand Down
238 changes: 130 additions & 108 deletions examples/Snakefile

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions examples/ben/example/run_1960-2004/run_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
with open("ben\\example\\run_1960-2004\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
with open("ben/example/run_1960-2004/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -87,7 +88,7 @@ def run_experiment(**kwargs):

experiment = _config_experiment(**kwargs)
_pre_run(experiment, **kwargs)
experiment.run(wait_until_done=True, wait_on_done=False)
experiment.run(**kwargs)
_post_run(experiment, **kwargs)


Expand All @@ -110,4 +111,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
11 changes: 6 additions & 5 deletions examples/ben/example/run_2005-2022/run_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
with open("ben\\example\\run_2005-2022\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
with open("ben/example/run_2005-2022/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -87,7 +88,7 @@ def run_experiment(**kwargs):

experiment = _config_experiment(**kwargs)
_pre_run(experiment, **kwargs)
experiment.run(wait_until_done=True, wait_on_done=False)
experiment.run(**kwargs)
_post_run(experiment, **kwargs)


Expand All @@ -110,4 +111,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
# Save experiment id to file to be used by snakefile
with open("monique\\calibration\\baseline_calibration\\01_serialize_transmission_sweep\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)

pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
# Save experiment id to file to be used by snakefile
with open("monique/calibration/baseline_calibration/01_serialize_transmission_sweep/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -87,7 +87,7 @@ def run_experiment(**kwargs):

experiment = _config_experiment(**kwargs)
_pre_run(experiment, **kwargs)
experiment.run(wait_until_done=True, wait_on_done=False)
experiment.run(**kwargs)
_post_run(experiment, **kwargs)


Expand All @@ -106,4 +106,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
# Save experiment id to file to be used by snakefile
with open(r"monique\\calibration\\baseline_calibration\\02_run_transmission_sweep\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
# Save experiment id to file to be used by snakefile
with open("monique/calibration/baseline_calibration/02_run_transmission_sweep/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -85,7 +86,7 @@ def run_experiment(**kwargs):

experiment = _config_experiment(**kwargs)
_pre_run(experiment, **kwargs)
experiment.run(wait_until_done=True, wait_on_done=False)
experiment.run(**kwargs)
_post_run(experiment, **kwargs)


Expand All @@ -104,4 +105,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings=False)
run_experiment(show_warnings=False, wait_until_done=True)
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
with open("monique\\calibration\\seasonality_calibration\\01_burnin_for_seasonalityCalib\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)

pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
with open("monique/calibration/seasonality_calibration/01_burnin_for_seasonalityCalib/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -84,7 +84,7 @@ def run_experiment(**kwargs):

experiment = _config_experiment(**kwargs)
_pre_run(experiment, **kwargs)
experiment.run(wait_until_done=True, wait_on_done=False)
experiment.run(**kwargs)
_post_run(experiment, **kwargs)


Expand All @@ -103,4 +103,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ def get_manager(**kwargs):
return calib_manager


def _post_run(suite_id, **kwargs):
"""
Add extra work after run calibration.
Args:
suite_id:
kwargs: additional parameters
Return:
None
"""
from idmtools.core import ItemType
suite = platform.get_item(suite_id, ItemType.SUITE)

if all([exp.succeeded for exp in suite.experiments]):
with open("monique/calibration/seasonality_calibration/02_seasonality_calibration/experiment_id.txt", "w") as fd:
fd.write("Calibration good.")


def run_calibration(directory: str = '.', **kwargs):
"""
Get configured calibration and run.
Expand All @@ -176,6 +193,7 @@ def run_calibration(directory: str = '.', **kwargs):
calib_manager = get_manager(**kwargs)
_pre_run(**kwargs)
calib_manager.run_calibration(**kwargs)
_post_run(calib_manager.suite_id, **kwargs)


if __name__ == "__main__":
Expand Down
9 changes: 5 additions & 4 deletions examples/monique/run_future_scenarios/run_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
with open("monique\\run_future_scenarios\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
pass
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
with open("monique/run_future_scenarios/experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)


def _config_experiment(**kwargs):
Expand Down Expand Up @@ -103,4 +104,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
8 changes: 5 additions & 3 deletions examples/monique/run_to_present/run_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ def _post_run(experiment: Experiment, **kwargs):
Return:
None
"""
with open("monique\\run_to_present\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
wait_until_done = kwargs.get('wait_until_done', None)
if wait_until_done and experiment.succeeded:
with open("monique\\run_to_present\\experiment_id.txt", "w") as fd:
fd.write(experiment.uid.hex)
pass


Expand Down Expand Up @@ -103,4 +105,4 @@ def run_experiment(**kwargs):
# dtk.setup(pathlib.Path(manifest.eradication_path).parent)
# os.chdir(os.path.dirname(__file__))
# print("...done.")
run_experiment(show_warnings_once=True)
run_experiment(show_warnings_once=True, wait_until_done=True)
4 changes: 2 additions & 2 deletions examples/update_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ def update_parameters_in_file(filepath, parameters: dict = None):
Helper function that updates file parameters to run examples in snakemake
Args:
filepath:
parameters: a dictionary formatted as: {"what to find in line": "what to replace the line with"}
parameters: a dictionary formatted as: {"what to find in line": "what to replace the entire line with"}

Returns:

"""
temp = "temp.ptxt"
temp = "temp.txt"
with open(temp, 'w') as new_file:
with open(filepath) as old_file:
for line in old_file:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-i https://packages.idmod.org/api/pypi/pypi-production/simple
emodpy-malaria~=3.1.1
emodpy-malaria
requests==2.29.0
idmtools_calibra~=1.0.9
idmtools-platform-comps~=1.7.7
scipy
Expand Down