Skip to content

feat: V2 collection tests#1668

Merged
jsignell merged 5 commits intov2from
v2-collection-tests
Apr 20, 2026
Merged

feat: V2 collection tests#1668
jsignell merged 5 commits intov2from
v2-collection-tests

Conversation

@jsignell
Copy link
Copy Markdown
Member

@jsignell jsignell commented Apr 1, 2026

Related Issue(s):

Description:

The big question that came up in this work was: do we want datetimes to be dt.datetime or iso strings? So far v2 has the DateTime protocol defined in common_metadata.py has datetimes stored as strings in extra_fields but returns them as dt.datetime when accessed as a property. This is what is used by item.properties. But SpatialExtent just uses strings

collection.extent.temporal.interval: list[list[str]] 

@jsignell jsignell mentioned this pull request Apr 1, 2026
23 tasks
@gadomski
Copy link
Copy Markdown
Member

gadomski commented Apr 1, 2026

do we want datetimes to be dt.datetime or iso strings?

My gut tells me to store and retrieve as datetimes, and only go to/from strings on (de)serialization. That implies that it's awkward to intentionally store as a string in extra_fields.

Very open to different models, though, so curious what ya'lls instincts are.

collection_as_dict = collection.to_dict()
for key in (
"title",
"stac_extensions",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's actually better to include an empty list for stac_extensions. That seems like a very common pattern in stac.

@jsignell jsignell force-pushed the v2-collection-tests branch from ab24538 to 2f64818 Compare April 7, 2026 20:22
@jsignell
Copy link
Copy Markdown
Member Author

jsignell commented Apr 7, 2026

do we want datetimes to be dt.datetime or iso strings?

My gut tells me to store and retrieve as datetimes, and only go to/from strings on (de)serialization. That implies that it's awkward to intentionally store as a string in extra_fields.

Very open to different models, though, so curious what ya'lls instincts are.

I think your instincts are good. I updated this PR make all the regular datetime fields convert to dt.datetime on initialization and when setting. I didn't do this for collection.extent.temporal.interval yet because it looked like there was some intentional logic there. Also because of rounding you can't guarantee that roundtripping from str -> dt.datetime -> str will give exactly the same string. Probably not super important, but if we are trying to not mutate on read...

Copy link
Copy Markdown
Member

@ircwaves ircwaves left a comment

Choose a reason for hiding this comment

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

This looks good. A question and suggestion.

Comment thread src/pystac/container.py Outdated
Comment thread tests/v1/test_common_metadata.py
Co-authored-by: Ian Cooke <ircwaves@users.noreply.github.com>
@jsignell
Copy link
Copy Markdown
Member Author

@gadomski do you want to take a look at this one? I think it would be best to merge it before working on item_collection and catalog tests.

@gadomski gadomski self-requested a review April 14, 2026 17:53
Copy link
Copy Markdown
Member

@gadomski gadomski left a comment

Choose a reason for hiding this comment

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

LGTM! Sorry about the slowness on review

@jsignell jsignell merged commit 098bb9e into v2 Apr 20, 2026
14 checks passed
@jsignell jsignell deleted the v2-collection-tests branch April 20, 2026 14:02
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

Successfully merging this pull request may close these issues.

3 participants