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

PB-847: Add item field 'expires' #450

Merged
merged 3 commits into from
Aug 15, 2024
Merged

Conversation

benschs
Copy link
Contributor

@benschs benschs commented Aug 14, 2024

Add optional field 'expires' to item property.
New field should conform to stac-extensions/timestamps (https://github.com/stac-extensions/timestamps).
Refactor item properties validation function.

Add optional field 'expires' to item property.Field should conform to
stac-extensions/timestamps (https://github.com/stac-extensions/timestamps).
Adapt test cases and spec.
@benschs benschs requested review from schtibe and boecklic August 14, 2024 14:02
@@ -374,32 +386,23 @@ def validate_item_properties_datetimes_dependencies(
Raises:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think now the documentation is incomplete here

@@ -364,8 +364,20 @@ def validate_geometry(geometry):
return geometry


def validate_item_properties_datetimes_dependencies(
properties_datetime, properties_start_datetime, properties_end_datetime
def validate_datetime_format(date_string):
Copy link
Contributor

@schtibe schtibe Aug 15, 2024

Choose a reason for hiding this comment

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

Nice refactoring!

properties_datetime, properties_start_datetime, properties_end_datetime
def validate_datetime_format(date_string):
try:
if not isinstance(date_string, datetime) and date_string is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just some nitpick: wouldn't it make sense to first check for None and then for the instance?



def validate_item_properties_datetimes(
properties_datetime, properties_start_datetime, properties_end_datetime, properties_expires
Copy link
Contributor

@schtibe schtibe Aug 15, 2024

Choose a reason for hiding this comment

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

Just some higher-level thinking here, (it doesn't have to do with your change directly):
I think it might be better if the callers of this function made sure that what they pass in is either datetime or None (but not string). Instead, the above function, as a side-effect, parses the dates in case they are strings, even though this here is about validation... (I guess that's a result of not having strict typing 😁)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I played around with different options, but nothing that is really nicer.

@@ -1072,6 +1072,8 @@ components:
$ref: "#/components/schemas/datetime"
end_datetime:
$ref: "#/components/schemas/datetime"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it meant to be on both versions of our API (v0.9 and v1)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK the v0.9 spec should not change anymore. The new feature should only be in the v1 spec.
To keep things easier (and as it is not a breaking change), I decided to add the field to response of both versions. We could also check for v0.9 and remove the 'expires' field from the response again.

Split validation function. Remove wrapper function
validate_item_properties_datetimes_dependencies.
@benschs benschs force-pushed the feat-PB-847-item-expires-field branch from b9e949b to bc3a96d Compare August 15, 2024 11:29
Copy link
Contributor

@boecklic boecklic left a comment

Choose a reason for hiding this comment

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

Nice!
If we want to be perfect, the standard suggest to add extensions to the corresponding stac_extensions list, e.g. for items: https://github.com/radiantearth/stac-spec/blob/master/item-spec/item-spec.md#stac_extensions
We haven't done this so far though

properties_end_datetime,
)
if properties_expires is not None:
if properties_expires < properties_end_datetime:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should even enforce a minimal lifetime of an object, e.g. 24/72/... hours?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline, we are not sure about the different use cases, so for now we keep it simple and don't add more restrictions.

@benschs benschs merged commit 20ffd6b into develop Aug 15, 2024
3 checks passed
@benschs benschs deleted the feat-PB-847-item-expires-field branch August 15, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants