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

Feature: public methods to interface with new backend model instance #471

Merged
merged 34 commits into from
Oct 23, 2023

Conversation

brynpickering
Copy link
Member

Fixes issue #429

Summary of changes in this pull request:

General restructuring:

  • Move pyomo backend model class to its own file.
  • Move all backend interface methods to be public on the backend object itself, rather than making them available as methods on the model object (e.g., "model.to_lp" -> "model.backend.to_lp"). This came after I realised just how many methods would need to be passed through to the model object (and each one would need wrapping in functions to check the backend model has been built and to copy across docstrings from the backend) - seemed like too much. We just have to get people used to the "backend" as a thing (or give it a different name).
  • Store a copy of the model data in the backend so it doesn't need to be supplied every time a method is called.

New methods:

  • Update parameter values
  • Update variable bounds
  • Fix/unfix a variable

Reviewer checklist:

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

calliope/backend/backend_model.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #471 (210041e) into main (cbed4c8) will decrease coverage by 2.87%.
Report is 1 commits behind head on main.
The diff coverage is 95.59%.

❗ Current head 210041e differs from pull request most recent head 4069505. Consider uploading reports for the commit 4069505 to get more accurate results

@@            Coverage Diff             @@
##             main     #471      +/-   ##
==========================================
- Coverage   94.98%   92.12%   -2.87%     
==========================================
  Files          31       32       +1     
  Lines        3890     3975      +85     
  Branches        0      946     +946     
==========================================
- Hits         3695     3662      -33     
- Misses        195      196       +1     
- Partials        0      117     +117     
Files Coverage Δ
src/calliope/__init__.py 100.00% <ø> (ø)
src/calliope/_version.py 100.00% <ø> (ø)
src/calliope/backend/helper_functions.py 99.35% <ø> (ø)
src/calliope/backend/where_parser.py 98.43% <ø> (ø)
src/calliope/cli.py 81.67% <100.00%> (ø)
src/calliope/core/__init__.py 100.00% <ø> (ø)
src/calliope/core/attrdict.py 99.50% <ø> (ø)
src/calliope/core/io.py 89.47% <ø> (ø)
src/calliope/core/model.py 93.23% <100.00%> (ø)
src/calliope/core/util/generate_runs.py 87.09% <ø> (ø)
... and 22 more

@brynpickering brynpickering changed the base branch from main to restructure-project October 23, 2023 13:45
Base automatically changed from restructure-project to main October 23, 2023 14:19
Copy link
Member

@sjpfenninger sjpfenninger left a comment

Choose a reason for hiding this comment

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

Good to go - though we should track points to revisit later, e.g. the naming of global_expressions (one alternative suggestion is to call them named_expressions)

@brynpickering brynpickering merged commit 42500c7 into main Oct 23, 2023
9 checks passed
@brynpickering brynpickering deleted the feature-public-backend-api branch October 23, 2023 15:02
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.

2 participants