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

Make zero padding tile ids and https hrefs default #68

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions dep_tools/namers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions dep_tools/stac_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("./")
Expand All @@ -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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably pull this function out and test it... it works now though!

)
else:
# E.g., s3://dep-public-prod/
Expand Down
3 changes: 2 additions & 1 deletion dep_tools/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ def __init__(
processor: Processor,
post_processor: Processor | None = XrPostProcessor(),
logger: Logger = getLogger(),
make_hrefs_https: bool = True,
alexgleith marked this conversation as resolved.
Show resolved Hide resolved
**kwargs,
):
"""A StacTask with typical parameters to write to s3 storage."""
writer = kwargs.pop("writer", AwsDsCogWriter(itempath))
stac_creator = kwargs.pop("stac_creator", StacCreator(itempath))
stac_writer = kwargs.pop("stac_writer", AwsStacWriter(itempath))
stac_writer = kwargs.pop("stac_writer", AwsStacWriter(itempath, make_hrefs_https=make_hrefs_https))
super().__init__(
id=id,
area=area,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_get_stac_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ 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")
item = get_stac_item(
itempath=itempath,
item_id="12,34",
data=test_xr,
remote=False,
remote=False
)

return item
Expand Down
Loading