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

Index api consistency #1234

Merged
merged 4 commits into from Feb 22, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions datacube/index/abstract.py
Expand Up @@ -469,14 +469,13 @@ def bulk_get(self, ids: Iterable[DSID]) -> Iterable[Dataset]:
"""

@abstractmethod
def get_derived(self, id_: UUID) -> Iterable[Dataset]:
def get_derived(self, id_: DSID) -> Iterable[Dataset]:
"""
Get all datasets derived from a dataset

:param id_: dataset id
:rtype: list[Dataset]
"""
# TODO: Upgrade to DSID (requires changes to existing index driver)

@abstractmethod
def has(self, id_: DSID) -> bool:
Expand Down Expand Up @@ -585,7 +584,7 @@ def purge(self, ids: Iterable[UUID]) -> None:
"""

@abstractmethod
def get_all_dataset_ids(self, archived: bool) -> Iterable[str]:
def get_all_dataset_ids(self, archived: bool) -> Iterable[UUID]:
"""
Get all dataset IDs based only on archived status

Expand All @@ -595,7 +594,6 @@ def get_all_dataset_ids(self, archived: bool) -> Iterable[str]:
:param archived: If true, return all archived datasets, if false, all unarchived datatsets
:return: Iterable of dataset ids
"""
# TODO: Should return Iterable[UUID] for API consistency - requires changes to default index driver

@abstractmethod
def get_field_names(self, product_name: Optional[str] = None) -> Iterable[str]:
Expand Down
8 changes: 5 additions & 3 deletions datacube/index/postgres/_datasets.py
Expand Up @@ -116,9 +116,11 @@ def get_derived(self, id_):
"""
Get all derived datasets

:param UUID id_: dataset id
:param Union[str,UUID] id_: dataset id
:rtype: list[Dataset]
"""
if not isinstance(id_, UUID):
id_ = UUID(id_)
SpacemanPaul marked this conversation as resolved.
Show resolved Hide resolved
with self._db.connect() as connection:
return [
self._make(result, full_info=True)
Expand Down Expand Up @@ -372,10 +374,10 @@ def get_all_dataset_ids(self, archived: bool):
only intended for small and/or experimental databases.

:param archived:
:rtype: list[str]
:rtype: list[UUID]
"""
with self._db.begin() as transaction:
return [str(dsid[0]) for dsid in transaction.all_dataset_ids(archived)]
return [dsid[0] for dsid in transaction.all_dataset_ids(archived)]

def get_field_names(self, product_name=None):
"""
Expand Down
3 changes: 2 additions & 1 deletion datacube/scripts/dataset.py
Expand Up @@ -9,6 +9,7 @@
from collections import OrderedDict
from textwrap import dedent
from typing import Iterable, Mapping, MutableMapping, Any, List, Set
from uuid import UUID

import click
import yaml
Expand Down Expand Up @@ -452,7 +453,7 @@ def search_cmd(index, limit, f, expressions):
)


def _get_derived_set(index: Index, id_: str) -> Set[Dataset]:
def _get_derived_set(index: Index, id_: UUID) -> Set[Dataset]:
"""
Get a single flat set of all derived datasets.
(children, grandchildren, great-grandchildren...)
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Expand Up @@ -19,6 +19,7 @@ RUN apt-get update -y \
python3-dev python3-distutils python3-pip \
build-essential \
postgresql \
redis-server \
postgresql-client-${V_PG} \
postgresql-${V_PG} \
sudo make graphviz \
Expand Down
3 changes: 2 additions & 1 deletion docs/about/whats_new.rst
Expand Up @@ -8,6 +8,7 @@ What's New
v1.8.next
=========

- Regularise some minor API inconsistencies and restore redis-server to Docker image. (:pull:`1234`)
- Move (default) postgres driver-specific files from `datacube.index` to `datacube.index.postgres`.
`datacube.index.Index` is now an alias for the abstract base class index interface definition
rather than postgres driver-specific implementation of that interface. (:pull:`1231`)
Expand All @@ -16,7 +17,7 @@ v1.8.next
- Migrate test docker image from `datacube/geobase` to `osgeo/gdal`. (:pull:`1233`)
- Separate index driver interface definition from default index driver implementation. (:pull:`1226`)
- Prefer WKT over EPSG when guessing CRS strings. (:pull:`1223`)
- Updates install docs. (:pull:`1208`, :pull:`1212`, :pull:`1215`)
- Updates install docs. (:pull:`1208`, :pull:`1212`, :pull:`1215`, :pull:`1218`)
- Tweak to segmented in geometry to suppress Shapely warning. (:pull:`1207`)

v1.8.6 (30 September 2021)
Expand Down