Skip to content

Commit

Permalink
Merge pull request #457 from ImperialCollegeLondon/354-xarrayopen_mfd…
Browse files Browse the repository at this point in the history
…ataset-can-cause-problems-in-vr_run

Turning on single-threaded handling in dask
  • Loading branch information
davidorme authored Jun 27, 2024
2 parents 327ad85 + 5ff2268 commit e1ee433
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions virtual_ecosystem/core/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
from pathlib import Path
from typing import Any

import dask
import numpy as np
from xarray import DataArray, Dataset, open_mfdataset

Expand All @@ -133,6 +134,16 @@
from virtual_ecosystem.core.readers import load_to_dataarray
from virtual_ecosystem.core.utils import check_outfile

# There are ongoing xarray issues with NetCDF not being thread safe and this causes
# segfaults on different architectures in testing using `xarray.open_mfdataset`
# See:
# - https://github.com/pydata/xarray/issues/7079
# - https://github.com/pydata/xarray/issues/3961
#
# Following advice on both those issues, we currently explicitly stop dask from trying
# to use parallel file processing and use open_mfdataset(..., lock=False)
dask.config.set(scheduler="single-threaded")


class Data:
"""The Virtual Ecosystem data object.
Expand Down

0 comments on commit e1ee433

Please sign in to comment.