Skip to content

constraints compatible with monthly daterange widget#364

Open
EddyCMWF wants to merge 10 commits into
mainfrom
feature/constraints-compatible-with-monthly-daterange-widget
Open

constraints compatible with monthly daterange widget#364
EddyCMWF wants to merge 10 commits into
mainfrom
feature/constraints-compatible-with-monthly-daterange-widget

Conversation

@EddyCMWF

@EddyCMWF EddyCMWF commented May 29, 2026

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_string helper that pads YYYY or YYYY-MM to a full YYYY-MM-DD date, padding start/end appropriately (with leap-year-aware month-end).
  • Updates gen_time_range_from_string to normalize both endpoints before constructing the DateTimeRange.
  • 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.

Comment thread cads_adaptors/constraints.py
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