Skip to content

Commit d09b0e7

Browse files
authored
Merge pull request #2 from ActivitySim/feature/data-assets
Add interactive model experiment suites and prepare 0.1.1
2 parents 3af49a4 + 6bc8f74 commit d09b0e7

18 files changed

Lines changed: 1924 additions & 47 deletions

‎README.md‎

Lines changed: 207 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ uvx abench --help
1111
uvx abench experiments.yaml
1212
```
1313

14-
For a specific release use `uvx abench@0.1.0 experiments.yaml`; use
14+
For a specific release use `uvx abench@0.1.1 experiments.yaml`; use
1515
`uvx abench@latest` to refresh to the latest release. Docker and model data must
1616
still be available locally. macOS and Linux hosts are supported.
1717

@@ -41,13 +41,45 @@ promised to work. Build/runtime failures retain diagnostics and a failure report
4141

4242
## Named experiment files
4343

44+
You can pass a model directory instead of a YAML file:
45+
46+
```bash
47+
abench /path/to/model
48+
```
49+
50+
Abench looks for `.yaml` and `.yml` files directly inside `/path/to/model/.abench/`
51+
(no recursive search). In a terminal it lists them alphabetically and asks which
52+
experiment to run, then prompts for that experiment's inputs. Enter chooses the
53+
first file; a single file still gets a selection prompt. Only the selected file
54+
is loaded. `run`, `validate`, and `prepare` all support directory selection.
55+
56+
`abench /path/to/model --help` lists available files without prompting or running
57+
anything. Missing `.abench` directories and empty file lists produce clear errors.
58+
Without a terminal, or with `--non-interactive`, one file is selected automatically;
59+
multiple files require passing the desired YAML path directly.
60+
61+
Relative paths remain relative to the selected YAML file. For a file inside
62+
`.abench`, use `model_dir: ..` and, for example, `data_dir: ../data_full` and
63+
`output_root: ../benchmark-runs/run-${timestamp}` to reference the parent model.
64+
For declared downloads, keep unpack destinations inside `.abench` (for example,
65+
`unpack: data_full` with `data_dir: data_full`); asset destinations cannot use `..`.
66+
Moving an existing suite into `.abench` requires reviewing its paths.
67+
68+
4469
Write common options once and override only what differs between runs:
4570

4671
```yaml
4772
schema_version: 1
73+
inputs:
74+
households:
75+
type: integer
76+
default: 28365
77+
minimum: 0
78+
warmup_households:
79+
type: integer
80+
default: 5000
81+
minimum: 1
4882
vars:
49-
households: 28365
50-
warmup_households: 5000
5183
model: /path/to/sandag-abm3-example
5284
output_root: ./results/sandag-${timestamp}
5385
defaults:
@@ -86,14 +118,132 @@ in the repository. Its paths assume abench and the SANDAG repository are sibling
86118
The pinned `main` revision is the one used in the earlier trials, not a moving
87119
branch reference.
88120

