Skip to content

Commit

Permalink
Merge pull request #291 from ihmeuw/develop
Browse files Browse the repository at this point in the history
Release v1.1.0
  • Loading branch information
rmudambi committed May 3, 2023
2 parents 6f8dd07 + 2b64612 commit 53b7d1f
Show file tree
Hide file tree
Showing 58 changed files with 1,487 additions and 675 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
**1.1.0 - 05/03/23**

- Clean up randomness system
- Fix a bug in stratification when a stratum is empty
- Create a dedicated logging system
- Fix bug in preventing passing an Iterable to `rate_to_probability`

**1.0.4 - 01/25/23**

- Bugfixes for ResultsContext
Expand Down
3 changes: 3 additions & 0 deletions docs/nitpick-exceptions
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ py:class pandas.core.frame.DataFrame
py:class pandas.core.series.Series
py:class pandas.core.generic.PandasObject

# loguru
py:class loguru._logger.Logger

# vivarium
# Type aliases don't play nicely with sphinx when you import them
# elsewhere. Works fine for static type checker though. I think this
Expand Down
7 changes: 7 additions & 0 deletions docs/source/api_reference/framework/logging/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. automodule:: vivarium.framework.logging

.. toctree::
:maxdepth: 2
:glob:

*
1 change: 1 addition & 0 deletions docs/source/api_reference/framework/logging/manager.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. automodule:: vivarium.framework.logging.manager
1 change: 1 addition & 0 deletions docs/source/api_reference/framework/logging/utilities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. automodule:: vivarium.framework.logging.utilities
4 changes: 4 additions & 0 deletions docs/source/api_reference/framework/population/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=====================
Population Management
=====================

.. automodule:: vivarium.framework.population

.. toctree::
Expand Down
1 change: 0 additions & 1 deletion docs/source/api_reference/framework/randomness/core.rst

This file was deleted.

4 changes: 4 additions & 0 deletions docs/source/api_reference/framework/randomness/index.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
========================
Random Number Generation
========================

.. automodule:: vivarium.framework.randomness

.. toctree::
Expand Down
9 changes: 9 additions & 0 deletions docs/source/concepts/logging.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. _logging_concept:

=================
Framework Logging
=================

.. todo::

Everything here.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from setuptools import find_packages, setup

if __name__ == "__main__":

base_dir = Path(__file__).parent
src_dir = base_dir / "src"

Expand All @@ -33,7 +32,7 @@

install_requirements = [
"numpy",
"pandas",
"pandas<2.0.0",
"pyyaml>=5.1",
"scipy",
"click",
Expand Down
2 changes: 1 addition & 1 deletion src/vivarium/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__summary__ = "vivarium is a microsimulation framework built on top of the standard scientific python stack."
__uri__ = "https://github.com/ihmeuw/vivarium"

__version__ = "1.0.4"
__version__ = "1.1.0"

__author__ = "The vivarium developers"
__email__ = "vivarium.dev@gmail.com"
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/examples/boids/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Location:

configuration_defaults = {
"location": {
"width": 1000, # Width of our field
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/examples/boids/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Neighbors:

configuration_defaults = {"neighbors": {"radius": 10}}

def __init__(self):
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/examples/boids/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class Population:

configuration_defaults = {
"population": {
"colors": ["red", "blue"],
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/examples/disease_model/disease.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ def metrics(self, index, metrics):


class SISDiseaseModel:

configuration_defaults = {
"disease": {
"incidence_rate": 0.005,
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/examples/disease_model/intervention.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class TreatmentIntervention:

configuration_defaults = {
"intervention": {
"effect_size": 0.5,
Expand Down
2 changes: 0 additions & 2 deletions src/vivarium/examples/disease_model/observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Observer:

configuration_defaults = {
"mortality": {
"life_expectancy": 80,
Expand All @@ -24,7 +23,6 @@ def setup(self, builder: Builder):
builder.value.register_value_modifier("metrics", self.metrics)

def metrics(self, index: pd.Index, metrics: Dict):

pop = self.population_view.get(index)
metrics["total_population_alive"] = len(pop[pop.alive == "alive"])
metrics["total_population_dead"] = len(pop[pop.alive == "dead"])
Expand Down
2 changes: 1 addition & 1 deletion src/vivarium/examples/disease_model/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def setup(self, builder: Builder):
)

self.age_randomness = builder.randomness.get_stream(
"age_initialization", for_initialization=self.with_common_random_numbers
"age_initialization", initializes_crn_attributes=self.with_common_random_numbers
)
self.sex_randomness = builder.randomness.get_stream("sex_initialization")

Expand Down
2 changes: 0 additions & 2 deletions src/vivarium/examples/disease_model/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class Risk:

configuration_defaults = {
"risk": {
"proportion_exposed": 0.3,
Expand Down Expand Up @@ -50,7 +49,6 @@ def __repr__(self):


class RiskEffect:

configuration_defaults = {
"risk_effect": {
"relative_risk": 2,
Expand Down
1 change: 0 additions & 1 deletion src/vivarium/framework/artifact/hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ def _write_pandas_data(path: Path, entity_key: EntityKey, data: Union[PandasObj]
def _write_json_blob(path: Path, entity_key: EntityKey, data: Any):
"""Writes a Python object as json to the HDF file at the given path."""
with tables.open_file(str(path), "a") as store:

if entity_key.group_prefix not in store:
store.create_group("/", entity_key.type)

Expand Down
9 changes: 4 additions & 5 deletions src/vivarium/framework/artifact/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from typing import Any, Sequence, Union

import pandas as pd
from loguru import logger

from vivarium.config_tree import ConfigTree
from vivarium.framework.artifact.artifact import Artifact
Expand All @@ -37,6 +36,7 @@ def name(self):

def setup(self, builder):
"""Performs this component's simulation setup."""
self.logger = builder.logging.get_logger(self.name)
# because not all columns are accessible via artifact filter terms, apply config filters separately
self.config_filter_term = validate_filter_term(
builder.configuration.input_data.artifact_filter_term
Expand All @@ -63,9 +63,9 @@ def _load_artifact(self, configuration: ConfigTree) -> Union[Artifact, None]:
return None
artifact_path = parse_artifact_path_config(configuration)
base_filter_terms = get_base_filter_terms(configuration)
logger.debug(f"Running simulation from artifact located at {artifact_path}.")
logger.debug(f"Artifact base filter terms are {base_filter_terms}.")
logger.debug(f"Artifact additional filter terms are {self.config_filter_term}.")
self.logger.info(f"Running simulation from artifact located at {artifact_path}.")
self.logger.info(f"Artifact base filter terms are {base_filter_terms}.")
self.logger.info(f"Artifact additional filter terms are {self.config_filter_term}.")
return Artifact(artifact_path, base_filter_terms)

def load(self, entity_key: str, **column_filters: _Filter) -> Any:
Expand Down Expand Up @@ -233,7 +233,6 @@ def parse_artifact_path_config(config: ConfigTree) -> str:
path = Path(config.input_data.artifact_path)

if not path.is_absolute():

path_config = config.input_data.metadata("artifact_path")[-1]
if path_config["source"] is None:
raise ValueError("Insufficient information provided to find artifact.")
Expand Down

0 comments on commit 53b7d1f

Please sign in to comment.