opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
467 stars 218 forks source link

DeprecationWarnings #1310

Closed freiburgermsu closed 1 year ago

freiburgermsu commented 1 year ago

Checklist

Is your feature related to a problem? Please describe it.

My workflows are flooded with warnings like those in the attached. Will these be resolved in a near-term update, or how can these be suppressed until that time?

SMETANA cobrapy warnings

Describe the solution you would like.

Describe alternatives you considered

Additional context

cdiener commented 1 year ago

I think the workflows or a package you are using is still using the old rxn.x and rxn.y to access the solution. Replacing those should fix those. Or do you get those when calling other cobrapy functions?

The warning with the formula wouldn't be fixed by this. This just tells you you have a chemical formula with invalid symbols (not an element).

freiburgermsu commented 1 year ago

I have never used x or y reaction attributes. Are these actual attributes for reactions, or are they arbitrary placeholders to represent the possible attributes of a Reaction object? Our code always accesses a solution through the returned output of .optimize() or slim_optimize(). I frankly do not know how "reduced_cost" or "shadow_price" would relate to our work.

Midnighter commented 1 year ago

Can you show which code you are running that causes these warnings? And what version of cobrapy are you using?

cdiener commented 1 year ago

Those are the actual names of the attributes and were the old accessors for the primal and dial solution values. There is some code in your codebase that calls Reaction.x and Reaction.y though this could also be hidden in another package you are using. Like @Midnighter said, hard to say where those come from without seeing the code.

freiburgermsu commented 1 year ago

@Midnighter I am running this package in this Notebook. I am running version 0.26.2 of COBRApy.

Let me know if I can assist in any other way :)

cdiener commented 1 year ago

Not @Midnighter but thanks for providing the code! It's caused by the use of DeepDiff in ModelSEEDpy. It goes through all attributes of the Reaction (including the deprecated ones) and diffs them. Should be an easy fix in the modelseedpy code, depending how often it is used. For now you could also just disable DeprecationWarnings for the code fragments that trigger them.

freiburgermsu commented 1 year ago

Thank you for rooting the cause! ModelSEEDpy is used very often, so a permanent workaround is desirable. How can I disable DeprecationWarnings?

cdiener commented 1 year ago

You can do

import warnings

warnings.simplefilter("ignore", category=DeprecationWarning)

If you run that at the top of your notebook it will suppress them for the entire notebook.

freiburgermsu commented 1 year ago

@cdiener Placing your two lines at the top of the ModelSEEDpy package file concisely eliminated the warnings. Thank you! :pray: