Skip to content

Commit

Permalink
v1.22.1 - June 24, 2024
Browse files Browse the repository at this point in the history
- Adding support for Custom_Node_Events and Custom_Coordinator_Events
- Updating a lot of documentation-related things
- Updating tests (fixes, improvements)
  • Loading branch information
Bridenbecker committed Sep 21, 2024
1 parent 95a88cf commit 75103cf
Show file tree
Hide file tree
Showing 21 changed files with 120 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.22.0
current_version = 1.22.1
commit = False
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[\+a-z]+)\.(?P<build>\d+))?
Expand Down
9 changes: 0 additions & 9 deletions docs/_templates/breadcrumbs.html

This file was deleted.

8 changes: 0 additions & 8 deletions docs/_templates/footer.html

This file was deleted.

2 changes: 2 additions & 0 deletions docs/_templates/footer_end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p><a href="https://www.gatesfoundation.org/Privacy-and-Cookies-Notice">Privacy and Cookies Notice</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
<a href="https://www.gatesfoundation.org/Terms-of-Use">Terms of Use</a></p>
3 changes: 3 additions & 0 deletions docs/_templates/footer_start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>emodpy is licensed under the <a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">Creative Commons
Attribution-ShareAlike 4.0 International License</a>.</p>
<p>Send documentation feedback to <a href="mailto:idmsupport@gatesfoundation.org" target="_top">idmsupport@gatesfoundation.org</a>.</p>
12 changes: 12 additions & 0 deletions docs/_templates/navbar-side.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{# Displays links to the top-level TOCtree elements, in the header navbar. #}
<nav class="navbar-nav">
<p class="sidebar-header-items__title"
role="heading"
aria-level="1"
aria-label="{{ _('') }}">
{{ _("") }}
</p>
<ul class="bd-navbar-elements navbar-nav">
{{ generate_header_nav_html(n_links_before_dropdown=20, dropdown_text=theme_header_dropdown_text) }}
</ul>
</nav>
14 changes: 14 additions & 0 deletions docs/_templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

{% block extrahead %}

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-NK4K647');</script>
<!-- End Google Tag Manager -->

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NK4K647"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

<link href="https://fonts.googleapis.com/css?family=Lato|Montserrat|Open+Sans" rel="stylesheet">

<link href="https://fonts.googleapis.com/css?family=Lato|Montserrat|Open+Sans" rel="stylesheet">

{% endblock %}
47 changes: 39 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os
import subprocess
import sys
import sphinx_rtd_theme
#import sphinx_rtd_theme
import configparser
from datetime import datetime
from urllib.request import urlretrieve
Expand Down Expand Up @@ -191,17 +191,48 @@
# The theme to use for HTML and HTML Help pages. See the docs for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = 'pydata_sphinx_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# docs.
# #
# html_theme_options = {
# }
html_theme_options = {
"collapse_navigation": False,
"navigation_depth": 3,
"show_prev_next": True,
"icon_links": [
{"name": "IDM docs", "url": "https://docs.idmod.org", "icon": "fas fa-home"},
{
"name": "GitHub",
"url": "https://github.com/institutefordiseasemodeling/emodpy",
"icon": "fab fa-github-square",
},
],
"navbar_end": ["theme-switcher", "navbar-icon-links"],
"secondary_sidebar_items": ["navbar-side"],
"header_links_before_dropdown": 5,
"footer_start": ["copyright", "footer_start"],
"footer_end": ["theme-version", "footer_end"],
}
html_sidebars = {
"**": ["sidebar-nav-bs", "page-toc"],
}
html_logo = "images/idm-logo-transparent.png"
html_favicon = "images/favicon.ico"
html_static_path = ['_static']
html_baseurl = "https://docs.idmod.org/projects/emodpy/en/latest"
html_context = {
'rtd_url': 'https://docs.idmod.org/projects/emodpy/en/latest',
"versions_dropdown": {
"latest": "devel (latest)",
"stable": "current (stable)",
},
"default_mode": "light",
}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
#html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# The name for this set of Sphinx documents.
# "<project> v<release> docs" by default.
Expand All @@ -215,7 +246,7 @@
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#
html_logo = "images/IDM_white.png"
#html_logo = "images/IDM_white.png"

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
Expand All @@ -231,7 +262,7 @@

html_css_files = ['theme_overrides.css']

html_js_files = ['show_block_by_os.js']
#html_js_files = ['show_block_by_os.js']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -297,7 +328,7 @@
search_project = os.environ["READTHEDOCS_PROJECT"]
search_version = os.environ["READTHEDOCS_VERSION"]

rtd_sphinx_search_default_filter = f"subprojects:{search_project_parent}/{search_version}"
rtd_sphinx_search_default_filter = f"subprojects:{search_project}/{search_version}"

rtd_sphinx_search_filters = {
"Search this project": f"project:{search_project}/{search_version}",
Expand Down
Binary file added docs/images/idm-logo-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ See :doc:`idmtools:api/idmtools_index` for a diagram showing how |IT_s| and each
related packages are used in an end-to-end workflow using |EMOD_s| as the
disease transmission model.

Contents
--------

.. toctree::
:maxdepth: 3
:titlesonly:
Expand All @@ -35,14 +38,12 @@ disease transmission model.
:titlesonly:
:caption: Related documentation

emodpy Jupyter notebooks <https://docs.idmod.org/projects/jupyter-notebooks-emodpy/en/latest/>
EMOD generic <https://docs.idmod.org/projects/emod-generic/en/latest/>
emod-api <https://docs.idmod.org/projects/emod-api/en/latest/>
idmtools <https://docs.idmod.org/projects/idmtools/en/latest/>


.. not sure what to do with catalyst. Not included yet.
.. nothing done with STAMP yet; not sure if it will be some sort of "plug-in" to the tools or totally standalone
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinxext.remoteliteralinclude~=0.4.0
sphinx~=6.2.1
sphinx-rtd-theme~=1.2.2
pydata-sphinx-theme
sphinxcontrib-napoleon~=0.7
plantweb~=1.2.1
sphinxcontrib-programoutput~=0.17
Expand All @@ -9,4 +9,5 @@ jupyterlab~=4.0.2
myst-parser~=2.0.0
readthedocs-sphinx-search~=0.3.1
sphinx-copybutton~=0.5.2
pygithub~=1.57
pygithub~=1.57
sphinxcontrib-jquery~=4.1
2 changes: 1 addition & 1 deletion emodpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa F821
from emodpy.defaults.iemod_default import IEMODDefault

__version__ = "1.22.0"
__version__ = "1.22.1"
15 changes: 11 additions & 4 deletions emodpy/emod_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,26 @@ def create_campaign_from_callback(self, builder, params=None):
adhoc_events = campaign.get_adhocs()
if dev_mode:
campaign.save()
# This might be a great place to reset the campaign object so users don't have to.
campaign.reset()

if len(adhoc_events) > 0:
if adhoc_events:
# print("Found adhoc events in campaign. Needs some special processing behind the scenes.")
logger.debug("Found adhoc events in campaign. Needs some special processing behind the scenes.")
if "Custom_Individual_Events" in self.config.parameters:
self.config.parameters.Custom_Individual_Events = [x for x in adhoc_events.keys()]
else:
reverse_map = {}
for user_name, builtin_name in adhoc_events.items():
reverse_map[builtin_name] = user_name
reverse_map[builtin_name] = user_name
self.config.parameters["Event_Map"] = reverse_map
# checking attributes because if using older emod-api whose campaign doesn't have them,
# we don't want to fail, just move on.
if hasattr(campaign, "get_custom_coordinator_events") and "Custom_Coordinator_Events" in self.config.parameters:
self.config.parameters.Custom_Coordinator_Events = campaign.get_custom_coordinator_events()
if hasattr(campaign, "get_custom_node_events") and "Custom_Node_Events" in self.config.parameters:
self.config.parameters.Custom_Node_Events = campaign.get_custom_node_events()

# This might be a great place to reset the campaign object so users don't have to.
campaign.reset()

def create_demog_from_callback(self, builder, from_sweep=False, params=None):
if builder is None:
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ click~=7.1
idmtools~=1.7
idmtools-platform-comps~=1.7
idmtools-models~=1.7
emod-api~=1.24
emod-api~=1.30
matplotlib
astor
astunparse
bs4
keyring
pyCOMPS~=2.6
requests==2.29.0
xmlrunner~=1.7.7
pytest==8.1.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@
setup_requires=setup_requirements,
test_suite='tests',
extras_require=extras,
version='1.22.0'
version='1.22.1'
)
3 changes: 1 addition & 2 deletions tests/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
output_dir = os.path.join(current_directory, "output")
serialization_files_dir = os.path.join(output_dir, "serialization_files", "output")

sft_id = "e5d5ab18-cfcf-ec11-92e9-f0921c167864"
sft_id_file = os.path.join(current_directory, "stage_sif.id")
sft_id_file = "stage_sif.id"

demographics_folder = os.path.join(current_directory, "inputs", "demographics")
if not os.path.isdir(demographics_folder):
Expand Down
1 change: 0 additions & 1 deletion tests/my_sif.sif

This file was deleted.

48 changes: 16 additions & 32 deletions tests/test_emod_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,6 @@ def test_from_files(self):
implicit_config_set_fns=self.demog.implicits),
config_out_path=self.config_path)

