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

Upgrade GridPath to work with Pyomo v5.7 #660

Closed
milindsmart opened this issue Jul 1, 2020 · 6 comments · Fixed by #742
Closed

Upgrade GridPath to work with Pyomo v5.7 #660

milindsmart opened this issue Jul 1, 2020 · 6 comments · Fixed by #742
Assignees
Labels
dependencies Pull requests that update a dependency file priority: high theme: model updates to the model formulation type: chore maintenance, requirements, upgrades, etc.

Comments

@milindsmart
Copy link
Contributor

milindsmart commented Jul 1, 2020

On GridPath v0.2, opening GridPath GUI or running gridpath_run_scenario results in the following ImportError

ImportError: pyomo.environ failed to import pyomo.opt.plugins:
Original ImportError: pyutilib.enum has been removed.

Python 3 now has an enum implementation in the standard library (also
available for older Python versions as the third-party enum34 PyPI
package) that supersedes this library.

@milindsmart
Copy link
Contributor Author

It turns out that Pyomo depends on PyUtilib, but backward compatibility of PyUtilib is assumed : example for Pyomo 5.6.8 the dependency version specification is PyUtilib (>=5.7.3). The most current version of https://github.com/PyUtilib/pyutilib/tree/6.0.0 is 6.0.0 (released on Jun 19).

However, PyUtilib made a big change in v6, PyUtilib/pyutilib#101 removes enum from the package in favour of Python built-in enum. That breaks Pyomo until Pyomo/pyomo#1506 adapts to it, available in version 5.7.0 which (released on Jun 21).

Manually forcing the PyUtilib version to 5.8.0 fixes this.

@milindsmart milindsmart changed the title Pyomo using non-existent pyutilib.enum Pyomo using non-existent pyutilib.enum + Pyomo set implementation changed. Jul 1, 2020
@milindsmart milindsmart changed the title Pyomo using non-existent pyutilib.enum + Pyomo set implementation changed. Pyomo using non-existent pyutilib.enum + Pyomo set implementation changed Jul 1, 2020
@milindsmart
Copy link
Contributor Author

Running a scenario in GridPath either via GUI or gridpath_run fails with the following ValueError


Running optimization for scenario .\2horizons
Building model...
Traceback (most recent call last):
  File "C:\Users\milind\.conda\envs\gp02\Scripts\gridpath_run-script.py", line 11, in <module>
    load_entry_point('GridPath', 'console_scripts', 'gridpath_run')()
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\run_scenario.py", line 779, in main
    scenario_structure, parsed_args)
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\run_scenario.py", line 284, in run_scenario
    structure.main_scenario_directory, "", "", parsed_arguments)
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\run_scenario.py", line 245, in run_optimization
    parsed_arguments)
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\run_scenario.py", line 152, in create_and_solve_problem
    create_abstract_model(model, dynamic_components, loaded_modules)
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\run_scenario.py", line 380, in create_abstract_model
    m.add_model_components(model, dynamic_components)
  File "c:\users\milind\work\projects-external\gridpath\software\repo\gridpath\project\capacity\capacity.py", line 141, in add_model_components
    rule=lambda mod, project:
  File "C:\Users\milind\.conda\envs\gp02\lib\site-packages\pyomo\core\base\set.py", line 1934, in __init__
    IndexedComponent.__init__(self, *args, **kwds)
  File "C:\Users\milind\.conda\envs\gp02\lib\site-packages\pyomo\core\base\indexed_component.py", line 182, in __init__
    Component.__init__(self, **kwds)
  File "C:\Users\milind\.conda\envs\gp02\lib\site-packages\pyomo\core\base\component.py", line 402, in __init__
    % ( type(self).__name__, ','.join(sorted(kwds.keys())) ))
ValueError: Unexpected keyword options found while constructing 'IndexedSet':
        rule

@milindsmart
Copy link
Contributor Author

milindsmart commented Jul 1, 2020

Pyomo/pyomo#1319 completely revamped the implementation of Set in Pyomo, which became available in v5.7.0 (released in June) . The Set element no longer has the rule= argument (https://pyomo.readthedocs.io/en/stable/pyomo_modeling_components/Sets.html), which is currently used in GridPath as in https://github.com/anamileva/gridpath/blob/7b0dd0fba3d0f346351a46f036fca7e8526ad848/gridpath/project/capacity/capacity.py#L139.

See Pyomo/pyomo@c1812ee#diff-7631fbd456728fa7392b5373f35cd27a for details.

Manually forcing Pyomo version to 5.6.9 fixes the issue, until GridPath code can be modified for the changed API across the board.

@anamileva anamileva self-assigned this Jul 1, 2020
@anamileva anamileva added dependencies Pull requests that update a dependency file priority: high type: chore maintenance, requirements, upgrades, etc. theme: model updates to the model formulation labels Jul 1, 2020
@anamileva
Copy link
Member

Leaving myself a note here, so that we fix this in the release that follows v0.3.

Pyomo has introduced breaking changes with v5.7. A simple downgrade of Pyomo to the previous version does not work because of a Pyomo dependency on Pyutilib and breaking changes introduced by the latter. We'll have to update GP to work with Pyomo v5.7 (the Pyutilib issue will be taken care of automatically at that point).

In v0.3, we will simply change the install_requires dependencies in setup.py to

"Pyomo==5.6.9",  # Optimization modeling language
"PyUtilib==5.8.0",  # Temporary while fixing Pyomo 5.7 breaking changes

@anamileva anamileva changed the title Pyomo using non-existent pyutilib.enum + Pyomo set implementation changed Upgrade GridPath to work with Pyomo v5.7 Aug 5, 2020
@anamileva anamileva added this to the Public Release milestone Aug 5, 2020
@anamileva
Copy link
Member

Closed with v0.7.0.

@milindsmart
Copy link
Contributor Author

For completeness : Pyomo/pyomo#1525

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file priority: high theme: model updates to the model formulation type: chore maintenance, requirements, upgrades, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants