Skip to content

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

Description

@sttzr

There's yet another xarray 2026.4.0 incompatibility...

Problem

These lines in graphcast/rollout.py line 320:

  # 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

  # 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!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions