equinor / ert

ERT - Ensemble based Reservoir Tool - is designed for running ensembles of dynamical models such as reservoir models, in order to do sensitivity analysis and data assimilation. ERT supports data assimilation using the Ensemble Smoother (ES), Ensemble Smoother with Multiple Data Assimilation (ES-MDA) and Iterative Ensemble Smoother (IES).
https://ert.readthedocs.io/en/latest/
GNU General Public License v3.0
103 stars 107 forks source link

ValueError: unable to infer dtype on variable 'time'; xarray cannot serialize arbitrary Python objects #9194

Open berland opened 1 day ago

berland commented 1 day ago

What happened? (You can include a screenshot if it helps explain)

This error is observed in the logs:

...
File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 309, in encode_cf_variable
    var = ensure_dtype_not_object(var, name=name)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 265, in ensure_dtype_not_object
    data = _copy_with_dtype(data, dtype=_infer_dtype(data, name))
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 198, in _infer_dtype
    raise ValueError(
ValueError: unable to infer dtype on variable 'time'; xarray cannot serialize arbitrary Python objects

6525 has probably reoccured.

What did you expect to happen?

No crash. We should support dates beyond 2262 if that is the problem, and assert it in tests.

steps to reproduce

Not known.

Environment where bug has been observed

berland commented 1 day ago

Full traceback:

Traceback (most recent call last):
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/ert/callbacks.py", line 69, in _write_responses_to_storage
    run_arg.ensemble_storage.save_response(
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/ert/storage/mode.py", line 105, in inner
    return func(self_, *args, **kwargs)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/ert/storage/local_ensemble.py", line 847, in save_response
    data.to_netcdf(output_path / f"{response_type}.nc", engine="scipy")
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/core/dataset.py", line 1912, in to_netcdf
    return to_netcdf(  # type: ignore  # mypy cannot resolve the overloads:(
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/backends/api.py", line 1232, in to_netcdf
    dump_to_store(
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/backends/api.py", line 1279, in dump_to_store
    store.store(variables, attrs, check_encoding, writer, unlimited_dims=unlimited_dims)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/backends/common.py", line 266, in store
    variables, attributes = self.encode(variables, attributes)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/backends/common.py", line 355, in encode
    variables, attributes = cf_encoder(variables, attributes)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 899, in cf_encoder
    new_vars = {k: encode_cf_variable(v, name=k) for k, v in variables.items()}
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 899, in <dictcomp>
    new_vars = {k: encode_cf_variable(v, name=k) for k, v in variables.items()}
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 309, in encode_cf_variable
    var = ensure_dtype_not_object(var, name=name)
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 265, in ensure_dtype_not_object
    data = _copy_with_dtype(data, dtype=_infer_dtype(data, name))
  File "/prog/res/komodo/2024.10.07-py38-rhel8/root/lib64/python3.8/site-packages/xarray/conventions.py", line 198, in _infer_dtype
    raise ValueError(
ValueError: unable to infer dtype on variable 'time'; xarray cannot serialize arbitrary Python objects