How to stop grouping FutureWarning
With this code:
expt = "OM4_025.JRA_RYF"
start_time = "1990-01-01"
end_time = "1990-12-31"
psi = cat[expt].search(variable="vmo", frequency="1mon",file_id=".*rho2_l.*")
psi = psi.to_dask(xarray_open_kwargs={"decode_timedelta": True}).sel(time=slice(start_time, end_time))
I am getting this warning:
[/g/data/xp65/public/apps/med_conda/envs/analysis3-25.09/lib/python3.11/site-packages/intake_esm/core.py:301](http://localhost:8888/g/data/xp65/public/apps/med_conda/envs/analysis3-25.09/lib/python3.11/site-packages/intake_esm/core.py#line=300): FutureWarning: When grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass "(name,)" instead of "name" to silence this warning. records = grouped.get_group(internal_key).to_dict(orient='records')
I'm struggling to figure out how to modify the code to stop this warning. Suggestions?
Maybe this is not best practice but I like suppressing warnings:
import warnings
warnings.filterwarnings("ignore", category = FutureWarning)
warnings.filterwarnings("ignore", category = UserWarning)
warnings.filterwarnings("ignore", category = RuntimeWarning)
Yeah, we discussed on our table and people said this is bad practice to suppress all warnings. So ideally I'm looking for a solution to change the code above (i.e. where do I put the suggested ( ,) ?) to stop the warning.
@charles-turner-1 does this need fixing in intake_esm ?
Yup, unfortunately it is. I did put a fix in on a branch somewhere. You can also do what @julia-neme suggests, but scoped to just the call:
with warnings.filterwarnings(
action='ignore',
category=FutureWarning,
):
psi = cat[expt].search(variable="vmo", frequency="1mon",file_id=".*rho2_l.*")
Cool, can we incorporate your fix in the main intake branch?
Yup, unfortunately it is. I did put a fix in on a branch somewhere. You can also do what @julia-neme suggests, but scoped to just the call:
with warnings.filterwarnings( action='ignore', category=FutureWarning, ): psi = cat[expt].search(variable="vmo", frequency="1mon",file_id=".rho2_l.")
Not sure if I misunderstood something here, but we don't wanna be suggesting to all users (via what the recipes are doing) that they need to be doing:
with warnings.filterwarnings(action='ignore', category=FutureWarning):
for every time they wanna load something, right? That makes the code look complicated!
Yeah, I agree it sucks and looks ugly. I'm currently working on a bleeding-edge fork of intake-esm which will go into the analysis3 environment. I'll add the fix in there.
Just pinging @charles-turner-1 because the warning still appears on the latest 25.10 environment. And there is a new one as well:
[/g/data/xp65/public/apps/med_conda/envs/analysis3-25.10/lib/python3.11/site-packages/distributed/diagnostics/nvml.py:14](https://are.nci.org.au/g/data/xp65/public/apps/med_conda/envs/analysis3-25.10/lib/python3.11/site-packages/distributed/diagnostics/nvml.py#line=13): FutureWarning: The pynvml package is deprecated. Please install nvidia-ml-py instead. If you did not install pynvml directly, please report this to the maintainers of the package that installed pynvml for you.
import pynvml
Also, I am getting this warning when opening datasets that shouldn't need concatenation (like this one hu_ds = esm_ds.search(variable='hu', frequency='fx').to_dask()):
[/g/data/xp65/public/apps/med_conda/envs/analysis3-25.10/lib/python3.11/site-packages/intake_esm/source.py:306](https://are.nci.org.au/g/data/xp65/public/apps/med_conda/envs/analysis3-25.10/lib/python3.11/site-packages/intake_esm/source.py#line=305): ConcatenationWarning: Attempting to concatenate datasets without valid dimension coordinates: retaining only first dataset. Request valid dimension coordinate to silence this warning.
warnings.warn(
@julia-neme yeah, I noticed that that warning was still there the other day - bit annoying!
I've just checked and those warnings shouldn't appear from 25.11 onwards - it looks like the wrong version of intake-esm got dragged into the 25.10 for fiddly packaging reasons.
Re. pynvml warnings, I've had a brief look into it but it looks like it's gonna be a 'wait and cross our fingers' type situation - it's being dragged in through dask as a dependency if I remember correctly. pynvml == 'Python utilities for Nvidia Management Library'. It's been deprecated I think.
Re. the static variable's concatenation, I'm pretty confident I know what's causing that, but I don't know if it'll be straightforward to fix. I'll update on that front when I know whether it can be fixed straightforwardly.