Replace logging.warn with warnings.warn
Closed this issue · 2 comments
Is your feature request related to a problem? Please describe.
It would be easier for us to handle warnings if they are issued using the standard library warnings
rather than logging
.
For example, earthkit
warns users that changes to xr.open_dataset
kwargs are not recommended, which produces a lot of warnings for us.
I think the change would be in line with the official logging HOWTO:
warnings.warn() in library code if the issue is avoidable and the client application should be modified to eliminate the warning
A logger’s warning() method if there is nothing the client application can do about the situation, but the event should still be noted
Describe the solution you'd like
No response
Describe alternatives you've considered
No response
Additional context
No response
Organisation
B-Open / CADS-EQC
Please can you post an example warning output you get when "changes to xr.open_dataset kwargs are not recommended"?
Here it is:
import earthkit.data
collection_id = "reanalysis-era5-single-levels"
request = {
"variable": "2t",
"product_type": "reanalysis",
"date": "2012-12-01",
"time": "12:00",
}
ds = earthkit.data.from_source("cds", collection_id, **request)
kwargs = {"chunks": {}, "squeeze": True}
ds.to_xarray(xarray_open_dataset_kwargs=kwargs)
In , overriding the default value (chunks=None) with chunks={} is not recommended.
In , overriding the default value (squeeze=False) with squeeze=True is not recommended.
earthkit-data/src/earthkit/data/utils/kwargs.py
Lines 55 to 61 in e873e96