Skip to content

Commit

Permalink
Merge pull request #4 from camsys/main
Browse files Browse the repository at this point in the history
Reduce test runtime
  • Loading branch information
jpn-- authored Apr 24, 2024
2 parents ad384fa + 7dca5fb commit 8bac1b6
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 120 deletions.
2 changes: 1 addition & 1 deletion configs/resident/external_workplace_location.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ local_dist,,_DIST@skims['DIST'],1
util_dist,,"@np.minimum(_DIST,10)",coef_dist_capped
util_size_variable,Size variable,@(df['size_term']).apply(np.log1p),coef_size
util_no_attractions,No attractions,@df['size_term']==0,-999
mode_choice_logsum,Mode choice logsum,@df.mode_choice_logsum if 'mode_choice_logsum' in df.columns else 0,coef_mode_logsum
mode_choice_logsum,Mode choice logsum,"@df.get('mode_choice_logsum', 0)",coef_mode_logsum
6 changes: 0 additions & 6 deletions configs/resident/external_workplace_location_archive.csv

This file was deleted.

113 changes: 0 additions & 113 deletions test/test_sandag_abm3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,119 +38,6 @@ def regress(out_dir: Path, regress_dir: Path = None):
pdt.assert_frame_equal(final_trips_df, regress_trips_df)


def run_test_sandag_abm3(multiprocess=False, chunkless=False, sharrow=False):
file_path = os.path.join(os.path.dirname(__file__), "..", "simulation.py")

run_args = []

if multiprocess:
run_args.extend(
[
"-c",
_test_path("configs_mp"),
"-c",
_example_path("configs_mp"),
]
)
elif chunkless:
run_args.extend(
[
"-c",
_test_path("configs_chunkless"),
]
)
elif sharrow:
run_args.extend(
[
"-c",
_test_path("configs_sharrow"),
]
)
if os.environ.get("GITHUB_ACTIONS") != "true":
run_args.append("--persist-sharrow-cache")
else:
run_args.extend(
[
"-c",
_example_path(r"configs/resident"),
]
)

out_dir = _test_path(
f"output-{'mp' if multiprocess else 'single'}"
f"-{'chunkless' if chunkless else 'chunked'}"
f"-{'sharrow' if sharrow else 'no_sharrow'}"
)

# create output directory if it doesn't exist and add .gitignore
Path(out_dir).mkdir(exist_ok=True)
Path(out_dir).joinpath(".gitignore").write_text("**\n")

run_args.extend(
[
"-c",
_example_path("configs"),
"-d",
_example_path("data"),
"-o",
out_dir,
]
)

if os.environ.get("GITHUB_ACTIONS") == "true":
subprocess.run(["coverage", "run", "-a", file_path] + run_args, check=True)
else:
subprocess.run([sys.executable, file_path] + run_args, check=True)

regress(out_dir, _test_path("regress/hh500"))


def test_sandag_abm3_cli():
run_test_sandag_abm3(multiprocess=False)


def test_sandag_abm3():
from activitysim import abm # noqa: F401

# make a temp directory for output that will persist for review
tmp_path = Path(__file__).parent.joinpath("output-test_sandag_abm3")
tmp_path.mkdir(exist_ok=True)

state = workflow.State.make_default(
configs_dir=(
_example_path(r"configs/common"),
_example_path(r"configs/resident"),
),
data_dir=_example_path("data"),
output_dir=tmp_path,
settings=dict(
cleanup_pipeline_after_run=False,
# recode_pipeline_columns=True,
treat_warnings_as_errors=True,
households_sample_size=100,
# households_sample_size=500, == 12min 43 sec
chunk_size=0,
use_shadow_pricing=True,
),
)
state.import_extensions("../extensions")
state.filesystem.persist_sharrow_cache()
state.run.all(resume_after=None)
regress(tmp_path, _test_path("regress/hh500"))


def test_sandag_abm3_chunkless():
run_test_sandag_abm3(multiprocess=False, chunkless=True)


def test_sandag_abm3_mp():
run_test_sandag_abm3(multiprocess=True)


def test_sandag_abm3_sharrow():
run_test_sandag_abm3(sharrow=True)


EXPECTED_MODELS = [
"initialize_proto_population",
"compute_disaggregate_accessibility",
Expand Down

0 comments on commit 8bac1b6

Please sign in to comment.