Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
**/__pycache__
activitysim.log
*.tar.zst
/data_full
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11
3.10
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ description = "User environment for Prototype MTC Model"
readme = "README.md"
requires-python = ">=3.10,<3.12"
dependencies = [
"activitysim==1.4",
"activitysim>=1.5.1",
"multimethod<2.0",
"numba>=0.57",
"numpy>=1.16.1,<1.26",
"numpy>=2,<3",
"openmatrix>=0.3.5.0",
"pandas>=2.1.0,<3",
"pandera>=0.15,<0.18.1",
"pandera>=0.30",
"psutil>=4.1",
"pydantic>=2.6",
"setuptools>=80.9.0,<81",
Expand All @@ -24,3 +24,7 @@ dev = [
"pytest>=8.4.1",
"zstandard>=0.23.0",
]

[tool.uv.sources]
activitysim = { git = "https://github.com/ActivitySim/ActivitySim", branch = "main" }
## TODO: unpin from source once we have a release with the new features we need
91 changes: 91 additions & 0 deletions scripts/run-large-sharrow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env -S uv run --script --locked --no-project
#
# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "activitysim >=1.5,<2.0",
# "sharrow >=2.15",
# ]
# [tool.uv]
# exclude-newer = "2025-11-01T00:00:00Z"
# ///

"""
Run the MTC example model with sharrow enabled, on the small test sample.

The metadata in the header above allows this script to be run with `uv` without
needing to set up a separate virtual environment or install dependencies manually.
"""

from pathlib import Path
import os.path

import platformdirs
import activitysim.abm # register components # noqa: F401
from activitysim.core import workflow
from activitysim.examples.external import download_external_example, download_asset

import pandas as pd

def main():



# in various places, ActivitySim emits this warning:
#
# FutureWarning:
# Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a
# future version. Call result.infer_objects(copy=False) instead. To opt-in to the future behavior,
# set `pd.set_option('future.no_silent_downcasting', True)`


pd.set_option('future.no_silent_downcasting', True)



working_dir = Path(__file__).parents[1]

download_asset(
url="https://github.com/ActivitySim/activitysim-prototype-mtc/releases/download/v1.3.4/data_full.tar.zst",
target_path=os.path.join(working_dir, "data_full.tar.zst"),
sha256 = "b402506a61055e2d38621416dd9a5c7e3cf7517c0a9ae5869f6d760c03284ef3",
link = Path(platformdirs.user_cache_dir(appname="ActivitySim")) / "External-Data",
base_path=str(working_dir),
unpack = "data_full",
)

# do not allow full data to enter Git repo
working_dir.joinpath(".gitignore").write_text("**\n")

out_dir = Path(str(__file__).replace(".py", "-output"))
out_dir.mkdir(exist_ok=True)
out_dir.joinpath(".gitignore").write_text("**\n")

settings = dict(
cleanup_pipeline_after_run=False,
treat_warnings_as_errors=False,
households_sample_size=500_000,
chunk_size=0,
use_shadow_pricing=True,
sharrow="require",
recode_pipeline_columns=True,
)

state = workflow.State.make_default(
working_dir=working_dir,
configs_dir=(
"configs",
),
data_dir="data_full",
output_dir=out_dir,
settings=settings,
)
state.filesystem.persist_sharrow_cache()
state.logging.config_logger()

state.run.all(resume_after=None)



if __name__ == "__main__":
main()
63 changes: 63 additions & 0 deletions scripts/run-small-sharrow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env -S uv run --script --locked --no-project
#
# /// script
# requires-python = ">=3.10,<3.12"
# dependencies = [
# "activitysim >=1.5,<2.0",
# "sharrow >=2.15",
# ]
# [tool.uv]
# exclude-newer = "2025-11-01T00:00:00Z"
# ///

"""
Run the MTC example model with sharrow enabled, on the small test sample.

The metadata in the header above allows this script to be run with `uv` without
needing to set up a separate virtual environment or install dependencies manually.
"""

from pathlib import Path

import activitysim.abm # register components # noqa: F401
from activitysim.core import workflow


def main():
working_dir = Path(__file__).parents[1]
out_dir = Path(str(__file__).replace(".py", "-output"))
out_dir.mkdir(exist_ok=True)
out_dir.joinpath(".gitignore").write_text("**\n")

settings = dict(
cleanup_pipeline_after_run=False,
treat_warnings_as_errors=False,
households_sample_size=100,
chunk_size=0,
use_shadow_pricing=True,
sharrow="require",
recode_pipeline_columns=True,
)

state = workflow.State.make_default(
working_dir=working_dir,
configs_dir=(
"configs",
),
data_dir="data",
output_dir=out_dir,
settings=settings,
)
state.filesystem.persist_sharrow_cache()
state.logging.config_logger()

# TODO: this script should be able to be run end-to-end with the "all" command
# but should be configurable to run by resuming or starting over.
state.run.all(resume_after=None)

# for step_name in state.settings.models:
# state.run.by_name(step_name)


if __name__ == "__main__":
main()
Loading
Loading