-
Notifications
You must be signed in to change notification settings - Fork 235
idaes v2 migrate
This guide shows how to migrate IDAES client code developed using the IDAES v1 API so that it can be used with the IDAES v2 API.
The internal structure of the top-level idaes
Python package has undergone significant changes in the v1 -> v2 transition, which resulted in changes to the IDAES import paths:
- In most cases, importable objects (subpackages/modules/classes/functions/...) available in v1 can still be imported from a different location (i.e. the import path has been modified)
- In other cases, the importable object does not have a direct equivalent in the v2 API (i.e. the import path has been removed)
For a list of the import path changes, users can refer to the specifications defined here:
In the specifications, the v1 import paths are mapped to the corresponding v2 import path if a direct replacement is available;
otherwise, they are be mapped to None
, or the specification is defined using the without_direct_replacement
method.
If the v1 import path has a direct replacement in v2, it is sufficient to modify the import paths from v1 to v2:
-from idaes.core.util import get_solver
+from idaes.core.solvers import get_solver
If the v1 import path has been removed, a non-direct alternative might still be available. If this is the case and the affected import path is not addressed in this guide, feel free to contact the IDAES team using one of the available support channels.
In IDAES v1, when creating instances of any class inheriting from ProcessBlock
, options had to be supplied as a dictionary object passed to the default
keyword argument (kwarg). In IDAES v2, the same options are are passed directly as keyword arguments.
If the dictionary passed to the default
argument was defined inline as a dict literal (i.e. default={"key1": ..., "key2": ..., ...}
),
then the same key-value pairs should be passed directly as keyword arguments:
-pb = ProcessBlock(default={"dynamic": False})
+pb = ProcessBlock(dynamic=False)
If a pre-defined dictionary was used, the "dict unpacking" operator **
may be used:
my_opts = {"dynamic": False}
-pb = ProcessBlock(default=my_opts)
+pb = ProcessBlock(**my_opts)
TODO
- Set up pre-commit
- Run pytest with coverage report
- Run Pylint locally
- Update the Pyomo version
- Install Pyomo from a local Git clone
- Set up GitHub authentication with GCM
- Handle warnings in pytest