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

Handle lineage for 1.9 #1

Open
jmettes opened this issue Sep 2, 2024 · 2 comments
Open

Handle lineage for 1.9 #1

jmettes opened this issue Sep 2, 2024 · 2 comments

Comments

@jmettes
Copy link
Contributor

jmettes commented Sep 2, 2024

I think dc.index.datasets.add() might need ignore flag? but I think 1.9 does handle lineage, so not sure.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[25], line 1
----> 1 stac_api_to_dc.process_item(rename_product="s2_l2a", item=pystac.read_dict(item), dc=dc, doc2ds=Doc2Dataset(dc.index), update_if_exists=False, allow_unsafe=False, archive_less_mature=False)

File [~/micromamba/envs/generic-mamba/envs/cubeenv/lib/python3.11/site-packages/odc/apps/dc_tools/stac_api_to_dc.py:97](http://localhost:8888/home/jonathan/micromamba/envs/generic-mamba/envs/cubeenv/lib/python3.11/site-packages/odc/apps/dc_tools/stac_api_to_dc.py#line=96), in process_item(item, dc, doc2ds, update_if_exists, allow_unsafe, rename_product, archive_less_mature, publish_action)
     86 def process_item(
     87     item: Item,
     88     dc: Datacube,
   (...)
     94     publish_action: bool = False,
     95 ):
     96     meta, uri, stac = item_to_meta_uri(item, rename_product)
---> 97     index_update_dataset(
     98         meta,
     99         uri,
    100         dc,
    101         doc2ds,
    102         update_if_exists=update_if_exists,
    103         allow_unsafe=allow_unsafe,
    104         archive_less_mature=archive_less_mature,
    105         publish_action=publish_action,
    106         stac_doc=stac,
    107     )

File [~/micromamba/envs/generic-mamba/envs/cubeenv/lib/python3.11/site-packages/odc/apps/dc_tools/utils.py:277](http://localhost:8888/home/jonathan/micromamba/envs/generic-mamba/envs/cubeenv/lib/python3.11/site-packages/odc/apps/dc_tools/utils.py#line=276), in index_update_dataset(metadata, uri, dc, doc2ds, update, update_if_exists, allow_unsafe, archive_less_mature, publish_action, stac_doc)
    273             raise IndexingException(
    274                 "Can't update dataset because it doesn't exist."
    275             )
    276         # Everything is working as expected, add the dataset
--> 277         dc.index.datasets.add(ds, archive_less_mature=archive_less_mature)
    278         added = True
    280 if publish_action:

File [~/dea/datacube-core/datacube/index/postgis/_datasets.py:158](http://localhost:8888/home/jonathan/dea/datacube-core/datacube/index/postgis/_datasets.py#line=157), in DatasetResource.add(self, dataset, with_lineage, archive_less_mature)
    140 """
    141 Add ``dataset`` to the index. No-op if it is already present.
    142 
   (...)
    154 :rtype: Dataset
    155 """
    157 if with_lineage:
--> 158     raise ValueError("Lineage is not yet supported by the postgis driver")
    160 _LOG.info('Indexing %s', dataset.id)
    162 if self.has(dataset.id):
@Ariana-B
Copy link

Ariana-B commented Sep 2, 2024

Need to specify with_lineage=False to bypass, but the error message is outdated since postgis driver does support lineage (albeit differently from postgres driver)

@jmettes
Copy link
Contributor Author

jmettes commented Sep 2, 2024

edit: ignore this comment, i fixed it

doc2ds = Doc2Dataset(dc.index)
doc2ds(_stac.stac_transform(item), uri)

original msg for posterity

found another lineage thing

from pystac_client import Client
client = Client.open("https://earth-search.aws.element84.com/v1")
bbox = [
176.13470010353373,
-85.035941506574,
180,
-84.59129667426426
]
search_results = client.search(
collections=["sentinel-2-c1-l2a"],
bbox=bbox,
datetime="2024-01-29/2024-01-31",
)
item = search_results.item_collection().items[0].to_dict()
item['properties']['proj:transform'] = item['assets']['red']['proj:transform']
item['properties']['proj:shape'] = item['assets']['red']['proj:shape']
item["properties"]["odc:product"] = "s2_l2a"
uri = item["links"][1]['href']

from datacube.index.hl import Doc2Dataset
Doc2Dataset(_stac.stac_transform(item), uri)


AttributeError Traceback (most recent call last)
Cell In[36], line 1
----> 1 Doc2Dataset(_stac.stac_transform(item), uri)

File ~/dea/datacube-core/datacube/index/hl.py:387, in Doc2Dataset.init(self, index, products, exclude_products, fail_on_missing_lineage, verify_lineage, skip_lineage, eo3, home_index)
378 def init(self,
379 index: AbstractIndex,
380 products: Optional[Sequence[str]] = None,
(...)
385 eo3: Union[bool, str] = 'auto',
386 home_index: Optional[str] = None):
--> 387 if not index.supports_lineage:
388 skip_lineage = True
389 verify_lineage = False

AttributeError: 'dict' object has no attribute 'supports_lineage'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants