From b2e06a9204621d506fd3f35869534b0ba95ec208 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Tue, 1 Mar 2022 17:12:02 +0100 Subject: [PATCH 1/2] xcube server to ignore datasets that cannot be opened --- CHANGES.md | 4 ++++ xcube/webapi/controllers/catalogue.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ac85154e2..b9f444970 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ### Enhancements +* `xcube serve` used to shut down with an error message + if it encountered datasets it could not open. New behaviour + is to emit a warning and ignore such datasets. (#630) + * Introduced parameter `base_dataset_id` for writing multi-level datasets with the "file", "s3", and "memory" data stores. If given, the base dataset will be linked only with the diff --git a/xcube/webapi/controllers/catalogue.py b/xcube/webapi/controllers/catalogue.py index bdd396789..e512aec0a 100644 --- a/xcube/webapi/controllers/catalogue.py +++ b/xcube/webapi/controllers/catalogue.py @@ -40,7 +40,7 @@ from xcube.webapi.controllers.tiles import get_dataset_tile_url from xcube.webapi.controllers.tiles import get_tile_source_options from xcube.webapi.errors import ServiceBadRequestError - +import zarr def get_datasets(ctx: ServiceContext, details: bool = False, @@ -136,7 +136,11 @@ def get_dataset(ctx: ServiceContext, required_scopes = ctx.get_required_dataset_scopes(dataset_config) assert_scopes(required_scopes, granted_scopes or set()) - ml_ds = ctx.get_ml_dataset(ds_id) + try: + ml_ds = ctx.get_ml_dataset(ds_id) + except ValueError as e: + raise DatasetIsNotACubeError(f'could not open dataset: {e}') from e + grid_mapping = ml_ds.grid_mapping if not grid_mapping.crs.is_geographic: raise CubeIsNotDisplayable(f'CRS is not geographic:' From 9ec79a0dd65ee58521ec923b5bce2ad4f4964ac4 Mon Sep 17 00:00:00 2001 From: Norman Fomferra Date: Tue, 1 Mar 2022 17:21:03 +0100 Subject: [PATCH 2/2] xcube server to ignore datasets that cannot be opened --- xcube/webapi/controllers/catalogue.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xcube/webapi/controllers/catalogue.py b/xcube/webapi/controllers/catalogue.py index e512aec0a..affd17226 100644 --- a/xcube/webapi/controllers/catalogue.py +++ b/xcube/webapi/controllers/catalogue.py @@ -29,6 +29,7 @@ from xcube.constants import LOG from xcube.core.geom import get_dataset_bounds from xcube.core.normalize import DatasetIsNotACubeError +from xcube.core.store import DataStoreError from xcube.core.timecoord import timestamp_to_iso_string from xcube.util.assertions import assert_instance from xcube.util.cmaps import get_cmaps @@ -40,7 +41,7 @@ from xcube.webapi.controllers.tiles import get_dataset_tile_url from xcube.webapi.controllers.tiles import get_tile_source_options from xcube.webapi.errors import ServiceBadRequestError -import zarr + def get_datasets(ctx: ServiceContext, details: bool = False, @@ -138,7 +139,7 @@ def get_dataset(ctx: ServiceContext, try: ml_ds = ctx.get_ml_dataset(ds_id) - except ValueError as e: + except (ValueError, DataStoreError) as e: raise DatasetIsNotACubeError(f'could not open dataset: {e}') from e grid_mapping = ml_ds.grid_mapping