Skip to content

Commit 67beffd

Browse files
committed
Fix missing import
1 parent 9b22f1c commit 67beffd

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

intertidal/io.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ def extract_geobox(
118118
# If `datacube` is not installed, only support `odc-geo` geometries
119119
try:
120120
from datacube.utils.geometry import Geometry as Geometry_datacube18
121+
121122
GEOM_TYPES = (odc.geo.geom.Geometry, Geometry_datacube18)
122123
except ImportError:
123-
GEOM_TYPES = (odc.geo.geom.Geometry)
124+
GEOM_TYPES = odc.geo.geom.Geometry
124125

125126
# Either `study_area` or `geom` must be provided
126127
if study_area is None and geom is None:
@@ -256,7 +257,6 @@ def load_data(
256257
to generate ODC lineage metadata for DEA Intertidal)
257258
258259
"""
259-
260260
# Attempt to import datacube and raise an error if not available
261261
try:
262262
from datacube.utils.masking import mask_invalid_data
@@ -532,6 +532,18 @@ def load_topobathy_mask(
532532
following analysis.
533533
534534
"""
535+
# Attempt to import datacube and raise an error if not available
536+
try:
537+
from datacube.utils.masking import mask_invalid_data
538+
except ImportError as e:
539+
msg = (
540+
"The `load_topobathy_mask` function requires `datacube` to be installed. "
541+
"Please consider loading data with `odc-stac` instead, or install "
542+
"DEA Intertidal with the `[datacube]` extra, e.g.: `pip install "
543+
"dea-intertidal[datacube]`"
544+
)
545+
raise ImportError(msg) from e
546+
535547
# Load from datacube, reprojecting to GeoBox of input satellite data
536548
topobathy_ds = dc.load(product=product, like=geobox, resampling=resampling).squeeze("time")
537549

@@ -588,6 +600,18 @@ def load_aclum_mask(
588600
False equals all other classes.
589601
590602
"""
603+
# Attempt to import datacube and raise an error if not available
604+
try:
605+
from datacube.utils.masking import mask_invalid_data
606+
except ImportError as e:
607+
msg = (
608+
"The `load_aclum_mask` function requires `datacube` to be installed. "
609+
"Please consider loading data with `odc-stac` instead, or install "
610+
"DEA Intertidal with the `[datacube]` extra, e.g.: `pip install "
611+
"dea-intertidal[datacube]`"
612+
)
613+
raise ImportError(msg) from e
614+
591615
try:
592616
# Load from datacube, reprojecting to GeoBox of input satellite data
593617
aclum_ds = dc.load(product=product, like=geobox, resampling=resampling).squeeze("time")

0 commit comments

Comments
 (0)