nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ecmwf/earthkit-data
Pull request #743 (2025-07-14 09:38:56)

Feature/merge 0.15.1 into develop


Patch:
diff --git a/docs/release_notes/version_0.15_updates.rst b/docs/release_notes/version_0.15_updates.rst
index 52f37d4..9885061 100644
--- a/docs/release_notes/version_0.15_updates.rst
+++ b/docs/release_notes/version_0.15_updates.rst
@@ -2,6 +2,15 @@ Version 0.15 Updates
 /////////////////////////
 
 
+Version 0.15.1
+===============
+
+Fixes
++++++++++++++++++
+
+- Fixed issue when :func:`xarray.open_dataset` did not work with the "earthkit" engine when a ``pathlib.Path`` object specified the input data (:pr:`741`).
+
+
 Version 0.15.0
 ===============
 
diff --git a/src/earthkit/data/utils/xarray/engine.py b/src/earthkit/data/utils/xarray/engine.py
index 8feeff4..da471cc 100644
--- a/src/earthkit/data/utils/xarray/engine.py
+++ b/src/earthkit/data/utils/xarray/engine.py
@@ -377,11 +377,14 @@ class EarthkitBackendEntrypoint(BackendEntrypoint):
 
     @staticmethod
     def _fieldlist(filename_or_obj, source_type):
+        import os
+        import pathlib
+
         from earthkit.data.core import Base
 
         if isinstance(filename_or_obj, Base):
             ds = filename_or_obj
-        elif isinstance(filename_or_obj, str):
+        elif isinstance(filename_or_obj, (str, os.PathLike, pathlib.Path)):
             from earthkit.data import from_source
 
             ds = from_source(source_type, filename_or_obj)


Test patch:
diff --git a/tests/xr_engine/test_xr_engine.py b/tests/xr_engine/test_xr_engine.py
index 7c574b6..7361828 100644
--- a/tests/xr_engine/test_xr_engine.py
+++ b/tests/xr_engine/test_xr_engine.py
@@ -10,6 +10,7 @@
 #
 
 import os
+import pathlib
 import sys
 
 import numpy as np
@@ -36,32 +37,28 @@ def test_xr_engine_kwargs_unchanged(engine):
 
 
 @pytest.mark.cache
-@pytest.mark.parametrize(
-    "file",
-    [
-        "pl.grib",
-        # "era5-levels-members",
-        # "fields_with_missing_values",
-        # "lambert_grid",
-        # "reduced_gg",
-        # "regular_gg_sfc",
-        # "regular_gg_pl",
-        # "regular_gg_ml",
-        # "regular_gg_ml_g2",
-        # "regular_ll_sfc",
-        # "regular_ll_msl",
-        # "scanning_mode_64",
-        # "single_gridpoint",
-        # "spherical_harmonics",
-        # "t_analysis_and_fc_0",
-    ],
-)
-def test_xr_engine_basic(file):
-    ds = from_source("url", earthkit_remote_test_data_file("test-data", "xr_engine", "level", file))
+def test_xr_engine_basic():
+    ds = from_source("url", earthkit_remote_test_data_file("test-data", "xr_engine", "level", "pl.grib"))
     res = ds.to_xarray()
     assert res is not None
 
 
+@pytest.mark.cache
+@pytest.mark.parametrize("path_maker", [lambda x: x, lambda x: pathlib.Path(x)])
+def test_xr_engine_open_dataset_path(path_maker):
+
+    ds = from_source("sample", "pl.grib")
+    path = path_maker(ds.path)
+
+    import xarray as xr
+
+    res = xr.open_dataset(
+        path,
+        engine="earthkit",
+    )
+    assert res is not None
+
+
 @pytest.mark.cache
 @pytest.mark.parametrize("api", ["earthkit", "xr"])
 def test_xr_engine_detailed_check_1(api):