From 98993fc2ba5e3a9f0dd92c08c6f5289434381f76 Mon Sep 17 00:00:00 2001 From: Matthew Iannucci Date: Tue, 3 Dec 2024 17:16:00 -0500 Subject: [PATCH] Protect zarr imports --- xpublish/plugins/included/dataset_info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xpublish/plugins/included/dataset_info.py b/xpublish/plugins/included/dataset_info.py index 4b4f9bf..88dfc8e 100644 --- a/xpublish/plugins/included/dataset_info.py +++ b/xpublish/plugins/included/dataset_info.py @@ -3,11 +3,9 @@ import xarray as xr from fastapi import APIRouter, Depends from starlette.responses import HTMLResponse # type: ignore -from zarr.storage import attrs_key # type: ignore from xpublish.utils.api import JSONResponse -from ...utils.zarr import get_zmetadata, get_zvariables from .. import Dependencies, Plugin, hookimpl @@ -54,6 +52,9 @@ def info( cache=Depends(deps.cache), ) -> dict: """Dataset schema (close to the NCO-JSON schema).""" + from zarr.storage import attrs_key # type: ignore + from ...utils.zarr import get_zmetadata, get_zvariables + zvariables = get_zvariables(dataset, cache) zmetadata = get_zmetadata(dataset, cache, zvariables)