Skip to content

Commit ae89183

Browse files
authored
Restore input checker docs (#941)
* restore lost input checker docs * render docs on workflow dispatch
1 parent de6d0ef commit ae89183

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.github/workflows/branch-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
docbuild:
10-
if: "contains(github.event.head_commit.message, '[makedocs]') && (github.repository_owner != 'ActivitySim') && (github.ref_name != 'develop')"
10+
if: "github.event_name == 'workflow_dispatch' || (contains(github.event.head_commit.message, '[makedocs]') && (github.repository_owner != 'ActivitySim') && (github.ref_name != 'develop'))"
1111
# develop branch docs are built at the end of the core test workflow, regardless of repository owner or commit message flags
1212
name: ubuntu-latest py3.10
1313
runs-on: ubuntu-latest

docs/dev-guide/components/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Components
66

77
.. toctree::
88
:maxdepth: 1
9+
input_checker
910
initialize
1011
initialize_los
1112
initialize_tours
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
(input_checker)=
2+
# Input Checker
3+
4+
The input checker is an optional model that will ensure the inputs are as expected according to the
5+
configuration of the user. This model does not have any connection to downstream models and does not
6+
add anything to the ActivitySim pipeline. It is intended to be run at the very start of every ActivitySim
7+
run to quickly examine whether the input data aligns with the user's expectations.
8+
9+
The input checker is built on the Pandera python package. Users are responsible for writing the
10+
Pandera code that will perform the checks they would like to be performed. By allowing the user to
11+
write python code, they are provided with maximum flexiblity to check their input data. (Pydantic
12+
was also explored as a potential technology choice for input checker implementation. Pydantic
13+
development got as far as performing checks and outputting errors, but further development around
14+
reporting warnings and more in-depth testing was dropped in favor of the Pandera approach. The
15+
in-development code has remained as-is in the repository in the event future data model development
16+
favors this approach.)
17+
18+
If any checks fail, ActivitySim will crash and direct you to the output input_checker.log file which
19+
will provide details of the checks that did not pass. The user can also setup checks to output
20+
warnings instead of fatal errors. Warning details will be output to the input_checker.log file for
21+
user review and documentation. Syntax examples for both errors and warnings are demonstrated in the
22+
[`prototype_mtc_extended`] and [`production_semcog`] examples.
23+
24+
Setup steps for new users:
25+
* Copy the data_model directory in the [`prototype_mtc_extended`] or
26+
[`production_semcog`] example folder to your setup space. You will need the enums.py and
27+
input_checks.py scripts. The additional input_checks_pydantic_dev.py script in
28+
[`prototype_mtc_extended`] is there for future development and can be discarded.
29+
* Modify the input_checker.py to be consistent with your input data. This can include changing
30+
variable names and adding or removing checks. The amount and types of checks to perform are
31+
completely up to you! Syntax is shown for many different checks in the example.
32+
* Modify enums.py to be consistent with your implesmentation by changing / adding / removing variable
33+
definitions.
34+
* Copy the input_checker.yaml script from [`prototype_mtc_extended`] or
35+
[`production_semcog`] configs into your configs
36+
directory. Update the list of data tables you would like to check in the input_checker.yaml
37+
file. The "validator_class" option should correspond to the name of the corresponding class in
38+
the input_checker.py file you modified in the above step.
39+
* Add the input_checker model to the models option in your settings.yaml file to include it in the
40+
model run. When running activitysim, you will also need to include the name of the data_model
41+
directory from the first step, e.g. activitysim run -c configs -d data -o outout --data_model
42+
data_model.
43+
44+
```{note}
45+
If you are running ActivitySim with the input checker module active, you must supply
46+
a --data_model argument that points to where the input_checks.py file exists!
47+
```
48+
49+
## Implementation
50+
51+
```{eval-rst}
52+
.. automodule:: activitysim.abm.models.input_checker
53+
:members:
54+
```

0 commit comments

Comments
 (0)