Closed tomvothecoder closed 11 months ago
I don't think this is necessarily an xCDAT issue based on the random occurrence and the related Xarray issues linked in the issue's description.
As Jason mentioned, it might have to do with the I/O on the Climate Program filesystem closing files that are open in Xarray.
Related to:
To summarise in this thread, it looks like a work-around in netcdf4-python to deal with netcdf-c not being thread safe was removed in 1.6.1. The solution (for now) is to [make sure your cluster only uses 1 thread per worker](https://forum.access-hive.org.au/t/netcdf-not-a-valid-id-errors/389/14).
It seems like some filesystems do not like parallel access to files. The workaround seems to be to set parallel=False
(source)
What happened?
For some reason, the
RuntimeError: NetCDF: Not a valid ID
is being thrown at random times when running operations on the same dataset.This has happened when I call the 1) spatial averaging and 2) temporal averaging APIs.
1) Spatial Averaging API
Example:
2) Temporal Averaging API
For this API, the
RuntimeError
stacktrace points to the logic inTemporalAccessor._get_weights()
. Temporal averaging should work fine across multiple copies of the same dataset object.Possible answers:
_get_weights()
, make a copy oftime_lengths
variable and load that into memory instead of the originaltime_lengths
variable (which might be closed after the first API call, resulting in theRuntime: NetCDF
error.There is a line of code that calculates
time_lengths
using time bounds. Thetime_lengths
are then loaded into memory.https://github.com/xCDAT/xcdat/blob/c83f46e2f35095d00ea5e05dde1142b7a318c719/xcdat/temporal.py#L1209-L1216
What did you expect to happen? Are there are possible answers you came
APIs should run work consistently across multiple copies of the same dataset.
@jasonb5 suggests that it could be the LLNL climate filesystem not behaving well with Xarray dataset I/O.
Minimal Complete Verifiable Example (MVCE)
Provided above.
Relevant log output
Provided above.
Anything else we need to know?
Related GitHub issues:
Environment