Skip to content

Conversation

@BelhsanHmida
Copy link
Contributor

Description

Currently, FLEXMEASURES_JOB_TTL and FLEXMEASURES_PLANNING_TTL have several issues:

  1. Type conflicts with defaults

    • Existing docs and code use timedelta(days=1) / timedelta(days=7) as defaults.
    • If a user sets an ISO-8601 string (e.g., "P2D") or an integer in the config, passing a timedelta as the .get() default causes a runtime error when calling .total_seconds().
  2. Unclear “persist forever” behavior

    • Previously, None and negative TTLs were not consistently handled.
    • Defaults could accidentally result in “persist forever” instead of TTLs defaults set in flexmeasures docs.
  3. Limited input formats

    • Only timedelta was accepted.
    • Intuitive formats like 2 (days) or ISO-8601 strings were unsupported.
  • Fix FLEXMEASURES_JOB_TTL and FLEXMEASURES_PLANNING_TTL configuration handling.
  • Introduced normalize_ttl(value, default_days) helper to convert config values to timedelta internally.
  • Supported input formats:
    • ISO-8601 duration strings (recommended), e.g., "P1D" / "P7D"
    • Integers → number of days
    • Integer -1 → persist forever
    • None → use sensible default (1 day for job TTL, 7 days for planning TTL)
  • Updated Job.create calls to use normalized TTLs safely.
  • Updated configuration documentation to add supported types while preserving original defaults.
  • Added changelog entry in documentation/changelog.rst.

How to test

  • Set FLEXMEASURES_JOB_TTL and FLEXMEASURES_PLANNING_TTL in flexmeasures.cfg with:
    • ISO-8601 strings, e.g., "P2D" or "PT12H"
    • Integers, e.g., 2
    • -1 for persist forever
  • Run scheduling and forecasting jobs, check that ttl and result_ttl are correctly applied.
  • Verify defaults are applied correctly when no value is set in config.

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 other license that is incompatible with FlexMeasures

…onsistently

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ling

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…ing to match flexmeasures documentation

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
…_PLANNING_TTL

configuration in documentation

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@BelhsanHmida BelhsanHmida changed the base branch from main to fix/keep-around-finished-forecasting-jobs-longer December 22, 2025 13:33
…t days in TTL configurations

Signed-off-by: Mohamed Belhsan Hmida <mohamedbelhsanhmida@gmail.com>
@read-the-docs-community
Copy link

Documentation build overview

📚 flexmeasures | 🛠️ Build #30782189 | 📁 Comparing e720f7b against latest (75e05d4)


🔍 Preview build

Show files changed (5 files in total): 📝 5 modified | ➕ 0 added | ➖ 0 deleted
File Status
changelog.html 📝 modified
configuration.html 📝 modified
genindex.html 📝 modified
_autosummary/flexmeasures.utils.time_utils.html 📝 modified
api/v3_0.html 📝 modified

@Flix6x
Copy link
Contributor

Flix6x commented Dec 28, 2025

I'm not sure issue 2 is correct. Did you see the default TTLs were coming from utils.config_defaults? Or what was the actual case that was inconsistently handled?

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