Skip to content

Feat automation timezones catchup - #2396

Open
BelhsanHmida wants to merge 5 commits into
feat/2288-automations-for-forecastsfrom
feat/2392-automation-timezones-catchup
Open

Feat automation timezones catchup#2396
BelhsanHmida wants to merge 5 commits into
feat/2288-automations-for-forecastsfrom
feat/2392-automation-timezones-catchup

Conversation

@BelhsanHmida

@BelhsanHmida BelhsanHmida commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

  • Store an IANA timezone for each forecast automation.
  • Default new automations to FLEXMEASURES_TIMEZONE.
  • Validate timezone names and expose the timezone through the CLI, API and UI.
  • Persist a UTC scheduling cursor for each automation.
  • Interpret cron expressions in the automation's timezone.
  • Catch up missed forecast occurrences after runner downtime.
  • Coalesce multiple missed occurrences into the most recent useful forecast.
  • Handle daylight-saving transitions:
    • skipped local times run once after the spring-forward transition;
    • repeated local times run only once during the fall-back transition.
  • Claim each scheduled occurrence before queueing while preserving the existing at-most-once failure policy.
  • Add migration, documentation, changelog entries and regression coverage.
  • Added changelog item in documentation/changelog.rst

Look & Feel

The automation CLI accepts an explicit timezone:

flexmeasures add automation \
  --asset-id 1 \
  --generator-id 2 \
  --recurrence "0 9 * * *" \
  --timezone Europe/Amsterdam

The automation UI and API now expose the configured timezone and persistent scheduling cursor.

How to test

Run the affected automation test modules:

pytest \
  flexmeasures/cli/tests/test_automations.py \
  flexmeasures/data/schemas/tests/test_automations.py \
  flexmeasures/data/tests/test_automation_scheduling_fresh_db.py \
  flexmeasures/data/tests/test_automations_fresh_db.py \
  flexmeasures/api/v3_0/tests/test_automations_api.py \
  flexmeasures/ui/tests/test_asset_crud.py

The regression coverage includes:

  • Default and explicit IANA timezones.
  • Invalid timezone rejection.
  • Automations in different timezones.
  • Normal due and non-due occurrences.
  • Spring-forward and fall-back transitions.
  • One or multiple missed occurrences.
  • Persistent cursor behavior across runner restarts.
  • Inactive automations.
  • Duplicate prevention.
  • Preservation of the existing failure guard.

Further Improvements

Durable execution records, partial-failure states and retry lifecycle management remain outside this PR and are tracked separately in #2393.

Catch-up behavior is intentionally limited to forecast automations. Policies for schedule and report automations should be defined separately.

Related Items

Closes #2392.

Built on the forecast automation work from #2290.


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or another incompatible license.

Store each automation's IANA timezone and a durable UTC scheduling watermark. Canonicalize daylight-saving transitions, coalesce missed forecasts, and claim occurrences before queueing while retaining the existing at-most-once failure policy.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Exercise timezone defaults and validation, independent timezone evaluation, normal and missed occurrences, DST gaps and folds, durable cursor claims, inactive automations, API/UI exposure, and the existing Redis failure guard.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Document per-automation timezone snapshots, scheduling watermarks, downtime coalescing, daylight-saving behavior, reconfiguration boundaries, and the at-most-once retry limitation. Refresh the published automation API examples.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Announce the new CLI options, additive automation response fields, persistent scheduling progress, and DST-aware catch-up behavior for issue #2392.

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida self-assigned this Aug 5, 2026
@BelhsanHmida BelhsanHmida changed the title Feat/2392 automation timezones catchup Feat automation timezones catchup Aug 5, 2026
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
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.

1 participant