google-deepmind / google-deepmind/weathernext

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

Open Beginner friendly
#213 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
7.7k
Forks
986
PR merge metrics
No merged PRs in 30d

Description

There's [yet another](https://github.com/google-deepmind/graphcast/issues/212) xarray 2026.4.0 incompatibility...

# Problem

These lines in [`graphcast/rollout.py` line 320](https://github.com/google-deepmind/graphcast/blob/main/graphcast/rollout.py#L310-L313):
```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](https://docs.xarray.dev/en/latest/whats-new.html#v2026-04-0-apr-13-2026):
> 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()](https://docs.xarray.dev/en/latest/generated/xarray.Dataset.copy.html#xarray.Dataset.copy) instead ([GH11095](https://github.com/pydata/xarray/issues/11095)). By [Kristian Kollsga](https://github.com/kkollsga).

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

Contributor guide

Open the contributing guide

Research direction

Start with graphcast/rollout.py around line 320 and inspect the rollout cell in graphcast_demo.ipynb. Run the notebook's rollout cell with xarray 2026.4.0 and verify that the Dataset copies no longer raise the reported TypeError and the demo continues successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.