eomatch.datatree.resolve_product_path#
- eomatch.datatree.resolve_product_path(product, download: bool = True) str[source]#
Resolve the local filesystem path for product, downloading it first if needed.
Prefers an absolute local path registered as a STAC “data” asset (set by
Matchup.from_stac_itemwhen loading a downloaded catalogue product) over scrappi’s filesystem-derived path. The asset href stores the bare product path (no extension).product.get_path()is re-resolved after adownload_product()call, not just before it: for an offline-archive-backed collection (e.g. GISTDA THEOS-1) with no absoluteurlasset to fall back on,product.get_path()’s first call reflects whatever default filesystem the product happened to be constructed with (scrappi’s organised online-download convention, almost never where an offline archive’s files actually are) –download_product()is what re-pinsproduct.filesystemto the file’s real location (seescrappi.api.offlinebase.OfflineArchiveHandler.download_product), so the path has to be read again afterward to see that, not reused from before.When the
.tar.gzarchive is still present alongside it, that archive path is returned in preference to the bare (already-extracted) directory, even though the directory itself also satisfieseoio’s requirement that the path passed to it exists: routing through the archive path letseoio.utils.read_utils.extract_filerun its own extraction-completeness check (comparing the directory’s contents against the archive’s member list) and transparently re-extract if a previous extraction was interrupted (killed process, OOM, disk full, …) and left a directory that exists but is incomplete/corrupt – a bareos.path.existson the directory can’t tell that case apart from a genuinely complete extraction, which is what let corrupt band files (e.g. a truncated Landsat*_B3.TIF) go undetected and be read as-is on every subsequent call. Only when the archive has since been removed (e.g. cleaned up to save disk after a prior extraction) does this fall back to trusting the bare directory directly, since there’s then nothing left to validate it against.- Parameters:
product – product (e.g.
ProductItem) to resolve a path for.download – if
True, download the product first if it isn’t already present locally.
- Returns:
local filesystem path.