Skip to content

Commit

Permalink
Merge pull request #589 from dcs4cop/toniof-576-last_identifier
Browse files Browse the repository at this point in the history
Only last configured Identifier is published via xcube serve
  • Loading branch information
TonioF authored Jan 19, 2022
2 parents d8e1247 + ad5aea2 commit 5038797
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
* Fixed bug that would cause that requesting data ids on some s3 stores would
fail with a confusing ValueError.

* Fixed that only last dataset of a directory listing was published via
`xcube serve` when using the `DataStores` configuration with
filesystem-based datastores such as "s3" or "file". (#576)

### Other

* Pinned Python version to < 3.10 to avoid ImportErrors caused by a third-party
Expand Down
10 changes: 10 additions & 0 deletions test/webapi/res/test/config-datastores.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DataStores:
- Identifier: test
StoreId: file
StoreParams:
root: examples/serve/demo
Datasets:
- Identifier: "cube-1-250-250.zarr"
Style: "default"
- Identifier: "cube-5-100-200.zarr"
Style: "default"
10 changes: 10 additions & 0 deletions test/webapi/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ def test_get_dataset_with_augmentation(self):
conc_chl_z = ctx.get_variable_for_z('demo-aug', var_name, z)
self.assertIsInstance(conc_chl_z, xr.DataArray)

def test_get_dataset_configs_from_stores(self):
ctx = new_test_service_context(config_file_name='config-datastores.yml')

dataset_configs_from_stores = ctx.get_dataset_configs_from_stores()
self.assertIsNotNone(dataset_configs_from_stores)
self.assertEqual(2, len(dataset_configs_from_stores))
ids = [config['Identifier'] for config in dataset_configs_from_stores]
self.assertIn('test~cube-1-250-250.zarr', ids)
self.assertIn('test~cube-5-100-200.zarr', ids)

def test_config_and_dataset_cache(self):
ctx = new_test_service_context()
self.assertNotIn('demo', ctx.dataset_cache)
Expand Down
1 change: 1 addition & 0 deletions xcube/webapi/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ def get_dataset_configs_from_stores(self) \
if fnmatch.fnmatch(store_dataset_id,
dataset_id_pattern):
dataset_config_base = store_dataset_config
break
else:
dataset_config_base = None
if dataset_config_base is not None:
Expand Down

0 comments on commit 5038797

Please sign in to comment.