Skip to content

Conversation

@andkay
Copy link

@andkay andkay commented Aug 1, 2025

As a follow on from ActivitySim PR 950, this pull request demonstrates a pattern for building a settings checker for extensions.

The key requirements are that users create a checker module in their extensions directory. This must be called settings_checker.py and contain a (dict) registry of settings called EXTENSION_SETTER_CHECKINGS. The general pattern established in core repository should be followed.

@jpn--
Copy link
Member

jpn-- commented Aug 20, 2025

@andkay please merge in latest changes from main to use uv for tests. I don't seem to have write access to your fork so I can't do it for you.

@andkay
Copy link
Author

andkay commented Aug 21, 2025

@jpn-- I've forked and rebased this branch to main.

Copy link
Member

@jpn-- jpn-- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked over the code changes here. Conceptually, it looks good. It passes the tests now, which is good. But to really test it I tried writing another test that would intentionally break an extension settings file:

https://github.com/driftlesslabs/sandag-abm3-example/blob/37804001bc12096a0e75278829a7438a6eeaeaff/test/test_sandag_abm3.py#L181-L246

In short, we make a copy of the settings, break the av_ownership.yaml file, and run with the broken settings. It should raise a validation error before it gets to the av_ownership model. But it doesn't: https://github.com/driftlesslabs/sandag-abm3-example/actions/runs/17132819984/job/48601266109

Can we figure out why, and fix it?

@andkay
Copy link
Author

andkay commented Aug 22, 2025

@jpn-- that is odd.

AvOwnershipSettings inherits from LogitComponentSettings, which is explicit about the allowable values for LOGIT_TYPE. So this should be caught upon loading the model. I'll have a look.

@andkay
Copy link
Author

andkay commented Sep 2, 2025

@jpn-- Smoke testing the settings checker with a bad value against the LOGIT_TYPE key in the av_ownership.yaml yielded the expected error:

[00:26.24] ERROR:       Error checking settings for av_ownership using files av_ownership.yaml: 1 validation error for AVOwnershipSettings
LOGIT_TYPE
  Input should be 'MNL' or 'NL' [type=literal_error, input_value='NOT_A_LOGIT', input_type=str]

Reading through your test in more detail, I don' think the settings checker is invoked at all. It's not called on a per-step basis. Its done once for all models before an ActivitySim run. https://github.com/ActivitySim/activitysim/blob/e345f9774e14d0eac7fe01b2e22aeca28c2b821f/activitysim/cli/run.py#L388

This does make it hard to test - and there may well be better way to code it in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants