Accept local dataset paths in managed_microsimulation#416
Draft
MaxGhenis wants to merge 1 commit into
Draft
Conversation
resolve_managed_dataset_reference now treats a local filesystem path as an unmanaged dataset when allow_unmanaged=True -- the same explicit opt-in already required for remote URIs. materialize_dataset_source already passes non-URI paths through unchanged, so the simulation constructs normally and records the provenance bundle (managed_by=policyengine.py). Local build-and-score pipelines can run their own Stage-output H5s through the managed wrapper instead of constructing policyengine_us simulations directly. A local path without allow_unmanaged=True now raises an actionable error rather than the generic "Unknown dataset" message. Fixes #415 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #415
Summary
managed_microsimulationcould not run a local dataset file — only managed dataset names and remote URIs (hf://,gs://). A local build artifact (a downstream pipeline's per-year Stage-output H5 that is not part of any release manifest) raisedUnknown dataset, andallow_unmanaged=Trueonly relaxed URIs, not local paths (file://failed downstream withFileNotFoundError).This makes
resolve_managed_dataset_referenceaccept a local filesystem path whenallow_unmanaged=True— the same explicit opt-in already required for unmanaged URIs.materialize_dataset_sourcealready passes non-URI paths through unchanged, so the simulation constructs normally and records the provenance bundle (managed_by=policyengine.py). A local path withoutallow_unmanaged=Truenow raises an actionable error instead of the generic "Unknown dataset" message.Why
Local build-and-score pipelines — for example projecting the certified base to future years and then scoring reforms on the resulting local H5s — had to construct
policyengine_us.Microsimulationdirectly, bypassing the provenance recording and runtime-model pinning the managed path exists to enforce. They can now stay on the managed wrapper.Tests
test__given_local_path__then_managed_resolution_requires_opt_intest__given_local_path_with_opt_in__then_resolves_to_that_pathtest__given_unknown_dataset_name__then_raises_unknown_datasetVerified end-to-end:
managed_microsimulation(dataset="<local>.h5", allow_unmanaged=True)constructs a working simulation and records the provenance bundle. Fulltest_release_manifests.pypasses (33 tests);make lintclean.🤖 Generated with Claude Code