121+
To compare **current main against a PR**, named suites also accept source mappings
122+
with `branch` or `pr` in place of `commit`:
123+
124+
```yaml
125+
schema_version: 1
126+
inputs:
127+
activitysim_pr:
128+
type: integer
129+
required: true
130+
minimum: 1
131+
description: ActivitySim PR number to compare against current main
132+
output_root: benchmark-runs/mtc-${timestamp}
133+
defaults:
134+
profile: mtc
135+
households: 500000
136+
multiprocess: true
137+
processes: 4
138+
sharrow: true
139+
sources:
140+
- sharrow=ActivitySim/sharrow@fc175b27d8e0c5d202721c67d96b050e6117b235
141+
runs:
142+
main:
143+
sources:
144+
- name: activitysim
145+
repository: ActivitySim/activitysim
146+
branch: main
147+
pr:
148+
label: ActivitySim PR ${activitysim_pr}
149+
sources:
150+
- name: activitysim
151+
repository: ActivitySim/activitysim
152+
pr: ${activitysim_pr}
153+
```
154+
155+
Each mapping must provide exactly one of `commit`, `branch`, or `pr`. Branch/PR
156+
selectors work for any source package in a suite, including extras/subdirectories.
157+
Abench uses host Git and network access to resolve each selector once per suite,
158+
before running models, and passes only exact commits to the builds. `pr` selects
159+
`refs/pull/<number>/head` in the named repository, including PRs from forks;
160+
it does **not** select the synthetic merge commit. Use a positive integer PR number.
161+
`branch` names the branch without `refs/heads/`.
162+
163+
The resolved commits are printed and recorded in `suite.json` alongside the
164+
original YAML, and in each experiment's source provenance. A new invocation
165+
resolves the selectors again, including `validate` and `prepare`. To reproduce an
166+
earlier suite, replace selectors with `commit: <recorded-full-SHA>`. CLI overrides
167+
and model profiles still require exact commits.
168+
169+
Start the suite and answer its input prompts:
170+
171+
```bash
172+
uvx abench ./activitysim-prototype-mtc/abench.yaml
173+
# Preflight the same selection without running benchmarks:
174+
uvx abench validate ./activitysim-prototype-mtc/abench.yaml
175+
```
176+
177+
Declare user-facing settings in `inputs`, and keep internal reusable values and
178+
expressions in `vars`. Only inputs can be overridden. For example:
179+
180+
```yaml
181+
inputs:
182+
households:
183+
type: integer
184+
default: 500000
185+
minimum: 0
186+
description: Households to sample; 0 uses the full population
187+
mode:
188+
type: string
189+
default: chunked
190+
choices: [chunked, unchunked]
191+
sharrow:
192+
type: boolean
193+
default: true
194+
vars:
195+
label: "${mode}, ${households} households"
196+
```
197+
198+
In a terminal, run, validate, and prepare prompt for each input in YAML order.
199+
Press Enter to accept a displayed default. Required inputs have no default and
200+
must be entered; empty or invalid answers prompt again with an explanation.
201+
Ctrl-C cancels before source resolution or downloads. Selected values are printed
202+
and saved in `suite.json` as `input_values`.
203+
204+
For scripting, `--non-interactive` uses defaults and supplied values without
205+
prompting. Non-terminal stdin behaves the same way; missing required inputs fail
206+
instead of hanging. Repeatable `--set NAME=VALUE` can supply values explicitly;
207+
these inputs are not prompted. Quote
208+
arguments containing spaces, for example `--set 'label=My experiment'` if `label`
209+
is declared as a string input. `abench experiment.yaml --help` lists the file's
210+
inputs, descriptions, defaults, and constraints without requiring input values,
211+
contacting GitHub, downloading data, or creating outputs.
212+
213+
- Every input requires a `type`: `string`, `integer`, `number`, or `boolean`.
214+
Give it either a typed YAML `default` or `required: true`, but not both.
215+
- Optional `choices` restricts allowed values; `minimum`/`maximum` are inclusive
216+
bounds for numeric inputs. Numbers must be finite. Boolean overrides accept
217+
`true` or `false` (case insensitive), not `yes`, `no`, `1`, or `0`.
218+
- Values are converted according to their declared type, never parsed as YAML.
219+
Strings retain literal text, including `=`, spaces, and `${...}`. Defaults and
220+
input declarations are literal too; use `vars` for derived expressions.
221+
- Defaults are applied first, followed by command-line overrides, then `${...}`
222+
expansion. Inputs and vars share one namespace; duplicate names and the
223+
reserved name `timestamp` are errors. Input names use letters, digits, and
224+
underscores and cannot start with a digit.
225+
- Unknown inputs, duplicate overrides, and invalid explicit values fail before
226+
source resolution or downloads. Missing required inputs prompt in a terminal
227+
and fail in non-interactive mode. There is no overriding vars.
228+
- The YAML file is unchanged. `suite.json` records typed `cli_overrides`, effective
229+
`input_values`, the expanded configuration, and exact source resolutions.
230+
`experiments.yaml` preserves the original file, so replay its recorded overrides
231+
too when reproducing a run.
232+
233+
`branch: main` is freshly resolved on **every launch**; there is no saved branch
234+
SHA to update manually. For the MTC example, enter the PR number when prompted,
235+
then press Enter twice to accept 500,000 households and 4 processes.
236+
237+
These features are available in abench 0.1.1 and later.
238+
89239
- `defaults` accepts CLI options using underscores (`shm_size`, `config_overlay`,
90240
etc.). Use `multiprocess: false` for serial execution and `sharrow: false` to
91241
disable Sharrow. `sources` accepts the same strings/mappings as model profiles.
92242
- `runs` is an ordered mapping of names to overrides. Each run inherits defaults;
93243
ordinary values and lists are replaced. **Sources merge by normalized package
94244
name**, so changing ActivitySim does not discard the shared Sharrow pin.
95-
- `${name}` substitutes a reusable scalar from `vars`; terms can reference other
96-
terms. A whole-value reference preserves its type, including numbers/booleans.
245+
- `${name}` substitutes a scalar from `inputs` or `vars`; vars can reference
246+
other vars and inputs. A whole-value reference preserves its type, including numbers/booleans.
97247
Undefined references and cycles are errors. No shell or environment expansion
98248
is performed. `${timestamp}` is a built-in UTC launch identifier shared by all
99249
runs, with microseconds to avoid reusing output directories.
@@ -108,13 +258,19 @@ branch reference.
108258
order. Failure stops the suite and retains partial results. The combined report
109259
is `output_root/comparison.html`; individual runs retain their own reports.
110260
`experiments.yaml` and `suite.json` record the original file and expanded plan.
111-
- File invocations do not accept additional CLI overrides. Edit `defaults` or the
112-
relevant run to keep the file a complete description of the experiment.
261+
- File invocations accept `--set` and `--non-interactive`; other model options belong
262+
in `defaults` or the relevant run.
113263

114264
This experiment file describes **which tests to run**. A model profile such as
115265
`benchmark.yaml` describes **how to configure a model**, and remains reusable
116266
across suites.
117267

