Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak list_products to consider load_hints #1535

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions datacube/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def list_products(self, with_pandas=True, dataset_count=False):
:return: A table or list of every product in the datacube.
:rtype: pandas.DataFrame or list(dict)
"""
def _get_non_default(product, col):
load_hints = product.load_hints()
if load_hints:
if col == 'crs':
return load_hints.get('output_crs', None)
return load_hints.get(col, None)
return getattr(product.grid_spec, col, None)

# Read properties from each datacube product
cols = [
'name',
Expand All @@ -125,10 +133,10 @@ def list_products(self, with_pandas=True, dataset_count=False):
getattr(pr, col, None)
# if 'default_crs' and 'default_resolution' are not None
# return 'default_crs' and 'default_resolution'
if getattr(pr, col, None) and 'default' not in col
# else try 'grid_spec.crs' and 'grid_spec.resolution'
if getattr(pr, col, None) or 'default' not in col
# else get crs and resolution from load_hints or grid_spec
# as per output_geobox() handling logic
else getattr(pr.grid_spec, col.replace('default_', ''), None)
else _get_non_default(pr, col.replace('default_', ''))
for col in cols]
for pr in self.index.products.get_all()]

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Copyright (c) 2015-2020 ODC Contributors
## SPDX-License-Identifier: Apache-2.0
##
FROM osgeo/gdal:ubuntu-small-latest
FROM ghcr.io/osgeo/gdal:ubuntu-small-latest
ARG V_PG=14
ARG V_PGIS=14-postgis-3

Expand Down
1 change: 1 addition & 0 deletions docs/about/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ v1.8.next
- Update pandas version in docker image to be consistent with conda environment and default to stdlib
timezone instead of pytz when converting timestamps; automatically update copyright years (:pull:`1527`)
- Update github-Dockerhub credential-passing mechanism. (:pull:`1528`)
- Tweak ``list_products`` logic for getting crs and resolution values (:pull:`1535`)

v1.8.17 (8th November 2023)
===========================
Expand Down