constraints compatible with monthly daterange widget#364
Open
EddyCMWF wants to merge 10 commits into
Open
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…:ecmwf-projects/cads-adaptors into feature/make-arco-area-weighting-general
Contributor
There was a problem hiding this comment.
Pull request overview
Normalizes partial date strings (year-only, year-month) before applying constraints so the monthly date-range widget works with the constraints algorithm.
Changes:
- Adds
_normalize_date_stringhelper that padsYYYYorYYYY-MMto a fullYYYY-MM-DDdate, padding start/end appropriately (with leap-year-aware month-end). - Updates
gen_time_range_from_stringto normalize both endpoints before constructing theDateTimeRange. - Adds parametrized tests for the year/year-month input cases plus unit tests for the new helper and
gen_time_range_from_string.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cads_adaptors/constraints.py | Adds _normalize_date_string and applies it inside gen_time_range_from_string. |
| tests/test_10_constraints.py | Parametrizes the existing date-range test with new year/year-month cases and adds unit tests for the new helpers and legacy_intersect_constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The new monthly resolution date-range widget is not compatible with the constraints alogorithm, see example entry here:
https://cds-dev-cci2.copernicus-climate.eu/datasets/demo-constraints-for-monthly-widget?tab=download
This PR normalises dates prior to applying constraints
Here is the link to the mini-cci version:
https://cads-mini-cci1.copernicus-climate.eu/datasets/demo-constraints-for-monthly-widget?tab=download
The constraints are behaving, but there are other issue with the stack. These need to be fixed so it can be fully tested before merging
For reference, the ticket where the monthly resolution to the widget was introduced: https://jira.ecmwf.int/browse/COPDS-3017