examples icon indicating copy to clipboard operation
examples copied to clipboard

Update Examples to track IDAES deprecation warnings

Open jsiirola opened this issue 3 years ago • 13 comments

While putting together IDAES/examples-pse#102, I ran across a ton of deprecation warnings in the example, e.g.:

2022-02-24 12:30:05 [WARNING] idaes.power_generation.unit_models.boiler_heat_exchanger: 'DeltaTMethod' is deprecated use 'HeatExchangerFlowPattern' This will be removed in IDAES 3.0
2022-02-24 12:30:05 [WARNING] idaes.power_generation.unit_models.boiler_heat_exchanger: Config item delta_T_method is deprecated use flow_pattern. Will be removed in IDAES 3.0.
2022-02-24 12:30:05 [WARNING] idaes.power_generation.unit_models.boiler_heat_exchanger: 'DeltaTMethod' is deprecated use 'HeatExchangerFlowPattern' This will be removed in IDAES 3.0
2022-02-24 12:30:05 [WARNING] idaes.power_generation.unit_models.boiler_heat_exchanger: Config item side_1_property_package is deprecated. Will be removed in IDAES 3.0.
2022-02-24 12:30:05 [WARNING] idaes.power_generation.unit_models.boiler_heat_exchanger: Config item side_2_property_package is deprecated. Will be removed in IDAES 3.0.

and

WARNING: DEPRECATED: DEPRECATED: svg_tag, the tags, tag_format and
    tag_format_default arguments are deprecated use tag_group instead.
    (deprecated in 1.12) (called from <ipython-input-8-b95b72557475>:6)
WARNING: DEPRECATED: DEPRECATED: svg_tag, the tags, tag_format and
    tag_format_default arguments are deprecated use tag_group instead.
    (deprecated in 1.12) (called from <ipython-input-8-b95b72557475>:7)

We should revisit the examples and update them to track the current recommended API.

We should also consider updating the examples tests to fail on (unexpected) warnings.

jsiirola avatar Feb 24 '22 19:02 jsiirola

Which model is this? Is it imported from idaes-pse or all in the example?

eslickj avatar Feb 24 '22 20:02 eslickj

The example is src/Examples/Advanced/DataRecon/econ_parmest_testing.ipynb, importing

from idaes.power_generation.unit_models.boiler_heat_exchanger import (
    BoilerHeatExchanger, 
    TubeArrangement, 
    DeltaTMethod
)

jsiirola avatar Feb 24 '22 20:02 jsiirola

Ok, so it's the notebook that needs to be updated. I assume you are working on this now, so I need to wait to update it.

eslickj avatar Feb 24 '22 20:02 eslickj

When debugging notebooks and writing new examples, I encounter many deprecation warnings concerning missing scaling factors or not specifying an equation form for Perry's liquid density methods. The second one is from one of my PR's to add a second equation form and default to the first/original equation form is no flag is provided. @andrewlee94 would it be best to update our examples so these warnings do not appear, and if so would you support catching these warnings via tests as @jsiirola suggests above?

bpaul4 avatar Feb 28 '22 21:02 bpaul4

@bpaul4 Yes, we should be fixing these deprecation warnings and it would be good to have a check for them. This will be especially important over the next few months as we begin the transition to IDAES v2.0.

andrewlee94 avatar Feb 28 '22 22:02 andrewlee94

The scaling factors aren't deprecation warnings. Just warnings. By popular request, I'm planning to add an option to silence the scaling warnings.

eslickj avatar Mar 01 '22 01:03 eslickj

As John noted those the scaling factor messages are warning, but the correct path here is to fix these rather than silence them - we need to show users how to use the scaling tools and this is the prefect opportunity.

andrewlee94 avatar Mar 01 '22 14:03 andrewlee94

PR https://github.com/IDAES/idaes-pse/pull/822 can turn deprecation warnings into exceptions, which can help track down the exact location of deprecation warnings being generated, and help us make sure we get them all.

eslickj avatar Aug 06 '22 02:08 eslickj

I think we should have fixed all the deprecations that were being raised, so now it should just be a matter of adding a test to warn us when new deprecations appear.

andrewlee94 avatar Oct 13 '22 18:10 andrewlee94

  • Implementing the check at runtime (e.g. the way that deprector does it) is trickier for Jupyter notebooks, since they run in their own isolated process and the runtime is not accessible for patching
  • One alternative would be to execute the notebooks and parse the output cells of the notebook post-execution to verify that it does not contain deprecation messages
  • Either way, it's not clear if it makes sense to try to implement the check in this repository since we're about to migrate to the new IDAES/examples repo

lbianchi-lbl avatar Dec 08 '22 19:12 lbianchi-lbl

fwiw, in this (examples) repository, we could implement this check by using the same function used in the pre-processing step to find all notebooks (ie idaes_examples.util.find_notebooks()) and parse them. We would just need to make sure it ran after all the other tests -- there is a plugin called pytest-order we can use.

dangunter avatar Mar 02 '23 07:03 dangunter

Summarizing the discussion from the dev call:

  • [ ] @lbianchi-lbl will take a stab at creating a pytest plugin that looks at the .ipynb post-execution output cells and does a text search for DEPRECATED (must ensure that this check is run after the notebooks are run).

lbianchi-lbl avatar Mar 02 '23 20:03 lbianchi-lbl

This is still relevant. I might be able to make some progress on this before the Feb release.

lbianchi-lbl avatar Jan 18 '24 19:01 lbianchi-lbl