Skip to content

Commit 59b8155

Browse files
Change run_benchmark arguments (#15)
* remove old model specs * Adjust how model specs are passed in * Update CHANGELOG for version 0.3.1 * update makefile to modern version (#16) --------- Co-authored-by: Steve Bachmeier <23350991+stevebachmeier@users.noreply.github.com>
1 parent 5dcc668 commit 59b8155

25 files changed

+112
-1728
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
**v0.3.1 - 01/27/2026**
2+
3+
- Adjust the parameters for run_benchmark command
4+
- Update makefile
5+
16
**v0.3.0 - 01/22/2026**
27

38
- Convert data ETL to click commands

Makefile

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ endif
1919
# Set the package name as the last part of this file's parent directory path
2020
PACKAGE_NAME = $(notdir $(CURDIR))
2121

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+
2225
ifneq ($(MAKE_INCLUDES),) # not empty
2326
# Include makefiles from vivarium_build_utils
2427
include $(MAKE_INCLUDES)/base.mk
@@ -35,15 +38,19 @@ help:
3538
@echo "make build-env"
3639
@echo
3740
@echo "USAGE:"
38-
@echo " make build-env name=<environment_name> [py=<python_version>]"
41+
@echo " make build-env [type=<environment type>] [name=<environment name>] [py=<python version>] [include_timestamp=<yes|no>] [lfs=<yes|no>]"
3942
@echo
4043
@echo "ARGUMENTS:"
41-
@echo " name [required] Name of the conda environment to create"
42-
@echo " py [optional] Python version (defaults to latest supported)"
43-
@echo
44-
@echo "EXAMPLE:"
45-
@echo " make build-env name=vivarium_dev"
46-
@echo " make build-env name=vivarium_dev py=3.9"
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)"
4754
@echo
4855
@echo "After creating the environment:"
4956
@echo " 1. Activate it: 'conda activate <environment_name>'"
@@ -52,18 +59,58 @@ help:
5259
endif
5360

5461
build-env: # Create a new environment with installed packages
55-
ifndef name
56-
@echo "Error: name is required and must be passed in as a keyword argument."
57-
@echo "Usage: make build-env name=<ENV_NAME> py=<PYTHON_VERSION>"
58-
@exit 1
59-
endif
60-
# Check if py is set, otherwise use the latest supported version
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
6191
@$(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+
6293
conda create -n $(name) python=$(py) --yes
6394
# Bootstrap vivarium_build_utils into the new environment
6495
conda run -n $(name) pip install vivarium_build_utils
65-
conda run -n $(name) make install
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)"
66114
@echo
67-
@echo "Environment built ($(name))"
68115
@echo "Don't forget to activate it with: 'conda activate $(name)'"
69116
@echo

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ depending on the profiler backend provided. By default, runtime profiling is per
178178
you can also use ``scalene`` for more detailed call stack analysis.
179179

180180
The ``run_benchmark`` command runs multiple iterations of one or more model specification, in order to compare
181-
the results. It requires at least one baseline model (specified as ``model_spec_baseline.yaml``) for comparison,
181+
the results. It requires at least one baseline model for comparison,
182182
and any other number of 'experiment' models to benchmark against the baseline, which can be passed via glob patterns.
183183
You can separately configure the sample size of runs for the baseline and experiment models. The command aggregates
184184
the profiling results and generates summary statistics and visualizations for a default set of important function calls

src/vivarium_profiling/model_specifications/model_spec_baseline.yaml

Lines changed: 0 additions & 81 deletions
This file was deleted.

src/vivarium_profiling/model_specifications/model_spec_causes_2x.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

src/vivarium_profiling/model_specifications/model_spec_causes_4x.yaml

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)