Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,12 @@ jobs:
region:
- prototype_mtc
- prototype_psrc_in_development
- prototype_mtc_extended
fail-fast: false
defaults:
run:
shell: bash -l {0}
name: ${{ matrix.region }}
name: ${{ matrix.region }} (external)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
9 changes: 0 additions & 9 deletions activitysim/core/configuration/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ def data_dirs_must_exist(cls, data_dir, values):
Name of the data model directory.
"""

@validator("data_model_dir")
def data_model_dirs_must_exist(cls, data_model_dir, values):
working_dir = values.get("working_dir", None) or Path.cwd()
for d in data_model_dir:
d_full = working_dir.joinpath(d)
if not d_full.exists():
raise ValueError(f"data model directory {d_full} does not exist")
return data_model_dir

output_dir: Path = "output"
"""
Name of the output directory.
Expand Down
9 changes: 6 additions & 3 deletions activitysim/core/logit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
import warnings
from typing import Iterator

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -548,7 +549,9 @@ def _each_nest(spec: LogitNestSpec, parent_nest, post_order):
yield spec, nest


def each_nest(nest_spec: dict | LogitNestSpec, type=None, post_order=False):
def each_nest(
nest_spec: dict | LogitNestSpec, type=None, post_order=False
) -> Iterator[Nest]:
"""
Iterate over each nest or leaf node in the tree (of subtree)

Expand All @@ -567,8 +570,8 @@ def each_nest(nest_spec: dict | LogitNestSpec, type=None, post_order=False):

Yields
------
nest : Nest
Nest object with info about the current node (nest or leaf)
nest : Nest
Nest object with info about the current node (nest or leaf)
"""
if type is not None and type not in Nest.nest_types():
raise RuntimeError("Unknown nest type '%s' in call to each_nest" % type)
Expand Down
14 changes: 9 additions & 5 deletions activitysim/core/test/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,30 @@ def assert_frame_substantively_equal(
raise


def assert_equal(x, y):
def assert_equal(x, y, message=None):
__tracebackhide__ = True # don't show this code in pytest outputs
if message is None:
message = ""
elif isinstance(message, str) and len(message) > 0 and message[0] != "\n":
message = "\n" + message
try:
import pytest
except ImportError:
assert x == y
else:
if isinstance(x, list) and isinstance(y, list) and len(x) == len(y):
for n_, (x_, y_) in enumerate(zip(x, y)):
assert x_ == pytest.approx(y_), f"error at index {n_}"
assert y_ == pytest.approx(x_), f"error at index {n_}{message}"
elif isinstance(x, dict) and isinstance(y, dict) and x.keys() == y.keys():
for n_ in x.keys():
assert x[n_] == pytest.approx(y[n_]), f"error at key {n_}"
assert y[n_] == pytest.approx(x[n_]), f"error at key {n_}{message}"
else:
try:
assert x == pytest.approx(y)
assert y == pytest.approx(x)
except (TypeError, AssertionError):
# pytest.approx() does not support nested data structures
for x_, y_ in zip(x, y):
assert x_ == pytest.approx(y_)
assert y_ == pytest.approx(x_), f"error in an item{message}"


def progressive_checkpoint_test(
Expand Down
6 changes: 6 additions & 0 deletions activitysim/core/workflow/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def initialize_filesystem(
*,
configs_dir: Path | tuple[Path, ...] = ("configs",),
data_dir: Path | tuple[Path, ...] = ("data",),
data_model_dir: Path | tuple[Path, ...] = ("data_model",),
output_dir: str | Path = "output",
profile_dir: Path | None = None,
cache_dir: Path | None = None,
Expand Down Expand Up @@ -394,6 +395,8 @@ def initialize_filesystem(
their inputs and settings.
data_dir : path-like or tuple of path-like, default "data"
The directories where input data files can be found.
data_model_dir : path-like or tuple of path-like, default "data_model"
The directories where data model files can be found.
output_dir : path-like, default "output"
Most ActivitySim output will be written to this directory (or
subdirectories within it).
Expand Down Expand Up @@ -422,10 +425,13 @@ def initialize_filesystem(
configs_dir = (configs_dir,)
if isinstance(data_dir, str | Path):
data_dir = (data_dir,)
if isinstance(data_model_dir, str | Path):
data_model_dir = (data_model_dir,)

fs = dict(
configs_dir=configs_dir,
data_dir=data_dir,
data_model_dir=data_model_dir,
output_dir=output_dir,
settings_file_name=settings_file_name,
pipeline_file_name=pipeline_file_name,
Expand Down
4 changes: 2 additions & 2 deletions activitysim/core/workflow/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ def read_csv_as_list_of_lists(finame):
[i[1:] for i in that_blob],
)
)
assert_equal(this_dict, that_dict)
assert_equal(this_dict, that_dict, message=that_path)
else:
try:
assert_equal(this_blob, that_blob)
assert_equal(this_blob, that_blob, message=that_path)
except:
logger.error(f"trace validation BAD: {label}")
raise
Expand Down
8 changes: 4 additions & 4 deletions activitysim/examples/external_example_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ prototype_mtc:
sha256: 394e5b403d4c61d5214493cefe161432db840ba4967c23c999d914178d43a1f0

prototype_mtc_extended:
url: https://github.com/ActivitySim/activitysim-prototype-mtc/archive/refs/tags/v1.3.2.tar.gz
sha256: b3f8f60f6354a0ffce80dd67f058c2ef81645d2c8bedddfcb989d3878651f045
url: https://github.com/ActivitySim/activitysim-prototype-mtc/archive/refs/tags/v1.3.6.tar.gz
sha256: bb2eb1a6197115e3c34450b41fc32203c21de9b99649989fb569d15de67b1b0a
assets:
mtc_data_full.tar.zst:
url: https://github.com/ActivitySim/activitysim-prototype-mtc/releases/download/v1.3.2/mtc_data_full.tar.zst
sha256: ffc22b34b4990a1459829b101b43180d0f5d41da0d4535d58588f232c98bd44e
url: https://github.com/ActivitySim/activitysim-prototype-mtc/releases/download/v1.3.4/data_full.tar.zst
sha256: b402506a61055e2d38621416dd9a5c7e3cf7517c0a9ae5869f6d760c03284ef3
unpack: data_full
test/prototype_mtc_reference_pipeline.zip:
url: https://github.com/ActivitySim/activitysim-prototype-mtc/releases/download/v1.3.2/prototype_mtc_extended_reference_pipeline.zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def regress():
[sys.executable, "-m", "activitysim", "run"] + run_args, check=True
)
else:
import activitysim.abm
import activitysim.abm # noqa: F401

state = workflow.State.make_default(**kwargs)
state.run.all()
Expand Down