268+
Terminal progress identifies the experiment number, image build, warmup, and
269+
measured attempts/retries. Builds and model phases print elapsed time every
270+
15 seconds; model phases also show current and peak cgroup memory when samples
271+
are available. Full console output stays in the printed log paths. These are
272+
status updates, not an estimated completion percentage.
273+
118274
## Run controls
119275

120276
- `--single-process` (default), or `--multiprocess --processes N`. The count applies
@@ -349,3 +505,47 @@ benchmark. See LICENSE for the retained BSD license.
349505

350506
See [RELEASING.md](https://github.com/ActivitySim/abench/blob/main/RELEASING.md)
351507
for Trusted Publishing setup and release instructions.
508+
509+
## Downloading model data
510+
511+
Experiment suites may declare `data_assets` using ActivitySim's external-example
512+
asset names, URLs, SHA-256 checksums, and `unpack` destinations:
513+
514+
```yaml
515+
data_assets:
516+
name: prototype_mtc_extended
517+
assets:
518+
data_full.tar.zst:
519+
url: https://github.com/ActivitySim/activitysim-prototype-mtc/releases/download/v1.3.4/data_full.tar.zst
520+
sha256: b402506a61055e2d38621416dd9a5c7e3cf7517c0a9ae5869f6d760c03284ef3
521+
unpack: data_full
522+
```
523+
524+
`abench experiment.yaml` prepares these assets before validating model inputs or
525+
starting Docker. `abench prepare experiment.yaml` only prepares data. `abench
526+
validate experiment.yaml` remains read-only: it checks declarations and requires
527+
inputs to be present (use `prepare` first for a fresh clone). Asset destinations
528+
are relative to the experiment YAML, regardless of `model_dir`; point each run's
529+
`data_dir` to the appropriate destination. Variable substitutions also work here.
530+
531+
The default download cache is exactly
532+
`platformdirs.user_cache_dir("ActivitySim")/External-Examples/<name>/`—the same
533+
layout used by `activitysim.examples.external.download_external_example`.
534+
`name` is optional; `cache_dir` can override the root before appending `name`.
535+
Keep names and checksums identical to ActivitySim's declarations to share files.
536+
For assets cached by direct `download_asset(link=True)` calls, set `cache_dir`
537+
to that call's `platformdirs.user_data_dir("ActivitySim")` and omit `name`.
538+
No host ActivitySim installation is needed.
539+
540+
Checksums are required and verified before reuse. For a `.gz` URL whose asset name
541+
omits `.gz`, the checksum covers the decompressed file, as in ActivitySim.
542+
Archives (`.tar.zst`, `.tar.gz`, `.zip`) use the archive checksum and preserve their
543+
internal paths when unpacking. Verified extracted contents are cached under
544+
`.abench-extracted/<sha256>/` beside the archive. Whole unpacked directories are
545+
linked to the suite, and abench resolves `data_dir` before Docker mounts it.
546+
Individual files are copied so external file symlinks cannot break inside Docker.
547+
Existing destinations must match; modified inputs are never silently replaced.
548+
Archive links, special files, and paths escaping the destination are rejected.
549+
The original instructions and resolved cache locations are saved in `suite.json`.
550+
551+
Data preparation is available in abench 0.1.1 and later.

‎examples/sandag-chunked.yaml‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
# Run from any directory: abench /path/to/abench/examples/sandag-chunked.yaml
22
schema_version: 1
3+
inputs:
4+
households:
5+
type: integer
6+
default: 28365
7+
minimum: 0
8+
description: Households to sample from benchmarking-data; 0 uses all
9+
processes:
10+
type: integer
11+
default: 4
12+
minimum: 1
13+
warmup_households:
14+
type: integer
15+
default: 5000
16+
minimum: 1
317
vars:
4-
households: 28365
518
model: ../../sandag-abm3-example
619
activitysim_main: 5c6fae24a91a57a2d6dfc2e1dbe062a61d94545a
720
activitysim_pr1110: 51e298a84276813946e1d623c9a5785e078e022f
@@ -12,11 +25,11 @@ defaults:
1225
data_dir: ${model}/benchmarking-data
1326
config_overlay: ["${model}/configs_explicit_chunk"]
1427
multiprocess: true
15-
processes: 4
28+
processes: ${processes}
1629
sharrow: true
1730
households: ${households}
18-
# The 5000-household cache build misses some cache builds, so this test uses more
19-
warmup_households: 5000
31+
# Cache misses in the measured run trigger a retry using the compiled flows.
32+
warmup_households: ${warmup_households}
2033
memory: 80g
2134
shm_size: 8g
2235
platform: linux/arm64

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
requires-python = ">=3.10"
1111
license = "BSD-3-Clause"
1212
license-files = ["LICENSE"]
13-
dependencies = ["PyYAML>=6"]
13+
dependencies = ["PyYAML>=6", "platformdirs>=3", "zstandard>=0.21"]
1414
keywords = ["activitysim", "benchmark", "transportation", "memory", "sharrow"]
1515
classifiers = [
1616
"Development Status :: 3 - Alpha",

‎src/abench/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Reproducible ActivitySim experiments in Linux containers."""
22

3-
__version__ = "0.1.0"
3+
__version__ = "0.1.1"

0 commit comments

Comments
 (0)