Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0abb3ef
use odc-geo, make 1.9-compatible, update deps
Oct 3, 2024
7331cc2
Do not hang on empty stac file
pjonsson Nov 18, 2024
28fb1af
Fix miniconda installation
whatnick Nov 21, 2024
8218aad
Mamba does not get installed without mamba-version
whatnick Nov 21, 2024
dc4bac2
Merge pull request #619 from opendatacube/fix/mamba-deprecation
whatnick Nov 21, 2024
93e7440
use odc-geo, make 1.9-compatible, update deps
Oct 3, 2024
b90896c
Get ready for 1.9 release (#625)
Ariana-B Jan 8, 2025
663b448
Cherry picks
abradley60 Jul 22, 2024
4536bd8
Adding test for deafrica s2_l2a_c1 (#614)
abradley60 Jul 24, 2024
6480ebb
Cherry picks
SpacemanPaul Jul 23, 2024
a987ce5
Do not hang on empty stac file
pjonsson Nov 18, 2024
f96c2f7
Fix miniconda installation
whatnick Nov 21, 2024
973dff2
Mamba does not get installed without mamba-version
whatnick Nov 21, 2024
a120767
Merge commit 'dc4bac2708cc283cc41cef64bf4da0f103b60670' into integrat…
Jan 9, 2025
dda7338
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Oct 14, 2024
de50461
Avoid network access in ESA WorldCover Test
omad Mar 1, 2023
aafd64e
Add to .gitignore
omad Nov 21, 2024
6bc8ae4
Fix GHA: Use postgresql service
omad Nov 21, 2024
cefa0be
Remove unused line from CI workflow
omad Nov 22, 2024
23fd72b
XFail failing tests
omad Nov 22, 2024
2acb9fd
[pre-commit.ci] pre-commit autoupdate
pre-commit-ci[bot] Dec 2, 2024
f90b308
remove xfail
Jan 9, 2025
a2547bc
fix esa test path error
Jan 13, 2025
bf95c1a
Merge branch 'develop-1.9' into integrate_1.9
Ariana-B Jan 13, 2025
dc33fa1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2025
4bb1250
add odc-stac to conda env reqs
Jan 13, 2025
eeed301
[CI] Fix build, broken mamba argument
omad Jan 14, 2025
58c07d3
[CI] Fix pylint linting errors
omad Jan 14, 2025
c486419
[CI] Use Python 3.12, add logging to debug DB issue
omad Jan 14, 2025
5c86632
[CI] Use correct ENV var to configure ODC
omad Jan 14, 2025
3638ae3
fix dataset indexing handling
Jan 14, 2025
8878a65
[tests] update and use local version of eo3_sentinel_ard.odc-type
omad Jan 14, 2025
36cfc78
[tests] Fix esa worldcover indexer test not finding data
omad Jan 14, 2025
8ef9741
fix json serialization error
Jan 14, 2025
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
559 changes: 291 additions & 268 deletions .github/workflows/main.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ docs/notebooks/
.run/

docker/wheels/

.jj
.ropeproject
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: yamllint
args: ['-c', '.yamllint']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: check-docstring-first
Expand All @@ -26,14 +26,14 @@ repos:
# name: isort (python)
# args: [ "--profile", "black", "--filter-files" ]
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/pylint
rev: 'v3.2.3' # Use the sha / tag you want to point at
rev: 'v3.3.2' # Use the sha / tag you want to point at
hooks:
- id: pylint
- repo: https://github.com/PyCQA/flake8
rev: '7.0.0'
rev: '7.1.1'
hooks:
- id: flake8
4 changes: 2 additions & 2 deletions apps/dc_tools/odc/apps/dc_tools/_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

import numpy
from datacube.model import Dataset
from datacube.utils.geometry import Geometry, box
from odc.geo.geom import Geometry, box
from eodatasets3.stac import to_stac_item
from eodatasets3.serialise import from_doc
from toolz import get_in
from urllib.parse import urlparse

Expand Down Expand Up @@ -452,7 +453,6 @@ def transform_geom_json_coordinates_to_list(geom_json):

def ds_to_stac(ds: Dataset) -> dict:
"""Get STAC document from dataset with eo3 metadata"""
from eodatasets3.serialise import from_doc
if ds.is_eo3:
if not ds.uris:
raise ValueError("Can't find dataset location")
Expand Down
2 changes: 1 addition & 1 deletion apps/dc_tools/odc/apps/dc_tools/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.18"
__version__ = "1.9.0"
10 changes: 8 additions & 2 deletions apps/dc_tools/odc/apps/dc_tools/add_update_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import datacube
from datacube import Datacube
from datacube.cfg import ODCEnvironment
from datacube.ui.click import environment_option, pass_config
from odc.apps.dc_tools.utils import (
update_if_exists_flag,
statsd_gauge_reporting,
Expand Down Expand Up @@ -123,12 +125,16 @@ def add_update_products(


@click.command("dc-sync-products")
@environment_option
@pass_config
@click.argument("csv-path", nargs=1)
@update_if_exists_flag
@statsd_setting
def cli(csv_path: str, update_if_exists: bool, statsd_setting: str):
def cli(
cfg_env: ODCEnvironment, csv_path: str, update_if_exists: bool, statsd_setting: str
):
# Check we can connect to the Datacube
dc = datacube.Datacube(app="add_update_products")
dc = datacube.Datacube(app="add_update_products", env=cfg_env)
logging.info(
"Starting up: connected to Datacube, and update-if-exists is: %s",
update_if_exists,
Expand Down
7 changes: 6 additions & 1 deletion apps/dc_tools/odc/apps/dc_tools/azure_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

import click
from datacube import Datacube
from datacube.cfg import ODCEnvironment
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from odc.apps.dc_tools._stac import stac_transform
from odc.apps.dc_tools.utils import (
SkippedException,
Expand Down Expand Up @@ -128,6 +130,8 @@ def dump_list_to_odc(


@click.command("azure-to-dc")
@environment_option
@pass_config
@update_flag
@update_if_exists_flag
@allow_unsafe
Expand All @@ -151,6 +155,7 @@ def dump_list_to_odc(
@click.argument("suffix", type=str, nargs=1)
@rename_product
def cli(
cfg_env: ODCEnvironment,
update: bool,
update_if_exists: bool,
allow_unsafe: bool,
Expand All @@ -166,7 +171,7 @@ def cli(
rename_product: str,
):
# Set up the datacube first, to ensure we have a connection
dc = Datacube()
dc = Datacube(env=cfg_env)
print(f"Opening AZ Container {container_name} on {account_url}")
print(f"Searching on prefix '{prefix}' for files matching suffix '{suffix}'")
yaml_urls = find_blobs(
Expand Down
6 changes: 5 additions & 1 deletion apps/dc_tools/odc/apps/dc_tools/cop_dem_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from datacube import Datacube
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from datacube.utils import read_documents
from odc.apps.dc_tools.utils import (
SkippedException,
Expand Down Expand Up @@ -202,6 +203,8 @@ def cop_dem_to_dc(


@click.command("cop-dem-to-dc")
@environment_option
@pass_config
@limit
@update_if_exists_flag
@bbox
Expand All @@ -226,6 +229,7 @@ def cop_dem_to_dc(
help="Number of threads to use to process, default 20",
)
def cli(
cfg_env,
limit,
update_if_exists,
bbox,
Expand All @@ -244,7 +248,7 @@ def cli(
f"Unknown product {product}, must be one of {' '.join(PRODUCTS)}"
)

dc = Datacube()
dc = Datacube(env=cfg_env)

if add_product:
add_cop_dem_product(dc, product)
Expand Down
11 changes: 9 additions & 2 deletions apps/dc_tools/odc/apps/dc_tools/esa_worldcover_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from datacube import Datacube
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from datacube.utils import read_documents
from odc.apps.dc_tools.utils import (
bbox,
Expand Down Expand Up @@ -112,6 +113,7 @@ def get_tile_uris(bounding_box: str) -> Tuple[str, str]:
)


# pylint: disable=too-many-positional-arguments
def process_uri_tile(
uri_tile: Tuple[str, str, str],
dc: Datacube,
Expand Down Expand Up @@ -160,6 +162,7 @@ def select_map_version(version: str):
map_version["algo"] = "v200"


# pylint: disable=too-many-positional-arguments
def esa_wc_to_dc(
dc: Datacube,
bounding_box,
Expand Down Expand Up @@ -204,6 +207,7 @@ def esa_wc_to_dc(
sys.stdout.write(f"\rAdded {success} datasets...")
except rasterio.errors.RasterioIOError:
logging.info("Couldn't read file %s", uri, exc_info=True)
failure += 1
except Exception: # pylint:disable=broad-except
logging.exception("Failed to handle uri %s", uri)
failure += 1
Expand All @@ -213,6 +217,8 @@ def esa_wc_to_dc(


@click.command("esa-wc-to-dc")
@environment_option
@pass_config
@limit
@update_if_exists_flag
@bbox
Expand All @@ -237,7 +243,8 @@ def esa_wc_to_dc(
type=str,
help="Select version of world cover map, default 2020",
)
def cli(
def cli( # pylint: disable=too-many-positional-arguments
cfg_env,
limit,
update_if_exists,
bbox,
Expand All @@ -255,7 +262,7 @@ def cli(
# Select map version
select_map_version(version)

dc = Datacube()
dc = Datacube(env=cfg_env)

if add_product:
add_odc_product(dc)
Expand Down
6 changes: 5 additions & 1 deletion apps/dc_tools/odc/apps/dc_tools/fs_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import datacube
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from odc.apps.dc_tools._stac import stac_transform
from odc.apps.dc_tools.utils import (
allow_unsafe,
Expand All @@ -26,6 +27,8 @@


@click.command("fs-to-dc")
@environment_option
@pass_config
@click.argument("input_directory", type=str, nargs=1)
@update_if_exists_flag
@allow_unsafe
Expand All @@ -39,6 +42,7 @@
help="File system glob to use, defaults to **/*.yaml or **/*.json for STAC.",
)
def cli(
cfg_env,
input_directory,
update_if_exists,
allow_unsafe,
Expand All @@ -48,7 +52,7 @@ def cli(
archive_less_mature,
publish_action,
):
dc = datacube.Datacube()
dc = datacube.Datacube(env=cfg_env)
doc2ds = Doc2Dataset(dc.index)

if glob is None:
Expand Down
9 changes: 8 additions & 1 deletion apps/dc_tools/odc/apps/dc_tools/s3_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from datacube import Datacube
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from odc.apps.dc_tools._docs import parse_doc_stream
from odc.apps.dc_tools._stac import stac_transform
from odc.apps.dc_tools.utils import (
Expand Down Expand Up @@ -62,6 +63,9 @@ def dump_to_odc(

found_docs = False
for uri, metadata in uris_docs:
if metadata is None:
ds_skipped += 1
continue
found_docs = True
stac_doc = None
if transform:
Expand Down Expand Up @@ -93,6 +97,8 @@ def dump_to_odc(


@click.command("s3-to-dc")
@environment_option
@pass_config
@click.option(
"--log",
type=click.Choice(
Expand All @@ -118,6 +124,7 @@ def dump_to_odc(
@click.argument("uris", nargs=-1)
@click.argument("product", type=str, nargs=1, required=False)
def cli(
cfg_env,
log,
skip_lineage,
fail_on_missing_lineage,
Expand Down Expand Up @@ -156,7 +163,7 @@ def cli(
if request_payer:
opts["RequestPayer"] = "requester"

dc = Datacube()
dc = Datacube(env=cfg_env)

# if it's a uri, a product wasn't provided, and 'product' is actually another uri
if product.startswith("s3://"):
Expand Down
6 changes: 5 additions & 1 deletion apps/dc_tools/odc/apps/dc_tools/sqs_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from datacube import Datacube
from datacube.index.hl import Doc2Dataset
from datacube.ui.click import environment_option, pass_config
from datacube.utils import documents
from odc.apps.dc_tools.utils import (
IndexingException,
Expand Down Expand Up @@ -306,6 +307,8 @@ def queue_to_odc(


@click.command("sqs-to-dc")
@environment_option
@pass_config
@skip_lineage
@fail_on_missing_lineage
@verify_lineage
Expand Down Expand Up @@ -342,6 +345,7 @@ def queue_to_odc(
@click.argument("queue_name", type=str, nargs=1)
@click.argument("product", type=str, nargs=1)
def cli(
cfg_env,
skip_lineage,
fail_on_missing_lineage,
verify_lineage,
Expand Down Expand Up @@ -369,7 +373,7 @@ def cli(
queue = sqs.get_queue_by_name(QueueName=queue_name)

# Do the thing
dc = Datacube()
dc = Datacube(env=cfg_env)
success, failed, skipped = queue_to_odc(
queue,
dc,
Expand Down
11 changes: 8 additions & 3 deletions apps/dc_tools/odc/apps/dc_tools/stac_api_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import click
from datacube import Datacube
from datacube.model import Dataset

from datacube.ui.click import environment_option, pass_config
from odc.stac.eo3 import stac2ds

from odc.apps.dc_tools.utils import (
Expand Down Expand Up @@ -90,7 +90,9 @@ def item_to_meta_uri(
"Couldn't find matching product for product name: %s",
product_name_sanitised,
)
raise SkippedException(f"Couldn't find matching product for product name: {product_name_sanitised}")
raise SkippedException(
f"Couldn't find matching product for product name: {product_name_sanitised}"
)

# Convert the STAC Item to a Dataset
dataset = next(stac2ds([item]))
Expand Down Expand Up @@ -183,6 +185,8 @@ def stac_api_to_odc(


@click.command("stac-to-dc")
@environment_option
@pass_config
@limit
@update_if_exists_flag
@allow_unsafe
Expand Down Expand Up @@ -216,6 +220,7 @@ def stac_api_to_odc(
@publish_action
@statsd_setting
def cli(
cfg_env,
limit,
update_if_exists,
allow_unsafe,
Expand Down Expand Up @@ -249,7 +254,7 @@ def cli(
config["max_items"] = limit

# Do the thing
dc = Datacube()
dc = Datacube(env=cfg_env)
added, failed, skipped = stac_api_to_odc(
dc,
update_if_exists,
Expand Down
Loading
Loading