diff --git a/dep_tools/namers.py b/dep_tools/namers.py index 2cc53c6..2c87d6d 100644 --- a/dep_tools/namers.py +++ b/dep_tools/namers.py @@ -18,7 +18,7 @@ def __init__( version: str, time: str, prefix: str = "dep", - zero_pad_numbers: bool = False, + zero_pad_numbers: bool = True, ): self.sensor = sensor self.dataset_id = dataset_id @@ -86,7 +86,7 @@ def __init__( version: str, time: str, prefix: str = "dep", - zero_pad_numbers: bool = False, + zero_pad_numbers: bool = True, ): super().__init__( sensor=sensor, diff --git a/dep_tools/stac_utils.py b/dep_tools/stac_utils.py index c693ac7..e71c541 100644 --- a/dep_tools/stac_utils.py +++ b/dep_tools/stac_utils.py @@ -21,7 +21,7 @@ def __init__( itempath: DepItemPath, remote: bool = True, collection_url_root: str = "https://stac.staging.digitalearthpacific.org/collections", - make_hrefs_https: bool = False, + make_hrefs_https: bool = True, **kwargs, ): self._itempath = itempath @@ -52,7 +52,7 @@ def get_stac_item( data: DataArray | Dataset, remote: bool = True, collection_url_root: str = "https://stac.staging.digitalearthpacific.org/collections", - make_hrefs_https: bool = False, + make_hrefs_https: bool = True, **kwargs, ) -> Item | str: prefix = Path("./") @@ -65,7 +65,7 @@ def get_stac_item( if make_hrefs_https: # E.g., https://dep-public-prod.s3.us-west-2.amazonaws.com/ prefix = URL( - f"https://{getattr(itempath, 'bucket')}.s3/us-west-2.amazonaws.com" + f"https://{getattr(itempath, 'bucket')}.s3.us-west-2.amazonaws.com" ) else: # E.g., s3://dep-public-prod/ diff --git a/tests/test_get_stac_item.py b/tests/test_get_stac_item.py index 491ea00..92daef9 100644 --- a/tests/test_get_stac_item.py +++ b/tests/test_get_stac_item.py @@ -19,6 +19,7 @@ def stac_item(): dataset_id="wofs", version="1.0.0", time="2021-01-01", + zero_pad_numbers=False, ) tif = itempath.path("12,34", asset_name="wofs") test_xr = rioxarray.open_rasterio(tif).to_dataset(name="wofs") @@ -26,7 +27,7 @@ def stac_item(): itempath=itempath, item_id="12,34", data=test_xr, - remote=False, + remote=False ) return item diff --git a/tests/test_namers.py b/tests/test_namers.py index a16bd91..94a76dd 100644 --- a/tests/test_namers.py +++ b/tests/test_namers.py @@ -6,6 +6,7 @@ time = "2045" testItemPath = DepItemPath(sensor, dataset_id, version, time) paddedItemPath = DepItemPath(sensor, dataset_id, version, time, zero_pad_numbers=True) +nonPaddedItemPath = DepItemPath(sensor, dataset_id, version, time, zero_pad_numbers=False) item_id = "001,002" asset_name = "mean" @@ -47,11 +48,11 @@ def test_padded_format_item_id_string(): def test_format_item_id_iterable(): - assert testItemPath._format_item_id(("66", "23"), "_") == "66_23" + assert testItemPath._format_item_id(("66", "23"), "_") == "066_023" def test_format_item_id_iterable_int(): - assert testItemPath._format_item_id((66, 23), "_") == "66_23" + assert testItemPath._format_item_id((66, 23), "_") == "066_023" def test_format_item_id_list_as_string(): @@ -59,4 +60,16 @@ def test_format_item_id_list_as_string(): def test_format_item_id_string(): - assert testItemPath._format_item_id("66", "_") == "66" + assert testItemPath._format_item_id("66", "_") == "066" + + +def test_non_padded_format_item_id_iterable(): + assert nonPaddedItemPath._format_item_id(("66", "23"), "_") == "66_23" + + +def test_non_padded_format_item_id_iterable_int(): + assert nonPaddedItemPath._format_item_id((66, 23), "_") == "66_23" + + +def test_non_padded_format_item_id_list_as_string(): + assert nonPaddedItemPath._format_item_id("001,002", "_") == "001_002"