Skip to content

Adding model variable attribute validation#1338

Merged
davidorme merged 6 commits intodevelopfrom
1337-validate-claimed-model-variable-initialisation-at-run-time
Feb 23, 2026
Merged

Adding model variable attribute validation#1338
davidorme merged 6 commits intodevelopfrom
1337-validate-claimed-model-variable-initialisation-at-run-time

Conversation

@davidorme
Copy link
Copy Markdown
Collaborator

Description

This PR adds a function in main.py that checks that the variables added to data during a model __init__ or first _update actually match the vars_populated_at_init and vars_populated_at_first_update attributes of the model. These currently aren't validated and this seems like the simplest way to try and keep these attributes up to date.

I think this could be extended to verify the other var_ attributes too, but keeping the variable population correct matters to resolving the model running order.

Fixes #1337

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works
  • Relevant documentation reviewed and updated

@davidorme davidorme linked an issue Feb 13, 2026 that may be closed by this pull request
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 59.25926% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.85%. Comparing base (177aaaf) to head (ab232fb).

Files with missing lines Patch % Lines
virtual_ecosystem/main.py 59.25% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1338      +/-   ##
===========================================
- Coverage    94.99%   94.85%   -0.14%     
===========================================
  Files           71       71              
  Lines         7366     7392      +26     
===========================================
+ Hits          6997     7012      +15     
- Misses         369      380      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@jacobcook1995 jacobcook1995 left a comment

Choose a reason for hiding this comment

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

This seems like a sensible change to me!

@davidorme davidorme merged commit 70504e7 into develop Feb 23, 2026
13 checks passed
@davidorme davidorme deleted the 1337-validate-claimed-model-variable-initialisation-at-run-time branch February 23, 2026 12:47
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.

Validate claimed model variable initialisation at run time

3 participants