ecmwf / eccodes-python

Python interface to the ecCodes GRIB/BUFR decoder/encoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please use the warnings library for selfcheck

dsjstc opened this issue · comments

On Ubuntu 21.04 (a very common docker environment), the easily available version of libeccodes is version 2.20.0. Any pip-installed version of eccodes-python newer than 1.1.0 gives the following warning at import time:

Warning: ecCodes 2.21.0 or higher is recommended. You are running version 2.20.0

It would be really nice if this warning could be emitted by the warnings library, so it would be possible to catch it if desired, with code like this:

import warnings
with warnings.catch_warnings():
    import eccodes

In the meantime, if I don't want this (practically unaddressable) warning emitted by my script, I see no choice but to revert to pip install eccodes==1.1.0.

The ecCodes library is now v2.26.0. Can I ask why your library version is so old?
Version 2.20.0 is from January 2021

See https://confluence.ecmwf.int/display/ECC/History+of+Changes

The ecCodes library is now v2.26.0. Can I ask why your library version is so old? Version 2.20.0 is from January 2021

It is typical to use packaged linux distributions for containerized development. Ubuntu Impish (21.04) is a very common container environment, and is the one that my company's ML deployment platform is based on. EcCodes 2.20 is the package version available in the Ubuntu repositories for Ubuntu Impish.

This situation is very common for people who wish to use packages but not build them.

I have run into the same issue. Writing warnings to stdout via print messes up the output of tools that import eccodes. Writing via the Python standardlib warnings module would make the warnings appear on stderr (by default), which would also allow for shell redirection.

Pointing to newer versions of eccodes does not really address the issue.

I have fixed this (check my develop branch)

Great, thanks a lot! 👍

commented

Cool, thanks!