Xarray version 2026.4.0 breaks GraphCast Demo Notebook: Passing a Dataset to the constructor is not supported

Author: sttzrCreated Apr 25, 2026Updated Apr 25, 2026

There's yet another xarray 2026.4.0 incompatibility...

Problem

These lines in graphcast/rollout.py line 320:

python
  # Create copies to avoid mutating inputs.
  inputs = xarray.Dataset(inputs)
  targets_template = xarray.Dataset(targets_template)
  forcings = xarray.Dataset(forcings)

produce following error when running the rollout cell of the notebook cell inside graphcast_demo.ipynb:

TypeError: Passing a Dataset as data_vars to the Dataset constructor is not supported. Use ds.copy() to create a copy of a Dataset.

Reason

Again, the reason is breaking changes in Xarray 2026.4.0:

Passing a Dataset as data_vars to the Dataset constructor now raises TypeError. This was never intended behavior and silently dropped attrs. Use Dataset.copy() instead (GH11095). By Kristian Kollsga.

Proposed Solution

python
  # Create copies to avoid mutating inputs.
  inputs = inputs.copy()
  targets_template = targets_template.copy()
  forcings = forcings.copy()

(I did not check the complete repository for further deprecated usages!)

Source: google-deepmind/weathernext