Skip to content

Commit 684bdbd

Browse files
authored
Merge pull request #631 from dcs4cop/forman-630-xcube_serve_to_ignore_datacube
xcube server to ignore datasets that cannot be opened
2 parents 309b921 + 72bedb7 commit 684bdbd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
### Enhancements
44

5+
* `xcube serve` used to shut down with an error message
6+
if it encountered datasets it could not open. New behaviour
7+
is to emit a warning and ignore such datasets. (#630)
8+
59
* Introduced helper function `add_spatial_ref()`
610
of package `xcube.core.gridmapping.cfconv` that allows
711
adding a spatial coordinate reference system to an existing

xcube/webapi/controllers/catalogue.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from xcube.constants import LOG
3030
from xcube.core.geom import get_dataset_bounds
3131
from xcube.core.normalize import DatasetIsNotACubeError
32+
from xcube.core.store import DataStoreError
3233
from xcube.core.timecoord import timestamp_to_iso_string
3334
from xcube.util.assertions import assert_instance
3435
from xcube.util.cmaps import get_cmaps
@@ -136,7 +137,11 @@ def get_dataset(ctx: ServiceContext,
136137
required_scopes = ctx.get_required_dataset_scopes(dataset_config)
137138
assert_scopes(required_scopes, granted_scopes or set())
138139

139-
ml_ds = ctx.get_ml_dataset(ds_id)
140+
try:
141+
ml_ds = ctx.get_ml_dataset(ds_id)
142+
except (ValueError, DataStoreError) as e:
143+
raise DatasetIsNotACubeError(f'could not open dataset: {e}') from e
144+
140145
grid_mapping = ml_ds.grid_mapping
141146
if not grid_mapping.crs.is_geographic:
142147
raise CubeIsNotDisplayable(f'CRS is not geographic:'

0 commit comments

Comments
 (0)