Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Failed to decode variable 'end_time' with GSLA files when appending to Zarr #97

Open
craigrose opened this issue Nov 13, 2024 · 0 comments

Comments

@craigrose
Copy link
Contributor

Create a new zarr with the first file: s3://imos-data-nonproduction/IMOS/OceanCurrent/GSLA/NRT/2024/IMOS_OceanCurrent_HV_20240101T000000Z_GSLA_FV02_NRT.nc

Then try to appeand the second file: s3://imos-data-nonproduction/IMOS/OceanCurrent/GSLA/NRT/2024/IMOS_OceanCurrent_HV_20240102T000000Z_GSLA_FV02_NRT.nc

16:16:45.392 | INFO    | model_sea_level_anomaly_gridded_realtime - b88daeef-d00f-4387-9b57-899729ecd2a7: Appending data to existing Zarr
2024-11-13 16:16:45,595 - ERROR - GenericZarrHandler.py:408 - publish_cloud_optimised_fileset_batch - b88daeef-d00f-4387-9b57-899729ecd2a7: An unexpected error occurred: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed..
 Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 218, in _decode_cf_datetime_dtype
    result = decode_cf_datetime(example_value, units, calendar, use_cftime)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 349, in decode_cf_datetime
    dates = _decode_datetime_with_cftime(flat_num_dates, units, calendar)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 242, in _decode_datetime_with_cftime
    cftime.num2date(num_dates, units, calendar, only_use_cftime_datetimes=True)
  File "src/cftime/_cftime.pyx", line 587, in cftime._cftime.num2date
  File "src/cftime/_cftime.pyx", line 105, in cftime._cftime._dateparse
