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

Add operate mode #539

Merged
merged 41 commits into from
Jan 23, 2024
Merged

Add operate mode #539

merged 41 commits into from
Jan 23, 2024

Conversation

brynpickering
Copy link
Member

@brynpickering brynpickering commented Jan 18, 2024

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:

  • Add a slim-line operate mode back into the model
  • Switch from defining operate window/horizon as timesteps to being pandas time frequencies

Reviewer checklist:

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

The method for loading them in isn't dirty,
but aligning YAML definitions with those from file is.
Dummy test model isn't well-formatted to pass the carrier in/out checks.
We _do_ check these in the YAML schema so that should be sufficient.
Not failing locally...
@brynpickering brynpickering changed the base branch from main to feature-load-from-data-sources January 18, 2024 10:37
@brynpickering
Copy link
Member Author

Worth noting that in 4991efe 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
Copy link
Member Author

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 4991efe). 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.

model.build()
model.solve()

# TODO: introduce some of these warnings ?
Copy link
Member

Choose a reason for hiding this comment

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

Or introduce these operate mode quirks in the docs

Co-authored-by: Stefan Pfenninger <[email protected]>
Base automatically changed from feature-load-from-data-sources to main January 22, 2024 19:06
brynpickering and others added 2 commits January 22, 2024 20:18
* Add `data-sources` top-level key to load tabular data into the model from file or pandas.DataFrame.
* Remove `file/df=` functionality.
* Fix resampler; add parameter dtype casting.
* parent -> base_tech.
* Add data source schema validation.
* Add tutorial to docs.

---------

Co-authored-by: Stefan Pfenninger <[email protected]>
Copy link

codecov bot commented Jan 22, 2024

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
@@           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 Coverage Δ
src/calliope/__init__.py 100.00% <100.00%> (ø)
src/calliope/attrdict.py 96.50% <100.00%> (+0.01%) ⬆️
src/calliope/backend/backend_model.py 97.73% <100.00%> (+0.06%) ⬆️
src/calliope/backend/pyomo_backend_model.py 94.58% <100.00%> (+0.06%) ⬆️
src/calliope/examples.py 100.00% <100.00%> (ø)
src/calliope/io.py 94.79% <ø> (ø)
src/calliope/preprocess/data_sources.py 100.00% <100.00%> (ø)
src/calliope/preprocess/load.py 92.20% <ø> (-0.20%) ⬇️
src/calliope/preprocess/model_data.py 100.00% <100.00%> (+0.65%) ⬆️
src/calliope/preprocess/time.py 95.74% <ø> (-0.05%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

@brynpickering brynpickering merged commit e2bfb1a into main Jan 23, 2024
10 checks passed
@brynpickering brynpickering deleted the add-operate-mode branch January 23, 2024 09:30
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.

Reincorporate operate mode in v0.7.0
2 participants