Skip to content

Conversation

@DTrim99
Copy link

@DTrim99 DTrim99 commented Dec 4, 2025

Summary

  • Update getDatasetForRegion to return HuggingFace URLs for US states (e.g., hf://policyengine/policyengine-us-data/states/CA.h5)
  • Add helper functions for state detection and URL generation
  • Update tests to verify state-specific dataset behavior

Changes

When a US state is selected, the frontend now passes the full HuggingFace URL for the state-specific dataset instead of relying on the API's default pooled CPS dataset.

New Functions

  • getStateDatasetUrl(stateCode) - Generates HF URL for state datasets
  • isUSState(region) - Checks if region is a US state code
  • US_STATE_CODES - Set of all 50+ state/territory codes

Dataset Selection Logic

Region Dataset
US nationwide (us) enhanced_cps
enhanced_us enhanced_cps
US state (e.g., ca) hf://policyengine/policyengine-us-data/states/CA.h5
UK undefined (API default)

Test plan

  • All 22 societyWideCalculation tests pass
  • Tests verify correct URLs for CA, NY, TX, UT states
  • Tests verify enhanced_cps for US nationwide
  • Tests verify undefined for UK

Related PRs

🤖 Generated with Claude Code

- Update getDatasetForRegion to return HuggingFace URLs for US states
  (e.g., hf://policyengine/policyengine-us-data/states/CA.h5)
- Add US_STATE_CODES set with all 50+ state/territory codes
- Add getStateDatasetUrl helper function
- Add isUSState helper function with null safety
- Update tests to verify state-specific dataset behavior
- Add test fixtures for state dataset testing

When a US state is selected, the frontend now passes the full
HuggingFace URL for the state-specific dataset instead of relying
on the API's default pooled CPS dataset.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Dec 4, 2025

@DTrim99 is attempting to deploy a commit to the PolicyEngine Team on Vercel.

A member of the Team first needs to authorize it.

DTrim99 and others added 2 commits December 4, 2025 16:49
Add required curly braces to if statement to satisfy ESLint curly rule.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Dec 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
policyengine-calculator Ready Ready Preview Comment Dec 8, 2025 5:21pm

@anth-volk
Copy link
Collaborator

Closing in favor of the approach highlighted in PolicyEngine/policyengine-api#2953 (comment)

@anth-volk anth-volk closed this Dec 9, 2025
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