Repository navigation
Conversation
Products built from STAC items that only carry `datetime` (for example planetary_computer sentinel-2-l2a) have no `start_datetime` or `end_datetime`, so FilterDate kept all of them. FilterDate now uses `datetime` as start and end date when both are missing, and the FilterDate and FilterLatestIntersect sort helpers fall back to `datetime` when `start_datetime` is missing. Fixes CS-SI#2440 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
Please review the guidelines for contributing to this repository.
Description
Fixes #2440
SearchResult.filter_date()kept every Planetary Computer product.FilterDateineodag/plugins/crunch/filter_date.pyonly readsstart_datetimeandend_datetime, and skips a check when the value is missing. Planetary Computer'ssentinel-2-l2aitems only havedatetime, so these products have neither property and nothing gets filtered out.This used to work. Before #1730 the generic STAC mapping filled
startTimeFromAscendingNodefrom$.properties.datetime. Nowstart_datetimecomes from$.properties.start_datetime, which single-acquisition items don't have.Changes:
FilterDate.proceed(): when a product has neitherstart_datetimenorend_datetime, itsdatetimeis used as both. Products with either one set are filtered exactly as before.FilterDate.sort_product_by_start_date()andFilterLatestIntersect.sort_product_by_start_date(): usedatetimewhenstart_datetimeis missing, instead of sorting the product as 1970-01-01.FilterLatestIntersecthad the same problem, so with Planetary Computer results it didn't sort by date at all.Two notes on the example in the issue. With an end date of
2021-02-12T00:00:00, both products are dropped, not only the first, because the second was taken at 11:00 on the 12th. Andfilter_date()returns a newSearchResultwithout changingproducts, so the script needsfiltered = products.filter_date(...)to show the new count. TheFinished filtering products. N resulting productslog line shows the real number.How it was tested (Claude Code ran all of this):
tests/units/test_crunch.pycoverFilterDateand both sort helpers with products that only havedatetime, and check thatstart_datetimeandend_datetimestill take precedence. A new test intests/units/test_search_plugins.pyfeeds a minimal Planetary Computersentinel-2-l2aresponse throughStacSearchand then callsfilter_date. These 4 tests fail ondevelopand pass with the change.pytest -n 6 --ignore=tests/test_end_to_end.py --ignore=tests/test_benchmark.py): 1062 passed on Python 3.12, macOS..pre-commit-config.yaml, are clean on the changed files.mypy -p eodagreports the same 15 errors before and after, all in files this PR doesn't touch.filter_date('2021-02-10T00:00:00', '2021-02-12T00:00:00')kept 2 of 2 products. After: it keeps 0. With an end date of2021-02-13T00:00:00it keeps onlyS2B_MSIL2A_20210212T110059_R094_T30TXP_20210213T073201.Not run: tox itself (no docs build, no Python 3.10, 3.11, 3.13 or 3.14) and the end-to-end tests.
Further comments
The fix is in the crunchers rather than the provider config, so it covers any STAC provider whose items only carry
datetime. The other option is to fillstart_datetimeandend_datetimefromdatetimeinstac_provider.yml, but then every STAC product would show properties the provider never returned. I can switch to that if you prefer it.#2436 (ruff migration) also edits
filter_date.pyandtests/units/test_crunch.py, so whichever PR lands second will need a small rebase.I made this fix with help from Claude Code, which also wrote and ran the tests above.