# workaround for https://github.com/InstituteforDiseaseModeling/emodpy/issues/358
import emod_api.schema_to_class as s2c
with open(self.config_path) as conf:
config_rod = json.load(conf, object_hook=s2c.ReadOnlyDict)
config_rod.parameters.Enable_Demographics_Builtin = 1
del config_rod.parameters["Demographics_Filenames"]
with open(self.config_path, "w") as outfile:
json.dump(config_rod, outfile, sort_keys=True, indent=4)

task = EMODTask.from_files(
eradication_path=self.eradication_path,
config_path=self.config_path,
Expand Down Expand Up @@ -214,10 +205,10 @@ def test_from_files(self):

del sim.task.config["parameters"]["Enable_Demographics_Builtin"]
del sim.task.config["parameters"]["Demographics_Filenames"]
del config["Demographics_Filenames"]
del config["Enable_Demographics_Builtin"]

self.assertEqual(config, sim.task.config["parameters"])

# Assert the right demo file is loaded in demographics.assets
self.assertEqual(self.demo_path, sim.task.demographics.assets[0].absolute_path)

Expand All @@ -234,30 +225,26 @@ def test_from_files_config_only(self):
def test_from_files_valid_customReport(self):
self.prepare_input_files()

def set_param_fn(config, implicit_config_set_fns):
config.parameters.Enable_Demographics_Builtin = 0
config.parameters.Base_Infectivity_Constant = 1
config.parameters.Incubation_Period_Constant = 1
config.parameters.Infectious_Period_Constant = 1
config.parameters.Base_Infectivity_Distribution = 'CONSTANT_DISTRIBUTION'
config.parameters.Incubation_Period_Distribution = 'CONSTANT_DISTRIBUTION'
config.parameters.Infectious_Period_Distribution = 'CONSTANT_DISTRIBUTION'
config.parameters.x_Base_Population = 0.001
config.parameters.Simulation_Duration = 10
config.parameters.Start_Time = 0
for fn in implicit_config_set_fns:
config = fn(config)
return config

dfs.write_config_from_default_and_params(config_path=self.default_config_file,
set_fn=partial(set_param_fn,
implicit_config_set_fns=self.demog.implicits),
config_out_path=self.config_path)

# workaround for https://github.com/InstituteforDiseaseModeling/emodpy/issues/358
import emod_api.schema_to_class as s2c
with open(self.config_path) as conf:
config_rod = json.load(conf, object_hook=s2c.ReadOnlyDict)
#config_rod.parameters.Enable_Demographics_Builtin = 1
#del config_rod.parameters["Demographics_Filenames"]
config_rod.parameters['Base_Infectivity_Constant'] = 1
config_rod.parameters['Incubation_Period_Constant'] = 1
config_rod.parameters['Infectious_Period_Constant'] = 1
config_rod.parameters['Base_Infectivity_Distribution'] = 'CONSTANT_DISTRIBUTION'
config_rod.parameters['Incubation_Period_Distribution'] = 'CONSTANT_DISTRIBUTION'
config_rod.parameters['Infectious_Period_Distribution'] = 'CONSTANT_DISTRIBUTION'
config_rod.parameters['x_Base_Population'] = 0.001
config_rod.parameters['Simulation_Duration'] = 10
config_rod.parameters['Start_Time'] = 0

with open(self.config_path, "w") as outfile:
json.dump(config_rod, outfile, sort_keys=True, indent=4)

custom_reports_path = os.path.join(manifest.current_directory, "inputs", "custom_reports.json")

task = EMODTask.from_files(
Expand Down Expand Up @@ -379,7 +366,6 @@ def build_demog_and_mig():
return demog, mig_data

self.prepare_schema_and_eradication()


print(f"Telling emod-api to use {self.schema_path} as schema.")
ob.schema_path = self.schema_path
Expand Down Expand Up @@ -662,5 +648,3 @@ def test_add_py_path(self):
self.assertTrue(task.use_embedded_python)

self.assertIn(f"--python-script-path './Assets/python;{pypackage_path};{virtual_path}'", str(task.command))


6 changes: 6 additions & 0 deletions tests/test_experiment_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# current_directory = os.path.dirname(os.path.realpath(__file__))
# BIN_PATH = os.path.join(current_directory, "..", "examples", "inputs", "bin")
# INPUT_PATH = os.path.join(current_directory, "..", "examples", "serialization", "inputs")
sif_path = manifest.sft_id_file


@pytest.mark.comps
Expand Down Expand Up @@ -75,6 +76,7 @@ def test_mix_tasks_in_experiment(self):
ep4_path=manifest.ep4_path)
task.tags = {"idmtools": "idmtools-automation", "string_tag": "test", "number_tag": 123}
task.set_parameter("Enable_Immunity", 0)
task.set_sif(sif_path)

# User builder to create simulations
num_sims = 3
Expand All @@ -92,6 +94,7 @@ def test_mix_tasks_in_experiment(self):
demographics_paths=None,
eradication_path=eradication_path,
ep4_path=manifest.ep4_path)
task1.set_sif(sif_path)
# create another TemplatedSimulations with this task1
ts1 = TemplatedSimulations([builder], base_task=task1)

Expand All @@ -106,6 +109,9 @@ def test_mix_tasks_in_experiment(self):
sims = experiment.simulations
self.assertEqual(len(sims), 7)

self.assertTrue(experiment.succeeded, msg=f"Experiment {experiment.uid} failed.\n")
print(f"Experiment {experiment.uid} succeeded.")

def test_create_suite(self):
from idmtools.entities.suite import Suite
from COMPS.Data import Suite as CompsSuite
Expand Down
Loading

0 comments on commit 75103cf

Please sign in to comment.