vivarium-profiling 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vivarium_profiling-0.4.0/.github/CODEOWNERS +2 -0
- vivarium_profiling-0.4.0/.github/pull_request_template.md +21 -0
- vivarium_profiling-0.4.0/.github/workflows/update_readme.yml +32 -0
- vivarium_profiling-0.4.0/.gitignore +137 -0
- vivarium_profiling-0.4.0/CHANGELOG.rst +51 -0
- vivarium_profiling-0.4.0/CODEOWNERS +2 -0
- vivarium_profiling-0.4.0/Jenkinsfile +35 -0
- vivarium_profiling-0.4.0/LICENSE +29 -0
- vivarium_profiling-0.4.0/Makefile +116 -0
- vivarium_profiling-0.4.0/PKG-INFO +233 -0
- vivarium_profiling-0.4.0/README.rst +192 -0
- vivarium_profiling-0.4.0/artifact_requirements.txt +20 -0
- vivarium_profiling-0.4.0/environment.sh +156 -0
- vivarium_profiling-0.4.0/extraction_config_example.yaml +145 -0
- vivarium_profiling-0.4.0/pyproject.toml +77 -0
- vivarium_profiling-0.4.0/python_versions.json +1 -0
- vivarium_profiling-0.4.0/setup.cfg +4 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/__init__.py +5 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/components/__init__.py +0 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/components/risks/effect.py +45 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/__init__.py +0 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/data_keys.py +240 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/data_values.py +34 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/metadata.py +42 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/models.py +11 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/paths.py +10 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/constants/scenarios.py +29 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/data/__init__.py +0 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/data/builder.py +128 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/data/loader.py +257 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/model_specifications/branches/scenarios.yaml +7 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/model_specifications/model_spec_scaling.yaml +81 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/plugins/artifact.py +24 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/plugins/parser.py +419 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/templates/__init__.py +6 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/templates/analysis_template.ipynb +207 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/__init__.py +4 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/app_logging.py +89 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/cli.py +387 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/extraction.py +438 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/make_artifacts.py +243 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/notebook_generator.py +56 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/plotting.py +448 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/run_benchmark.py +223 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/run_profile.py +65 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/tools/summarize.py +190 -0
- vivarium_profiling-0.4.0/src/vivarium/profiling/utilities.py +151 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/PKG-INFO +233 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/SOURCES.txt +60 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/dependency_links.txt +1 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/entry_points.txt +5 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/requires.txt +37 -0
- vivarium_profiling-0.4.0/src/vivarium_profiling.egg-info/top_level.txt +1 -0
- vivarium_profiling-0.4.0/tests/__init__.py +0 -0
- vivarium_profiling-0.4.0/tests/conftest.py +102 -0
- vivarium_profiling-0.4.0/tests/plugins/test_parser.py +385 -0
- vivarium_profiling-0.4.0/tests/test_cli.py +158 -0
- vivarium_profiling-0.4.0/tests/test_extraction.py +409 -0
- vivarium_profiling-0.4.0/tests/test_run_benchmark.py +103 -0
- vivarium_profiling-0.4.0/tests/test_run_profile.py +45 -0
- vivarium_profiling-0.4.0/tests/test_sample.py +5 -0
- vivarium_profiling-0.4.0/tests/test_summarize.py +246 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Title: Summary, imperative, start upper case, don't end with a period
|
|
2
|
+
<!-- Ideally, <=50 chars. 50 chars is here..: -->
|
|
3
|
+
|
|
4
|
+
### Description
|
|
5
|
+
<!-- For use in commit message, wrap at 72 chars. 72 chars is here: -->
|
|
6
|
+
- *Category*: <!-- one of bugfix, data artifact, implementation, observers,
|
|
7
|
+
post-processing, refactor, revert, test, release, other/misc -->
|
|
8
|
+
- *JIRA issue*: https://jira.ihme.washington.edu/browse/MIC-XYZ
|
|
9
|
+
- *Research reference*: <!--Link to research documentation for code -->
|
|
10
|
+
|
|
11
|
+
### Changes and notes
|
|
12
|
+
<!--
|
|
13
|
+
Change description – why, what, anything unexplained by the above.
|
|
14
|
+
Include guidance to reviewers if changes are complex.
|
|
15
|
+
-->
|
|
16
|
+
|
|
17
|
+
### Verification and Testing
|
|
18
|
+
<!--
|
|
19
|
+
Details on how code was verified. Consider: plots, images, (small) csv files.
|
|
20
|
+
-->
|
|
21
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
# - invoked on push to any branch
|
|
3
|
+
# -----------------------------------------------------------------------------
|
|
4
|
+
name: update README
|
|
5
|
+
on: push
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
update-readme:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout code
|
|
12
|
+
uses: actions/checkout@v2
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: actions/setup-python@v2
|
|
15
|
+
with:
|
|
16
|
+
python-version: 3.11
|
|
17
|
+
- name: Update README
|
|
18
|
+
run: |
|
|
19
|
+
pip install packaging
|
|
20
|
+
python update_readme.py
|
|
21
|
+
- name: Commit and push changes
|
|
22
|
+
run: |
|
|
23
|
+
git config --local user.email "action@github.com"
|
|
24
|
+
git config --local user.name "github-actions"
|
|
25
|
+
git diff --quiet && git diff --staged --quiet || (
|
|
26
|
+
git add README.rst
|
|
27
|
+
git commit -am "update README with supported Python versions"
|
|
28
|
+
git pull --rebase origin ${{ github.ref_name }}
|
|
29
|
+
git push origin ${{ github.ref_name }}
|
|
30
|
+
)
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
|
|
53
|
+
# Translations
|
|
54
|
+
*.mo
|
|
55
|
+
*.pot
|
|
56
|
+
|
|
57
|
+
# Django stuff:
|
|
58
|
+
*.log
|
|
59
|
+
local_settings.py
|
|
60
|
+
db.sqlite3
|
|
61
|
+
db.sqlite3-journal
|
|
62
|
+
|
|
63
|
+
# Flask stuff:
|
|
64
|
+
instance/
|
|
65
|
+
.webassets-cache
|
|
66
|
+
|
|
67
|
+
# Scrapy stuff:
|
|
68
|
+
.scrapy
|
|
69
|
+
|
|
70
|
+
# Sphinx documentation
|
|
71
|
+
docs/_build/
|
|
72
|
+
|
|
73
|
+
# PyBuilder
|
|
74
|
+
target/
|
|
75
|
+
|
|
76
|
+
# Jupyter Notebook
|
|
77
|
+
.ipynb_checkpoints
|
|
78
|
+
|
|
79
|
+
# IPython
|
|
80
|
+
profile_default/
|
|
81
|
+
ipython_config.py
|
|
82
|
+
|
|
83
|
+
# pyenv
|
|
84
|
+
.python-version
|
|
85
|
+
|
|
86
|
+
# pipenv
|
|
87
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
88
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
89
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
90
|
+
# install all needed dependencies.
|
|
91
|
+
#Pipfile.lock
|
|
92
|
+
|
|
93
|
+
# celery beat schedule file
|
|
94
|
+
celerybeat-schedule
|
|
95
|
+
|
|
96
|
+
# SageMath parsed files
|
|
97
|
+
*.sage.py
|
|
98
|
+
|
|
99
|
+
# Environments
|
|
100
|
+
.env
|
|
101
|
+
.venv
|
|
102
|
+
env/
|
|
103
|
+
venv/
|
|
104
|
+
ENV/
|
|
105
|
+
env.bak/
|
|
106
|
+
venv.bak/
|
|
107
|
+
|
|
108
|
+
# Spyder project settings
|
|
109
|
+
.spyderproject
|
|
110
|
+
.spyproject
|
|
111
|
+
|
|
112
|
+
# Rope project settings
|
|
113
|
+
.ropeproject
|
|
114
|
+
|
|
115
|
+
# mkdocs documentation
|
|
116
|
+
/site
|
|
117
|
+
|
|
118
|
+
# mypy
|
|
119
|
+
.mypy_cache/
|
|
120
|
+
.dmypy.json
|
|
121
|
+
dmypy.json
|
|
122
|
+
|
|
123
|
+
# Pyre type checker
|
|
124
|
+
.pyre/
|
|
125
|
+
|
|
126
|
+
# Pycharm project settings
|
|
127
|
+
.idea/
|
|
128
|
+
|
|
129
|
+
# Version file
|
|
130
|
+
src/*/_version.py
|
|
131
|
+
|
|
132
|
+
# Copilot instructions
|
|
133
|
+
.github/copilot_instructions.md
|
|
134
|
+
.github/prompts/
|
|
135
|
+
|
|
136
|
+
# VS Code settings
|
|
137
|
+
.vscode/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
**0.4.0 - 05/11/26**
|
|
2
|
+
|
|
3
|
+
BREAKING CHANGE: Initial release from vivarium-suite monorepo. The import path is
|
|
4
|
+
now ``vivarium.profiling`` (was ``vivarium_profiling``). The ``vivarium-compat``
|
|
5
|
+
shim redirects the old path with a ``DeprecationWarning``; update imports before
|
|
6
|
+
that shim is removed.
|
|
7
|
+
|
|
8
|
+
**0.3.6 - 05/05/26**
|
|
9
|
+
|
|
10
|
+
Archive notice: this package is archived and no longer maintained. Please use the
|
|
11
|
+
vivarium-suite monorepo for future development. Refer to the README for more details.
|
|
12
|
+
|
|
13
|
+
**0.3.5 - 04/21/26**
|
|
14
|
+
|
|
15
|
+
- Update for VPH v5
|
|
16
|
+
|
|
17
|
+
**0.3.4 - 04/16/26**
|
|
18
|
+
|
|
19
|
+
- Tighten vivarium_build_utils pin
|
|
20
|
+
|
|
21
|
+
**0.3.3 - 04/15/26**
|
|
22
|
+
|
|
23
|
+
- Update vivarium_build_utils pin
|
|
24
|
+
|
|
25
|
+
**0.3.2 - 03/25/26**
|
|
26
|
+
|
|
27
|
+
- Remove upstream_repos from Jenkinsfile
|
|
28
|
+
|
|
29
|
+
**0.3.1 - 01/27/2026**
|
|
30
|
+
|
|
31
|
+
- Adjust the parameters for run_benchmark command
|
|
32
|
+
- Update makefile
|
|
33
|
+
|
|
34
|
+
**0.3.0 - 01/22/2026**
|
|
35
|
+
|
|
36
|
+
- Convert data ETL to click commands
|
|
37
|
+
- add configurable function call patterns
|
|
38
|
+
- add notebook support
|
|
39
|
+
|
|
40
|
+
**0.2.0 - 01/02/2026**
|
|
41
|
+
|
|
42
|
+
- Add MultiComponentParser with Causes, Risks, RiskEffects
|
|
43
|
+
|
|
44
|
+
**0.1.0 - 10/24/2025**
|
|
45
|
+
|
|
46
|
+
- Convert bash script to python
|
|
47
|
+
- add profiling CLI with scalene backend
|
|
48
|
+
|
|
49
|
+
**0.0.1 - 10/20/2025**
|
|
50
|
+
|
|
51
|
+
- Initial release
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* This Jenkinsfile simply loads the `reusable_pipeline` pipeline from the
|
|
2
|
+
vivariu_build_utils repository (https://github.com/ihmeuw/vivarium_build_utils).
|
|
3
|
+
|
|
4
|
+
vivarium_build_utils is loaded as a Jenkins shared library
|
|
5
|
+
(https://www.jenkins.io/doc/book/pipeline/shared-libraries/).
|
|
6
|
+
Jenkins shared library convention dictates that importable modules must be stored
|
|
7
|
+
in the 'vars' folder.
|
|
8
|
+
|
|
9
|
+
Jenkins shared libraries can be configured in the Jenkins UI:
|
|
10
|
+
* Manage Jenkins
|
|
11
|
+
* Configure System
|
|
12
|
+
* Global Pipeline Libraries section
|
|
13
|
+
* Library subsection
|
|
14
|
+
* Name: The Name for the lib
|
|
15
|
+
* Version: The branch you want to use. Throws an error
|
|
16
|
+
for nonexistent branches.
|
|
17
|
+
* Project Repository: Url to the shared lib
|
|
18
|
+
* Credentials: SSH key to access the repo
|
|
19
|
+
|
|
20
|
+
Note that updating the shared repo will take affect on the next pipeline invocation.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// Load the get_vbu_version function from vivarium_build_utils/bootstrap/
|
|
24
|
+
// (the directory to load from is defined in the Jenkins shared library configuration)
|
|
25
|
+
@Library("get_vbu_version@main") _
|
|
26
|
+
|
|
27
|
+
// Load the full vivarium_build_utils library at the expected version
|
|
28
|
+
library("vivarium_build_utils@${get_vbu_version()}")
|
|
29
|
+
|
|
30
|
+
reusable_pipeline(
|
|
31
|
+
scheduled_branches: ['main'],
|
|
32
|
+
skip_doc_build: true,
|
|
33
|
+
run_mypy: false,
|
|
34
|
+
env_reqs: 'ci_jenkins',
|
|
35
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright 2022 Institute for Health Metrics and Evaluation
|
|
4
|
+
All rights reserved
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Check if we're running in Jenkins
|
|
2
|
+
ifdef JENKINS_URL
|
|
3
|
+
# Files are already in workspace from shared library
|
|
4
|
+
MAKE_INCLUDES := .
|
|
5
|
+
else
|
|
6
|
+
# For local dev, use the installed vivarium_build_utils package if it exists
|
|
7
|
+
# First, check if we can import vivarium_build_utils and assign 'yes' or 'no'.
|
|
8
|
+
# We do this by importing the package in python and redirecting stderr to the null device.
|
|
9
|
+
# If the import is successful (&&), it will print 'yes', otherwise (||) it will print 'no'.
|
|
10
|
+
VIVARIUM_BUILD_UTILS_AVAILABLE := $(shell python -c "import vivarium_build_utils" 2>/dev/null && echo "yes" || echo "no")
|
|
11
|
+
# If vivarium_build_utils is available, get the makefiles path or else set it to empty
|
|
12
|
+
ifeq ($(VIVARIUM_BUILD_UTILS_AVAILABLE),yes)
|
|
13
|
+
MAKE_INCLUDES := $(shell python -c "from vivarium_build_utils.resources import get_makefiles_path; print(get_makefiles_path())")
|
|
14
|
+
else
|
|
15
|
+
MAKE_INCLUDES :=
|
|
16
|
+
endif
|
|
17
|
+
endif
|
|
18
|
+
|
|
19
|
+
# Set the package name as the last part of this file's parent directory path
|
|
20
|
+
PACKAGE_NAME = $(notdir $(CURDIR))
|
|
21
|
+
|
|
22
|
+
# Helper function for validating enum arguments
|
|
23
|
+
validate_arg = $(if $(filter-out $(2),$(1)),$(error Error: '$(3)' must be one of: $(2), got '$(1)'))
|
|
24
|
+
|
|
25
|
+
ifneq ($(MAKE_INCLUDES),) # not empty
|
|
26
|
+
# Include makefiles from vivarium_build_utils
|
|
27
|
+
include $(MAKE_INCLUDES)/base.mk
|
|
28
|
+
include $(MAKE_INCLUDES)/test.mk
|
|
29
|
+
else # empty
|
|
30
|
+
# Use this help message (since the vivarium_build_utils version is not available)
|
|
31
|
+
help:
|
|
32
|
+
@echo
|
|
33
|
+
@echo "For Make's standard help, run 'make --help'."
|
|
34
|
+
@echo
|
|
35
|
+
@echo "Most of our Makefile targets are provided by the vivarium_build_utils"
|
|
36
|
+
@echo "package. To access them, you need to create a development environment first."
|
|
37
|
+
@echo
|
|
38
|
+
@echo "make build-env"
|
|
39
|
+
@echo
|
|
40
|
+
@echo "USAGE:"
|
|
41
|
+
@echo " make build-env [type=<environment type>] [name=<environment name>] [py=<python version>] [include_timestamp=<yes|no>] [lfs=<yes|no>]"
|
|
42
|
+
@echo
|
|
43
|
+
@echo "ARGUMENTS:"
|
|
44
|
+
@echo " type [optional]"
|
|
45
|
+
@echo " Type of conda environment. Either 'simulation' (default) or 'artifact'"
|
|
46
|
+
@echo " name [optional]"
|
|
47
|
+
@echo " Name of the conda environment to create (defaults to <PACKAGE_NAME>_<TYPE>)"
|
|
48
|
+
@echo " include_timestamp [optional]"
|
|
49
|
+
@echo " Whether to append a timestamp to the environment name. Either 'yes' or 'no' (default)"
|
|
50
|
+
@echo " lfs [optional]"
|
|
51
|
+
@echo " Whether to install git-lfs in the environment. Either 'yes' or 'no' (default)"
|
|
52
|
+
@echo " py [optional]"
|
|
53
|
+
@echo " Python version (defaults to latest supported)"
|
|
54
|
+
@echo
|
|
55
|
+
@echo "After creating the environment:"
|
|
56
|
+
@echo " 1. Activate it: 'conda activate <environment_name>'"
|
|
57
|
+
@echo " 2. Run 'make help' again to see all newly available targets"
|
|
58
|
+
@echo
|
|
59
|
+
endif
|
|
60
|
+
|
|
61
|
+
build-env: # Create a new environment with installed packages
|
|
62
|
+
# Validate arguments - exit if unsupported arguments are passed
|
|
63
|
+
@allowed="type name lfs py include_timestamp"; \
|
|
64
|
+
for arg in $(filter-out build-env,$(MAKECMDGOALS)) $(MAKEFLAGS); do \
|
|
65
|
+
case $$arg in \
|
|
66
|
+
*=*) \
|
|
67
|
+
arg_name=$${arg%%=*}; \
|
|
68
|
+
if ! echo " $$allowed " | grep -q " $$arg_name "; then \
|
|
69
|
+
allowed_list=$$(echo $$allowed | sed 's/ /, /g'); \
|
|
70
|
+
echo "Error: Invalid argument '$$arg_name'. Allowed arguments are: $$allowed_list" >&2; \
|
|
71
|
+
exit 1; \
|
|
72
|
+
fi \
|
|
73
|
+
;; \
|
|
74
|
+
esac; \
|
|
75
|
+
done
|
|
76
|
+
|
|
77
|
+
# Handle arguments and set defaults
|
|
78
|
+
# type
|
|
79
|
+
@$(eval type ?= simulation)
|
|
80
|
+
@$(call validate_arg,$(type),simulation artifact,type)
|
|
81
|
+
# name
|
|
82
|
+
@$(eval name ?= $(PACKAGE_NAME)_$(type))
|
|
83
|
+
# timestamp
|
|
84
|
+
@$(eval include_timestamp ?= no)
|
|
85
|
+
@$(call validate_arg,$(include_timestamp),yes no,include_timestamp)
|
|
86
|
+
@$(if $(filter yes,$(include_timestamp)),$(eval override name := $(name)_$(shell date +%Y%m%d_%H%M%S)),)
|
|
87
|
+
# lfs
|
|
88
|
+
@$(eval lfs ?= no)
|
|
89
|
+
@$(call validate_arg,$(lfs),yes no,lfs)
|
|
90
|
+
# python version
|
|
91
|
+
@$(eval py ?= $(shell python -c "import json; versions = json.load(open('python_versions.json')); print(max(versions, key=lambda x: tuple(map(int, x.split('.')))))"))
|
|
92
|
+
|
|
93
|
+
conda create -n $(name) python=$(py) --yes
|
|
94
|
+
# Bootstrap vivarium_build_utils into the new environment
|
|
95
|
+
conda run -n $(name) pip install vivarium_build_utils
|
|
96
|
+
# Install packages based on type
|
|
97
|
+
@if [ "$(type)" = "simulation" ]; then \
|
|
98
|
+
conda run -n $(name) make install ENV_REQS=dev; \
|
|
99
|
+
conda install -n $(name) redis -c anaconda -y; \
|
|
100
|
+
elif [ "$(type)" = "artifact" ]; then \
|
|
101
|
+
conda run -n $(name) make install ENV_REQS=data; \
|
|
102
|
+
fi
|
|
103
|
+
@if [ "$(lfs)" = "yes" ]; then \
|
|
104
|
+
conda run -n $(name) conda install -c conda-forge git-lfs --yes; \
|
|
105
|
+
conda run -n $(name) git lfs install; \
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
@echo
|
|
109
|
+
@echo "Finished building environment"
|
|
110
|
+
@echo " name: $(name)"
|
|
111
|
+
@echo " type: $(type)"
|
|
112
|
+
@echo " git-lfs installed: $(lfs)"
|
|
113
|
+
@echo " python version: $(py)"
|
|
114
|
+
@echo
|
|
115
|
+
@echo "Don't forget to activate it with: 'conda activate $(name)'"
|
|
116
|
+
@echo
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vivarium-profiling
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Profiling and benchmarking tools for Vivarium simulations.
|
|
5
|
+
Author-email: The vivarium developers <vivarium.dev@gmail.com>
|
|
6
|
+
License: BSD 3-Clause
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/x-rst
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: vivarium-compat>=0.1.2
|
|
11
|
+
Requires-Dist: vivarium_dependencies[click,loguru,numpy,pandas,scipy,tables]
|
|
12
|
+
Requires-Dist: vivarium_build_utils<4.0.0,>=3.0.2
|
|
13
|
+
Requires-Dist: gbd_mapping>=4.1.6
|
|
14
|
+
Requires-Dist: vivarium>=4.1.2
|
|
15
|
+
Requires-Dist: vivarium_public_health>=5.0.0
|
|
16
|
+
Requires-Dist: jinja2
|
|
17
|
+
Requires-Dist: pyyaml
|
|
18
|
+
Requires-Dist: memory_profiler
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
|
+
Requires-Dist: seaborn
|
|
21
|
+
Requires-Dist: scalene
|
|
22
|
+
Requires-Dist: nbformat>=5.0
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
Requires-Dist: vivarium_dependencies[pytest]; extra == "test"
|
|
25
|
+
Provides-Extra: cluster
|
|
26
|
+
Requires-Dist: vivarium_cluster_tools>=2.1.17; extra == "cluster"
|
|
27
|
+
Provides-Extra: data
|
|
28
|
+
Requires-Dist: vivarium_inputs>=5.2.6; extra == "data"
|
|
29
|
+
Requires-Dist: vivarium-profiling[cluster]; extra == "data"
|
|
30
|
+
Provides-Extra: interactive
|
|
31
|
+
Requires-Dist: vivarium_dependencies[interactive]; extra == "interactive"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: vivarium-profiling[cluster,interactive,test]; extra == "dev"
|
|
34
|
+
Requires-Dist: vivarium_dependencies[lint]; extra == "dev"
|
|
35
|
+
Provides-Extra: ci-github
|
|
36
|
+
Requires-Dist: vivarium-profiling[test]; extra == "ci-github"
|
|
37
|
+
Requires-Dist: vivarium_dependencies[lint]; extra == "ci-github"
|
|
38
|
+
Provides-Extra: ci-jenkins
|
|
39
|
+
Requires-Dist: vivarium-profiling[ci_github,cluster]; extra == "ci-jenkins"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
==================
|
|
43
|
+
vivarium.profiling
|
|
44
|
+
==================
|
|
45
|
+
|
|
46
|
+
Profiling and benchmarking tools for Vivarium simulations.
|
|
47
|
+
|
|
48
|
+
.. contents::
|
|
49
|
+
:depth: 1
|
|
50
|
+
|
|
51
|
+
Installation
|
|
52
|
+
------------
|
|
53
|
+
|
|
54
|
+
``vivarium-profiling`` is published on PyPI as part of the vivarium-suite monorepo:
|
|
55
|
+
|
|
56
|
+
.. code-block:: bash
|
|
57
|
+
|
|
58
|
+
pip install vivarium-profiling
|
|
59
|
+
|
|
60
|
+
For local development against the monorepo source, see the monorepo README at
|
|
61
|
+
https://github.com/ihmeuw/vivarium-suite.
|
|
62
|
+
|
|
63
|
+
Supported Python versions: 3.10, 3.11
|
|
64
|
+
|
|
65
|
+
**HDF5 backing storage.** Vivarium uses the Hierarchical Data Format (HDF) for its
|
|
66
|
+
data artifacts, and the libraries pip needs to read these files may not be present
|
|
67
|
+
on your system. If you encounter HDF5-related errors, install the system tooling
|
|
68
|
+
into your conda env:
|
|
69
|
+
|
|
70
|
+
.. code-block:: bash
|
|
71
|
+
|
|
72
|
+
conda install hdf5
|
|
73
|
+
|
|
74
|
+
**git-lfs and data artifacts.** When cloning the monorepo, large data artifacts
|
|
75
|
+
are stored via ``git-lfs``. A clone that completes very quickly likely fetched
|
|
76
|
+
only the checksum files rather than the artifacts themselves, and your simulations
|
|
77
|
+
will fail. If you suspect this happened, pull the data explicitly:
|
|
78
|
+
|
|
79
|
+
.. code-block:: bash
|
|
80
|
+
|
|
81
|
+
git-lfs pull
|
|
82
|
+
|
|
83
|
+
Source layout
|
|
84
|
+
-------------
|
|
85
|
+
|
|
86
|
+
The package lives at ``src/vivarium/profiling/`` and provides these subpackages:
|
|
87
|
+
|
|
88
|
+
- ``components`` - custom Vivarium components used by the profiling models
|
|
89
|
+
- ``constants`` - project-level constants and metadata
|
|
90
|
+
- ``data`` - artifact builder helpers
|
|
91
|
+
- ``model_specifications`` - model spec YAMLs (e.g. ``model_spec_scaling.yaml``)
|
|
92
|
+
- ``plugins`` - the ``MultiComponentParser`` plugin
|
|
93
|
+
- ``templates`` - Jupyter notebook templates for analysis
|
|
94
|
+
- ``tools`` - the CLI entry points (``profile_sim``, ``run_benchmark``, ``summarize``,
|
|
95
|
+
``make_artifacts``)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
Profiling and Benchmarking
|
|
99
|
+
---------------------------
|
|
100
|
+
|
|
101
|
+
This repository provides tools for profiling and benchmarking Vivarium simulations
|
|
102
|
+
to analyze their performance characteristics. See the tutorials at
|
|
103
|
+
https://vivarium.readthedocs.io/en/latest/tutorials/running_a_simulation/index.html
|
|
104
|
+
and https://vivarium.readthedocs.io/en/latest/tutorials/exploration.html for general instructions
|
|
105
|
+
on running simulations with Vivarium.
|
|
106
|
+
|
|
107
|
+
Configuring Scaling Simulations
|
|
108
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
109
|
+
|
|
110
|
+
This repository includes a custom ``MultiComponentParser`` plugin that allows you to
|
|
111
|
+
easily create scaling simulations by defining multiple instances of diseases and risks
|
|
112
|
+
using a simplified YAML syntax.
|
|
113
|
+
|
|
114
|
+
To use the parser, add it to your model specification::
|
|
115
|
+
|
|
116
|
+
plugins:
|
|
117
|
+
required:
|
|
118
|
+
component_configuration_parser:
|
|
119
|
+
controller: "vivarium.profiling.plugins.parser.MultiComponentParser"
|
|
120
|
+
|
|
121
|
+
Then use the ``causes`` and ``risks`` multi-config blocks:
|
|
122
|
+
|
|
123
|
+
**Causes Configuration**
|
|
124
|
+
|
|
125
|
+
Define multiple disease instances with automatic numbering::
|
|
126
|
+
|
|
127
|
+
components:
|
|
128
|
+
causes:
|
|
129
|
+
lower_respiratory_infections:
|
|
130
|
+
number: 4 # Creates 4 disease instances
|
|
131
|
+
duration: 28 # Disease duration in days
|
|
132
|
+
observers: True # Auto-create DiseaseObserver components
|
|
133
|
+
|
|
134
|
+
This creates components named ``lower_respiratory_infections_1``,
|
|
135
|
+
``lower_respiratory_infections_2``, etc., each with its own observer if enabled.
|
|
136
|
+
|
|
137
|
+
**Risks Configuration**
|
|
138
|
+
|
|
139
|
+
Define multiple risk instances and their effects on causes::
|
|
140
|
+
|
|
141
|
+
components:
|
|
142
|
+
risks:
|
|
143
|
+
high_systolic_blood_pressure:
|
|
144
|
+
number: 2
|
|
145
|
+
observers: False # Set False for continuous risks
|
|
146
|
+
affected_causes:
|
|
147
|
+
lower_respiratory_infections:
|
|
148
|
+
effect_type: nonloglinear
|
|
149
|
+
measure: incidence_rate
|
|
150
|
+
number: 2 # Affects first 2 LRI instances
|
|
151
|
+
|
|
152
|
+
unsafe_water_source:
|
|
153
|
+
number: 2
|
|
154
|
+
observers: True # Set True for categorical risks
|
|
155
|
+
affected_causes:
|
|
156
|
+
lower_respiratory_infections:
|
|
157
|
+
effect_type: loglinear
|
|
158
|
+
number: 2
|
|
159
|
+
|
|
160
|
+
See ``model_specifications/model_spec_scaling.yaml`` for a complete working example
|
|
161
|
+
of a scaling simulation configuration.
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
Running Benchmark Simulations
|
|
165
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
166
|
+
|
|
167
|
+
The ``profile_sim`` command profiles runtime and memory usage for a single simulation of a vivarium model
|
|
168
|
+
given a model specification file. The underlying simulation model can
|
|
169
|
+
be any vivarium-based model, including the aforementioned scaling simulations as well as models in a
|
|
170
|
+
separate repository. This will generate, in addition to the standard simulation outputs, profiling data
|
|
171
|
+
depending on the profiler backend provided. By default, runtime profiling is performed with ``cProfile``, but
|
|
172
|
+
you can also use ``scalene`` for more detailed call stack analysis.
|
|
173
|
+
|
|
174
|
+
The ``run_benchmark`` command runs multiple iterations of one or more model specification, in order to compare
|
|
175
|
+
the results. It requires at least one baseline model for comparison,
|
|
176
|
+
and any other number of 'experiment' models to benchmark against the baseline, which can be passed via glob patterns.
|
|
177
|
+
You can separately configure the sample size of runs for the baseline and experiment models. The command aggregates
|
|
178
|
+
the profiling results and generates summary statistics and visualizations for a default set of important function calls
|
|
179
|
+
to help identify performance bottlenecks.
|
|
180
|
+
|
|
181
|
+
The command creates a timestamped directory containing:
|
|
182
|
+
|
|
183
|
+
- ``benchmark_results.csv``: Raw profiling data for each run
|
|
184
|
+
- ``summary.csv``: Aggregated statistics (automatically generated)
|
|
185
|
+
- ``performance_analysis.png``: Performance charts (automatically generated)
|
|
186
|
+
- Additional analysis plots for runtime phases and bottlenecks
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
Analyzing Benchmark Results
|
|
190
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
191
|
+
|
|
192
|
+
The ``summarize`` command processes benchmark results and creates visualizations.
|
|
193
|
+
This runs automatically after ``run_benchmark``, but can also be run manually
|
|
194
|
+
for custom analysis after the fact.
|
|
195
|
+
|
|
196
|
+
By default, this creates the following files in the specified output directory:
|
|
197
|
+
|
|
198
|
+
- ``summary.csv``: Aggregated statistics with mean, median, std, min, max
|
|
199
|
+
for all metrics, plus percent differences from baseline
|
|
200
|
+
- ``performance_analysis.png``: Runtime and memory usage comparison charts
|
|
201
|
+
- ``runtime_analysis_*.png``: Individual phase runtime charts (setup, run, etc.)
|
|
202
|
+
- ``bottleneck_fraction_*.png``: Bottleneck fraction scaling analysis
|
|
203
|
+
|
|
204
|
+
You can also generate an interactive Jupyter notebook including the same default plots
|
|
205
|
+
and summary dataframe with a ``--nb`` flag, in which case the command also creates an
|
|
206
|
+
``analysis.ipynb`` file in the output directory.
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
Customizing Result Extraction
|
|
210
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
211
|
+
|
|
212
|
+
By default, the benchmarking tools extract standard profiling metrics:
|
|
213
|
+
|
|
214
|
+
- Simulation phases: setup, initialize_simulants, run, finalize, report
|
|
215
|
+
- Common bottlenecks: gather_results, pipeline calls, population views
|
|
216
|
+
- Memory usage and total runtime
|
|
217
|
+
|
|
218
|
+
You can customize which metrics to extract by creating an extraction config YAML file.
|
|
219
|
+
See ``extraction_config_example.yaml`` for a complete annotated example.
|
|
220
|
+
|
|
221
|
+
**Basic Pattern Structure**::
|
|
222
|
+
|
|
223
|
+
patterns:
|
|
224
|
+
- name: my_function # Logical name for the metric
|
|
225
|
+
filename: my_module.py # Source file containing the function
|
|
226
|
+
function_name: my_function # Function name to match
|
|
227
|
+
extract_cumtime: true # Extract cumulative time (default: true)
|
|
228
|
+
extract_percall: false # Extract time per call (default: false)
|
|
229
|
+
extract_ncalls: false # Extract number of calls (default: false)
|
|
230
|
+
|
|
231
|
+
In turn, this yaml can be passed to the ``run_benchmark`` and ``summarize`` commands
|
|
232
|
+
using the ``--extraction_config`` flag. ``summarize`` will automatically create runtime
|
|
233
|
+
analysis plots for the specified functions.
|