feat: Add version filtering to metadata endpoints#72
Open
Conversation
Add optional `tax_benefit_model_version_id` filter to /parameters/, /variables/, and /parameter-values/ endpoints. When only model name is provided (without version ID), endpoints now default to returning data from the latest version (by created_at timestamp). Changes: - Add shared tax_benefit_models service with helper functions - Update /parameters/ endpoint with version filtering - Update /variables/ endpoint with version filtering - Update /parameter-values/ endpoint with model name and version filtering - Refactor /analysis/economic-impact to use shared helper - Add comprehensive tests for version filtering behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests for aggregate and change-aggregate endpoints were failing because they passed random UUIDs for simulation IDs, but the endpoints now validate that simulations exist before creating aggregates. Changes: - Add create_dataset and create_simulation factory functions to fixtures - Add simulation_fixture for tests needing a complete simulation setup - Update test_outputs.py to create real simulations and mock Modal calls - Update test_change_aggregates.py similarly with two_simulations fixture - Add tests for 404 cases when simulations don't exist 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <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.
Summary
This PR adds optional
tax_benefit_model_version_idfiltering to the metadata endpoints (/parameters/,/variables/,/parameter-values/). When only a model name is provided (without an explicit version ID), endpoints now default to returning data from the latest version (determined bycreated_attimestamp).Key Changes
New shared service:
src/policyengine_api/services/tax_benefit_models.pywith helper functions:get_latest_model_version()- Get the latest version for a model nameget_model_version_by_id()- Get a specific version by UUIDresolve_model_version_id()- Resolve version ID from either explicit ID or model nameUpdated endpoints:
/parameters/- Addedtax_benefit_model_version_idfilter/variables/- Addedtax_benefit_model_version_idfilter/parameter-values/- Added bothtax_benefit_model_nameandtax_benefit_model_version_idfiltersRefactored:
/analysis/economic-impactnow uses the shared helper instead of its own duplicate functionBehavior
tax_benefit_model_nameprovidedtax_benefit_model_version_idprovidedtax_benefit_model_version_idtakes precedenceTest plan
🤖 Generated with Claude Code