Skip to content

Commit 3d6953a

Browse files
Fix file-pattern source returning wrong object (#697)
1 parent e171fe2 commit 3d6953a

File tree

4 files changed

+44
-7
lines changed

4 files changed

+44
-7
lines changed

docs/examples/files.ipynb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,14 @@
185185
"tags": []
186186
},
187187
"outputs": [
188+
{
189+
"name": "stderr",
190+
"output_type": "stream",
191+
"text": [
192+
"/Users/cgr/git/earthkit-data/src/earthkit/data/readers/netcdf/fieldlist.py:318: FutureWarning: In a future version of xarray decode_timedelta will default to False rather than None. To silence this warning, set decode_timedelta to True, False, or a 'CFTimedeltaCoder' instance.\n",
193+
" return xr.open_dataset(self.path_or_url)\n"
194+
]
195+
},
188196
{
189197
"data": {
190198
"text/html": [
@@ -508,10 +516,9 @@
508516
}
509517
],
510518
"source": [
511-
"\n",
512-
"fs = ekd.from_source(\"file-pattern\", \"./test{id}.grib\",\n",
519+
"ds = ekd.from_source(\"file-pattern\", \"./test{id}.grib\",\n",
513520
" {\"id\": [4, 6]})\n",
514-
"fs.ls()"
521+
"ds.ls()"
515522
]
516523
},
517524
{
@@ -531,9 +538,9 @@
531538
],
532539
"metadata": {
533540
"kernelspec": {
534-
"display_name": "dev_ecc",
541+
"display_name": "dev",
535542
"language": "python",
536-
"name": "dev_ecc"
543+
"name": "dev"
537544
},
538545
"language_info": {
539546
"codemirror_mode": {
@@ -545,7 +552,7 @@
545552
"name": "python",
546553
"nbconvert_exporter": "python",
547554
"pygments_lexer": "ipython3",
548-
"version": "3.10.13"
555+
"version": "3.11.12"
549556
}
550557
},
551558
"nbformat": 4,

docs/release_notes/version_0.14_updates.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Version 0.14 Updates
22
/////////////////////////
33

4+
Version 0.14.2
5+
===============
6+
7+
Fixes
8+
+++++++++++++++++
9+
10+
- Fixed issue when the :ref:`data-sources-file-pattern` source did not return the right data object when the ``hive_partitioning`` option was set to ``False`` (:pr:`697`).
11+
- Fixed issue when disabling the ``add_earthkit_attrs`` option in :py:meth:`~data.readers.grib.index.GribFieldList.to_xarray` caused a crash (:pr:`696`).
12+
413

514
Version 0.14.1
615
===============

src/earthkit/data/sources/file_pattern.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def mutate(self) -> Union["HiveFilePattern", "FilePattern"]:
9797
if self.hive_partitioning:
9898
return HiveFilePattern(self.pattern, self.params)
9999
else:
100-
return self
100+
return super().mutate()
101101

102102

103103
source = FilePattern

tests/sources/test_file_pattern.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
3+
# (C) Copyright 2020 ECMWF.
4+
#
5+
# This software is licensed under the terms of the Apache Licence Version 2.0
6+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7+
# In applying this licence, ECMWF does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an intergovernmental organisation
9+
# nor does it submit to any jurisdiction.
10+
#
11+
12+
13+
from earthkit.data import from_source
14+
from earthkit.data.testing import earthkit_examples_file
15+
16+
17+
def test_file_pattern_source_grib():
18+
ds = from_source("file-pattern", earthkit_examples_file("test{id}.grib"), {"id": [4, 6]})
19+
20+
assert len(ds) == 10
21+
assert ds.metadata("param") == ["t", "z", "t", "z", "t", "u", "v", "t", "u", "v"]

0 commit comments

Comments
 (0)