Skip to content

idaes v2 migrate

Ludovico Bianchi edited this page Nov 30, 2022 · 12 revisions

How to migrate code to IDAES v2 API

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.

List of v1 -> v2 API changes

Import paths within the idaes package

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:

  • Packages and modules (link)
  • Classes and functions (link)

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.

How to migrate

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.

ProcessBlock init arguments

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.

How to migrate

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)

HeatExchanger API

How to migrate

TODO

Clone this wiki locally