20
20
except ImportError :
21
21
from datacube .index .abstract import default_metadata_type_docs # type: ignore
22
22
23
- from datacube .model import Dataset , DatasetType , metadata_from_doc
23
+ from datacube .model import Dataset , Product , metadata_from_doc
24
24
from odc .geo import CRS
25
25
from odc .geo .geobox import GeoBox
26
26
from toolz import dicttoolz
60
60
)
61
61
62
62
63
- def _to_product (md : RasterCollectionMetadata ) -> DatasetType :
63
+ def _to_product (md : RasterCollectionMetadata ) -> Product :
64
64
def make_band (
65
65
band_key : BandKey ,
66
66
band : RasterBandMetadata ,
@@ -95,11 +95,11 @@ def make_band(
95
95
for band_key , band in md .meta .bands .items ()
96
96
],
97
97
}
98
- return DatasetType (_eo3 , doc )
98
+ return Product (_eo3 , doc )
99
99
100
100
101
101
@singledispatch
102
- def infer_dc_product (x : Any , cfg : Optional [ConversionConfig ] = None ) -> DatasetType :
102
+ def infer_dc_product (x : Any , cfg : Optional [ConversionConfig ] = None ) -> Product :
103
103
"""Overloaded function."""
104
104
raise TypeError (
105
105
"Invalid type, must be one of: pystac.item.Item, pystac.collection.Collection"
@@ -109,7 +109,7 @@ def infer_dc_product(x: Any, cfg: Optional[ConversionConfig] = None) -> DatasetT
109
109
@infer_dc_product .register (pystac .item .Item )
110
110
def infer_dc_product_from_item (
111
111
item : pystac .item .Item , cfg : Optional [ConversionConfig ] = None
112
- ) -> DatasetType :
112
+ ) -> Product :
113
113
"""
114
114
Infer Datacube product object from a STAC Item.
115
115
@@ -164,7 +164,7 @@ def _to_dataset(
164
164
item : ParsedItem ,
165
165
properties : Dict [str , Any ],
166
166
ds_uuid : uuid .UUID ,
167
- product : DatasetType ,
167
+ product : Product ,
168
168
) -> Dataset :
169
169
# pylint: disable=too-many-locals
170
170
@@ -228,7 +228,7 @@ def _to_dataset(
228
228
229
229
230
230
def _item_to_ds (
231
- item : pystac .item .Item , product : DatasetType , cfg : Optional [ConversionConfig ] = None
231
+ item : pystac .item .Item , product : Product , cfg : Optional [ConversionConfig ] = None
232
232
) -> Dataset :
233
233
"""
234
234
Construct Dataset object from STAC Item and previously constructed Product.
@@ -239,7 +239,7 @@ def _item_to_ds(
239
239
if cfg is None :
240
240
cfg = {}
241
241
242
- md : RasterCollectionMetadata = getattr (product , "_md" )
242
+ md : Optional [ RasterCollectionMetadata ] = getattr (product , "_md" , None )
243
243
uuid_cfg = cfg .get ("uuid" , {})
244
244
ds_uuid = _compute_uuid (
245
245
item , mode = uuid_cfg .get ("mode" , "auto" ), extras = uuid_cfg .get ("extras" , [])
@@ -252,7 +252,7 @@ def _item_to_ds(
252
252
def stac2ds (
253
253
items : Iterable [pystac .item .Item ],
254
254
cfg : Optional [ConversionConfig ] = None ,
255
- product_cache : Optional [Dict [str , DatasetType ]] = None ,
255
+ product_cache : Optional [Dict [str , Product ]] = None ,
256
256
) -> Iterator [Dataset ]:
257
257
"""
258
258
STAC :class:`~pystac.item.Item` to :class:`~datacube.model.Dataset` stream converter.
@@ -277,7 +277,7 @@ def stac2ds(
277
277
278
278
:param product_cache:
279
279
Input/Output parameter, contains mapping from collection name to deduced product definition,
280
- i.e. :py:class:`datacube.model.DatasetType ` object.
280
+ i.e. :py:class:`datacube.model.Product ` object.
281
281
282
282
.. rubric: Sample Configuration
283
283
@@ -313,7 +313,7 @@ def stac2ds(
313
313
warnings: ignore
314
314
315
315
"""
316
- products : Dict [str , DatasetType ] = {} if product_cache is None else product_cache
316
+ products : Dict [str , Product ] = {} if product_cache is None else product_cache
317
317
for item in items :
318
318
collection_id = _collection_id (item )
319
319
product = products .get (collection_id )
@@ -329,7 +329,7 @@ def stac2ds(
329
329
@infer_dc_product .register (pystac .collection .Collection )
330
330
def infer_dc_product_from_collection (
331
331
collection : pystac .collection .Collection , cfg : Optional [ConversionConfig ] = None
332
- ) -> DatasetType :
332
+ ) -> Product :
333
333
"""
334
334
Construct Datacube Product definition from STAC Collection.
335
335
0 commit comments