ValueError: In general, units must be one of 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', or 'days' (or select abbreviated versions of these).  For the '360_day' calendar, 'months' can also be used, or for the 'noleap' calendar 'common_years' can also be used. Got 'nanoseconds' instead, which are not recognized.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 448, in decode_cf_variables
    new_vars[k] = decode_cf_variable(
                  ^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 289, in decode_cf_variable
    var = times.CFDatetimeCoder(use_cftime=use_cftime).decode(var, name=name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 992, in decode
    dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 228, in _decode_cf_datetime_dtype
    raise ValueError(msg)
ValueError: unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 380, in publish_cloud_optimised_fileset_batch
    self._write_ds(ds, idx)
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 771, in _write_ds
    with xr.open_zarr(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1103, in open_zarr
    ds = open_dataset(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/api.py", line 611, in open_dataset
    backend_ds = backend.open_dataset(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1188, in open_dataset
    ds = store_entrypoint.open_dataset(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/store.py", line 46, in open_dataset
    vars, attrs, coord_names = conventions.decode_cf_variables(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 459, in decode_cf_variables
    raise type(e)(f"Failed to decode variable {k!r}: {e}") from e
ValueError: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 218, in _decode_cf_datetime_dtype
    result = decode_cf_datetime(example_value, units, calendar, use_cftime)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 349, in decode_cf_datetime
    dates = _decode_datetime_with_cftime(flat_num_dates, units, calendar)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 242, in _decode_datetime_with_cftime
    cftime.num2date(num_dates, units, calendar, only_use_cftime_datetimes=True)
  File "src/cftime/_cftime.pyx", line 587, in cftime._cftime.num2date
  File "src/cftime/_cftime.pyx", line 105, in cftime._cftime._dateparse
ValueError: In general, units must be one of 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', or 'days' (or select abbreviated versions of these).  For the '360_day' calendar, 'months' can also be used, or for the 'noleap' calendar 'common_years' can also be used. Got 'nanoseconds' instead, which are not recognized.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 448, in decode_cf_variables
    new_vars[k] = decode_cf_variable(
                  ^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 289, in decode_cf_variable
    var = times.CFDatetimeCoder(use_cftime=use_cftime).decode(var, name=name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 992, in decode
    dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 228, in _decode_cf_datetime_dtype
    raise ValueError(msg)
ValueError: unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 402, in publish_cloud_optimised_fileset_batch
    self._process_individual_file_fallback(
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 574, in _process_individual_file_fallback
    self._write_ds(ds, idx)
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 771, in _write_ds
    with xr.open_zarr(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1103, in open_zarr
    ds = open_dataset(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/api.py", line 611, in open_dataset
    backend_ds = backend.open_dataset(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1188, in open_dataset
    ds = store_entrypoint.open_dataset(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/store.py", line 46, in open_dataset
    vars, attrs, coord_names = conventions.decode_cf_variables(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 459, in decode_cf_variables
    raise type(e)(f"Failed to decode variable {k!r}: {e}") from e
ValueError: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

16:16:45.595 | ERROR   | model_sea_level_anomaly_gridded_realtime - b88daeef-d00f-4387-9b57-899729ecd2a7: An unexpected error occurred: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed..
 Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 218, in _decode_cf_datetime_dtype
    result = decode_cf_datetime(example_value, units, calendar, use_cftime)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 349, in decode_cf_datetime
    dates = _decode_datetime_with_cftime(flat_num_dates, units, calendar)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 242, in _decode_datetime_with_cftime
    cftime.num2date(num_dates, units, calendar, only_use_cftime_datetimes=True)
  File "src/cftime/_cftime.pyx", line 587, in cftime._cftime.num2date
  File "src/cftime/_cftime.pyx", line 105, in cftime._cftime._dateparse
ValueError: In general, units must be one of 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', or 'days' (or select abbreviated versions of these).  For the '360_day' calendar, 'months' can also be used, or for the 'noleap' calendar 'common_years' can also be used. Got 'nanoseconds' instead, which are not recognized.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 448, in decode_cf_variables
    new_vars[k] = decode_cf_variable(
                  ^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 289, in decode_cf_variable
    var = times.CFDatetimeCoder(use_cftime=use_cftime).decode(var, name=name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 992, in decode
    dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 228, in _decode_cf_datetime_dtype
    raise ValueError(msg)
ValueError: unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 380, in publish_cloud_optimised_fileset_batch
    self._write_ds(ds, idx)
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 771, in _write_ds
    with xr.open_zarr(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1103, in open_zarr
    ds = open_dataset(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/api.py", line 611, in open_dataset
    backend_ds = backend.open_dataset(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1188, in open_dataset
    ds = store_entrypoint.open_dataset(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/store.py", line 46, in open_dataset
    vars, attrs, coord_names = conventions.decode_cf_variables(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 459, in decode_cf_variables
    raise type(e)(f"Failed to decode variable {k!r}: {e}") from e
ValueError: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 218, in _decode_cf_datetime_dtype
    result = decode_cf_datetime(example_value, units, calendar, use_cftime)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 349, in decode_cf_datetime
    dates = _decode_datetime_with_cftime(flat_num_dates, units, calendar)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 242, in _decode_datetime_with_cftime
    cftime.num2date(num_dates, units, calendar, only_use_cftime_datetimes=True)
  File "src/cftime/_cftime.pyx", line 587, in cftime._cftime.num2date
  File "src/cftime/_cftime.pyx", line 105, in cftime._cftime._dateparse
ValueError: In general, units must be one of 'microseconds', 'milliseconds', 'seconds', 'minutes', 'hours', or 'days' (or select abbreviated versions of these).  For the '360_day' calendar, 'months' can also be used, or for the 'noleap' calendar 'common_years' can also be used. Got 'nanoseconds' instead, which are not recognized.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 448, in decode_cf_variables
    new_vars[k] = decode_cf_variable(
                  ^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 289, in decode_cf_variable
    var = times.CFDatetimeCoder(use_cftime=use_cftime).decode(var, name=name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 992, in decode
    dtype = _decode_cf_datetime_dtype(data, units, calendar, self.use_cftime)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/coding/times.py", line 228, in _decode_cf_datetime_dtype
    raise ValueError(msg)
ValueError: unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 402, in publish_cloud_optimised_fileset_batch
    self._process_individual_file_fallback(
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 574, in _process_individual_file_fallback
    self._write_ds(ds, idx)
  File "/home/craig/git/aodn_cloud_optimised/aodn_cloud_optimised/lib/GenericZarrHandler.py", line 771, in _write_ds
    with xr.open_zarr(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1103, in open_zarr
    ds = open_dataset(
         ^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/api.py", line 611, in open_dataset
    backend_ds = backend.open_dataset(
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/zarr.py", line 1188, in open_dataset
    ds = store_entrypoint.open_dataset(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/backends/store.py", line 46, in open_dataset
    vars, attrs, coord_names = conventions.decode_cf_variables(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/craig/git/dataflow-orchestration/prefect-env/lib/python3.11/site-packages/xarray/conventions.py", line 459, in decode_cf_variables
    raise type(e)(f"Failed to decode variable {k!r}: {e}") from e
ValueError: Failed to decode variable 'end_time': unable to decode time units 'nanoseconds since 1970-01-01' with "calendar 'proleptic_gregorian'". Try opening your dataset with decode_times=False or installing cftime if it is not installed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant