Skip to content

Commit 05ff9e6

Browse files
authored
Merge pull request #929 from dcs4cop/forman-928-ref_data_store
Add `reference` data store
2 parents e3d0ec4 + 05c3759 commit 05ff9e6

15 files changed

+749
-28
lines changed

CHANGES.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22

33
### Enhancements
44

5-
* STAC
5+
* Added new `reference` filesystem data store to support
6+
"kerchunked" NetCDF files in object storage. (#928)
7+
8+
See also
9+
- [ReferenceFileSystem](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.implementations.reference.ReferenceFileSystem)
10+
- [kerchunk](https://github.com/fsspec/kerchunk)
11+
12+
* Improved xcube Server's STAC API:
613
* Provide links for multiple coverages data formats
714
* Add `crs` and `crs_storage` properties to STAC data
815
* Add spatial and temporal grid data to collection descriptions
916
* Add a schema endpoint returning a JSON schema of a dataset's data
1017
variables
1118
* Add links to domain set, range type, and range schema to collection
1219
descriptions
13-
* OGC API – Coverages:
20+
21+
* Improved xcube Server's Coverages API:
1422
* Support scaling parameters `scale-factor`, `scale-axes`, and `scale-size`
1523
* Improve handling of bbox parameters
1624
* Handle half-open datetime intervals
@@ -27,9 +35,11 @@
2735

2836
### Fixes
2937

30-
* Make S3 unit tests compatible with moto 5 server (#922)
31-
* Make some CLI unit tests compatible with pytest 8 (#922)
32-
* Rename some test classes to avoid spurious warnings (#924)
38+
* Fixed `KeyError: 'lon_bnds'` raised occasionally when opening
39+
(mostly NetCDF) datasets. (#930)
40+
* Make S3 unit tests compatible with moto 5 server. (#922)
41+
* Make some CLI unit tests compatible with pytest 8. (#922)
42+
* Rename some test classes to avoid spurious warnings. (#924)
3343

3444
### Other changes
3545

test/core/store/fs/test_registry.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
from abc import ABC, abstractmethod
12
import collections.abc
23
import os.path
34
import shutil
5+
from typing import Any, Callable, Dict, Optional, Set, Type, Union
46
import unittest
57
import warnings
6-
from abc import ABC, abstractmethod
7-
from typing import Any, Callable, Dict, Optional, Set, Type, Union
88

99
import fsspec
1010
import numpy as np
@@ -342,7 +342,7 @@ def _assert_dataset_supported(
342342
requested_dtype_alias: Optional[str],
343343
expected_dtype_aliases: Set[str],
344344
expected_return_type: Union[Type[xr.Dataset],
345-
Type[MultiLevelDataset]],
345+
Type[MultiLevelDataset]],
346346
expected_descriptor_type: Optional[Union[
347347
Type[DatasetDescriptor],
348348
Type[MultiLevelDatasetDescriptor]

test/core/store/ref/__init__.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# The MIT License (MIT)
2+
# Copyright (c) 2020-2024 by the xcube development team and contributors
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
# this software and associated documentation files (the "Software"), to deal in
6+
# the Software without restriction, including without limitation the rights to
7+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
# of the Software, and to permit persons to whom the Software is furnished to do
9+
# so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.

test/core/store/ref/test_schema.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# The MIT License (MIT)
2+
# Copyright (c) 2020-2024 by the xcube development team and contributors
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
# this software and associated documentation files (the "Software"), to deal in
6+
# the Software without restriction, including without limitation the rights to
7+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
# of the Software, and to permit persons to whom the Software is furnished to do
9+
# so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
22+
import unittest
23+
import json
24+
from xcube.core.store.ref.schema import REF_STORE_SCHEMA
25+
from xcube.util.jsonschema import JsonObjectSchema
26+
27+
28+
class ReferenceSchemaTest(unittest.TestCase):
29+
30+
def test_schema_schema(self):
31+
self.assertIsInstance(REF_STORE_SCHEMA, JsonObjectSchema)
32+
self.assertIsInstance(REF_STORE_SCHEMA.properties, dict)
33+
self.assertEqual(
34+
{
35+
'asynchronous',
36+
'cache_size',
37+
'listings_expiry_time',
38+
'max_block',
39+
'max_gap',
40+
'max_paths',
41+
'refs',
42+
'remote_options',
43+
'remote_protocol',
44+
'skip_instance_cache',
45+
'target_options',
46+
'target_protocol',
47+
'use_listings_cache'
48+
},
49+
set(REF_STORE_SCHEMA.properties.keys())
50+
)
51+
52+
def test_json_serialisation(self):
53+
d = REF_STORE_SCHEMA.to_dict()
54+
self.assertEqual(d, json.loads(json.dumps(d)))

0 commit comments

Comments
 (0)