calliope-project / calliope

A multi-scale energy systems modelling framework
https://www.callio.pe
Apache License 2.0
287 stars 93 forks source link

Add operate mode #539

Closed brynpickering closed 8 months ago

brynpickering commented 8 months ago

Fixes #432

This is mostly to confirm that we're happy with how we approach adding new run modes into the new calliope internals. I would love to have operate mode work with #127 but suspect it needs more planning.

Summary of changes in this pull request:

Reviewer checklist:

brynpickering commented 8 months ago

Worth noting that in 4991efefb5459f61dffa023d8e10ed2a002d68be I implemented it in the backend, then I switched it to being implemented in model.py. I think it works better as a "controller" outside the backend, but maybe not polluting model.py? Imagine adding spores mode to the same class and then you start to see calliope.Model becoming quite large. Maybe that's ok though

brynpickering commented 8 months ago

Options for run modes:

  1. No run modes at all. Then we provide these different modes as external scripts. Those scripts might be a bit messy because we should avoid accessing private attributes / methods of the Model class, but it might make it cleaner to add new modes.
  2. Everything added to the Model class (as is currently the case). Could bloat the Model class.
  3. Everything added to the BackendModel class (as I implemented in https://github.com/calliope-project/calliope/commit/4991efefb5459f61dffa023d8e10ed2a002d68be). Leads to needing to re-initialise "self" which is messy.
  4. Everything added to some intermediate module (stored in backend?) that acts as a controller. This is akin to run.py in the v0.6 implementation.
codecov[bot] commented 8 months ago

Codecov Report

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

Comparison is base (60b0df8) 95.65% compared to head (46678a8) 95.66%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #539 +/- ## ======================================= Coverage 95.65% 95.66% ======================================= Files 25 24 -1 Lines 3450 3526 +76 Branches 747 700 -47 ======================================= + Hits 3300 3373 +73 - Misses 85 87 +2 - Partials 65 66 +1 ``` | [Files](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project) | Coverage Δ | | |---|---|---| | [src/calliope/\_\_init\_\_.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [src/calliope/attrdict.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL2F0dHJkaWN0LnB5) | `96.50% <100.00%> (+0.01%)` | :arrow_up: | | [src/calliope/backend/backend\_model.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL2JhY2tlbmQvYmFja2VuZF9tb2RlbC5weQ==) | `97.73% <100.00%> (+0.06%)` | :arrow_up: | | [src/calliope/backend/pyomo\_backend\_model.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL2JhY2tlbmQvcHlvbW9fYmFja2VuZF9tb2RlbC5weQ==) | `94.58% <100.00%> (+0.06%)` | :arrow_up: | | [src/calliope/examples.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL2V4YW1wbGVzLnB5) | `100.00% <100.00%> (ø)` | | | [src/calliope/io.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL2lvLnB5) | `94.79% <ø> (ø)` | | | [src/calliope/preprocess/data\_sources.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL3ByZXByb2Nlc3MvZGF0YV9zb3VyY2VzLnB5) | `100.00% <100.00%> (ø)` | | | [src/calliope/preprocess/load.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL3ByZXByb2Nlc3MvbG9hZC5weQ==) | `92.20% <ø> (-0.20%)` | :arrow_down: | | [src/calliope/preprocess/model\_data.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL3ByZXByb2Nlc3MvbW9kZWxfZGF0YS5weQ==) | `100.00% <100.00%> (+0.65%)` | :arrow_up: | | [src/calliope/preprocess/time.py](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project#diff-c3JjL2NhbGxpb3BlL3ByZXByb2Nlc3MvdGltZS5weQ==) | `95.74% <ø> (-0.05%)` | :arrow_down: | | ... and [5 more](https://app.codecov.io/gh/calliope-project/calliope/pull/539?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/calliope-project/calliope/pull/539/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=calliope-project)