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

tech/node groups to templates #655

Merged
merged 7 commits into from
Sep 2, 2024
Merged

tech/node groups to templates #655

merged 7 commits into from
Sep 2, 2024

Conversation

brynpickering
Copy link
Member

Fixes #600

I've merged tech_ and node_ into templates as there's no real reason to split them. You can access the same template from techs or nodes but the chance that it causes issues is minimal. The benefit is fewer top-level keys.

I've kept the reference to "inheriting" templates in the docs and the helper function. If there is a perference to purge all concept of inheritance, we could change it, but I don't have a good idea what to replace it with.

Summary of changes in this pull request

  • tech_groups/node_groups -> templates
  • inherit -> template

Reviewer checklist

  • Test(s) added to cover contribution
  • Documentation updated
  • Changelog updated
  • Coverage maintained or improved

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.97%. Comparing base (2099815) to head (b063029).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #655      +/-   ##
==========================================
- Coverage   95.98%   95.97%   -0.01%     
==========================================
  Files          26       26              
  Lines        3981     3980       -1     
  Branches      836      767      -69     
==========================================
- Hits         3821     3820       -1     
  Misses         70       70              
  Partials       90       90              
Files with missing lines Coverage Δ
src/calliope/backend/helper_functions.py 96.84% <ø> (ø)
src/calliope/preprocess/model_data.py 100.00% <100.00%> (ø)

irm-codebase
irm-codebase previously approved these changes Aug 17, 2024
Copy link
Contributor

@irm-codebase irm-codebase left a comment

Choose a reason for hiding this comment

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

I must say: I love this change. Very simple to understand, and will lead to users handling less terminology.

Bryn's idea to just merge everything into templates is excellent.

Copy link
Contributor

Choose a reason for hiding this comment

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

The new name is excellent!
Very easy to follow what's happening now!


Args:
dim_item_dict (AttrDict):
Dictionary (possibly) containing `inherit`. If it doesn't contain `inherit`, the climbing stops here.
Dictionary (possibly) containing `template`. If it doesn't contain `template`, the climbing stops here.
Copy link
Contributor

Choose a reason for hiding this comment

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

Small note: generally I think it's ok to omit long parameter explanations if they are in the docstring body above. Keeps docs lean and leads to less boilerplate fixing over time.

name: Transmission heat tech
carrier_in: heat
carrier_out: heat
base_tech: transmission
flow_cap_max: 5

init_nodes:
techs.test_demand_elec:
Copy link
Contributor

Choose a reason for hiding this comment

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

The red mark above indicates that the document does not end in an empty line. Generally, it's good to do so to aid in machine readability.

I'll fix that in a PR soon through pre-commit CI

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice-to-have: consider adding the small docstring to the modified tests, so that we know what they do in the future.

Feel free to skip.

irm-codebase
irm-codebase previously approved these changes Aug 20, 2024
Copy link
Contributor

@irm-codebase irm-codebase left a comment

Choose a reason for hiding this comment

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

Excellent!

@brynpickering
Copy link
Member Author

@sjpfenninger @irm-codebase one thing I missed is that you still end up with the two input variables in the xarray dataset: techs_inheritance and nodes_inheritance. For techs/nodes, they define the inheritance chain that was used to create that tech/node's definition. They need to be separated as they are indexed only over their respective dimensions. Should these be tech_templates and node_templates, or does inheritance make sense here?

@irm-codebase
Copy link
Contributor

@brynpickering looking at the code, it seems they achieve very similar things, but I do not think they match template's purpose, since template is more of a 'user-side' thing, and this seems more 'internal'...

I think you are right in just going for inheritance.

sjpfenninger
sjpfenninger previously approved these changes Aug 30, 2024
@@ -13,9 +13,10 @@ This establishes the basic characteristics in the optimisation model (decision v
* `conversion`: Converts from one carrier to another.

??? info "Sharing configuration through inheritance"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
??? info "Sharing configuration through inheritance"
??? info "Sharing configuration through inheritance from templates"

@sjpfenninger
Copy link
Member

@sjpfenninger @irm-codebase one thing I missed is that you still end up with the two input variables in the xarray dataset: techs_inheritance and nodes_inheritance. For techs/nodes, they define the inheritance chain that was used to create that tech/node's definition. They need to be separated as they are indexed only over their respective dimensions. Should these be tech_templates and node_templates, or does inheritance make sense here?

I agree with @irm-codebase that we can stick to inheritance here which marks this as a separate (but related) variable.

@brynpickering brynpickering merged commit c3d6c4c into main Sep 2, 2024
13 checks passed
@brynpickering brynpickering deleted the groups-to-templates branch September 2, 2024 09:08
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.

Change the name of 'tech_groups' to 'tech_class'
3 participants