Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining the CoreComponents, LayerStructure and ModelTiming classes #374

Merged
merged 40 commits into from
Feb 5, 2024

Conversation

davidorme
Copy link
Collaborator

@davidorme davidorme commented Jan 24, 2024

Description

Following the discussion in #369, we've aligned on a solution that tries to strike a balance between the original completely identical BaseModel subclass signatures and something that retains some of the model to model differences. See
#369 (comment) for a sketch of this solution.

That requires a dataclass of core details that can be created once and then passed to all model initialisations. Models will then share a genuine single copy of those details - not individual identical copies - and model signatures can avoid the more opaque Config objects while still inheriting core components.

This PR implements that by creating CoreComponents which includes nested classes for LayerStructure and ModelTiming. Those borrow heavily from existing code for generating layer_roles and the extract_timing_details function. Once this is accepted, those functions will disappear and an instance of CoreComponents can be used in their place.

Issue #369 is not completed by this PR, but it would be good to agree on this structure and I can then adopt this structure in a second PR onto this, so we can break up the review a little bit!

Edited to add: That second WIP PR (#375) is now in progress - I wanted to see if implementing the changes here threw up anything unexpected. They did not.

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

@davidorme davidorme linked an issue Jan 24, 2024 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (e9365f0) 93.30% compared to head (42bd787) 93.18%.

Files Patch % Lines
virtual_rainforest/core/core_components.py 94.21% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #374      +/-   ##
===========================================
- Coverage    93.30%   93.18%   -0.13%     
===========================================
  Files           59       60       +1     
  Lines         2866     2918      +52     
===========================================
+ Hits          2674     2719      +45     
- Misses         192      199       +7     

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

@davidorme
Copy link
Collaborator Author

Something odd going on with sphinx (what a surprise) that means it can't seem to find references for imported objects like InitVar and np abbreviations.

Copy link
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.

Looks sensible to me, just one small query.

Also I can't work out why codecov is claiming that your changes have 0% test coverage, despite the fact you've written quite a few unit tests?

virtual_rainforest/core/core_components.py Show resolved Hide resolved
@davidorme davidorme requested a review from dalonsoa January 26, 2024 15:21
Copy link
Collaborator

@vgro vgro left a comment

Choose a reason for hiding this comment

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

LGTM. My only concern is that we maybe overdo it with the wrapping and lose transparency.

Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

Looks good!

config: A Config instance.
"""

timing = config["core"]["timing"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

By the time this is called, the config has already validated to ensure there's a core and a timing, right? I think so, but just cross checking.

@vgro vgro mentioned this pull request Feb 1, 2024
7 tasks
Adopting the new BaseModel structure in the model files.
@davidorme davidorme marked this pull request as ready for review February 2, 2024 09:55
@davidorme
Copy link
Collaborator Author

I've merged #375 into this branch, ready to merge the whole thing down into develop.

@davidorme davidorme merged commit 76f1906 into develop Feb 5, 2024
16 checks passed
@davidorme davidorme deleted the 369-simplifying-the-model-creation-setup branch February 5, 2024 16:58
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.

6 participants