Skip to content

Feat: Expand FlexContextSchema with prior commitments #1754

Merged
Flix6x merged 63 commits intomainfrom
feat/flex-commitments
Nov 1, 2025
Merged

Feat: Expand FlexContextSchema with prior commitments #1754
Flix6x merged 63 commits intomainfrom
feat/flex-commitments

Conversation

@joshuaunity
Copy link
Copy Markdown
Contributor

@joshuaunity joshuaunity commented Oct 15, 2025

Description

This PR exposes the commitments by modeling the commitments field into the flex-context schema.

Look & Feel

None

How to test

To test this new addition, follow the steps below

  1. Open up an HTTP client like Postman or Insomnia
  2. Use the api url: http://localhost:5000/api/v3_0/assets/<asset_id>
  3. Use this request body as an example; -+.
  4. you can change the values to what suits you
{
	"flex_context": "{\"commitments\":[{\"baseline\":\"400 kW\",\"up-price\":\"304 EUR/MWh\",\"down-price\":\"530 EUR/MWh\"}]}"
}

Further Improvements

UI to add this new field. This would be handled in 1572

Related Items

This PR closes #1566


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

  • Update FlexContext Schema
  • Implement commitment deserialization in FlexContextSchema

@joshuaunity joshuaunity self-assigned this Oct 15, 2025
@joshuaunity joshuaunity added enhancement New feature or request Data labels Oct 15, 2025
@joshuaunity
Copy link
Copy Markdown
Contributor Author

joshuaunity commented Oct 15, 2025

I have implemented the commitments, but I don't know how to accept different units. By this, I mean that the object VariableQuantityField can only take one unit.

Right now, based on the baseline, I validate the prices on that unit. For example, if we have a baseline of MW, the prices should be /MW

From my current understanding, the VariableQuantityField would have to be modified to accept two units. What do you think, @Flix6x

CC @nhoening

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Oct 15, 2025

Documentation build overview

📚 flexmeasures | 🛠️ Build #30157995 | 📁 Comparing 0fa0f4c against latest (ec34740)


🔍 Preview build

Show files changed (6 files in total): 📝 6 modified | ➕ 0 added | ➖ 0 deleted
File Status
changelog.html 📝 modified
genindex.html 📝 modified
_autosummary/flexmeasures.data.models.planning.storage.html 📝 modified
_autosummary/flexmeasures.data.schemas.scheduling.html 📝 modified
_autosummary/flexmeasures.utils.validation_utils.html 📝 modified
api/v3_0.html 📝 modified

@Flix6x
Copy link
Copy Markdown
Contributor

Flix6x commented Oct 16, 2025

I'd say for now let's be explicit in the type of commitments that we allow: let's start with one type: MW baseline with EUR/MWh prices. We can extend it later, and maybe have separate schemas for each type of commitment, if that helps.

@joshuaunity joshuaunity requested a review from Flix6x October 27, 2025 11:18
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

2 small bugs

Flix6x added 23 commits October 31, 2025 17:25
Signed-off-by: F.N. Claessen <[email protected]>
… DBFlexContextSchema, so that's the schema we should test against

Signed-off-by: F.N. Claessen <[email protected]>
….g. a one-day commitment)

Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
Signed-off-by: F.N. Claessen <[email protected]>
…x-commitments

# Conflicts:
#	.github/workflows/lint-and-test.yml
Copy link
Copy Markdown
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Thanks again for adding those test cases. It helped me figure out what we actually want to support at this point. Right now that is:

  • A power baseline only (W, kW, MW, J/s, whatever, but not kWh).
  • Up- and down-prices per power unit or per energy unit (so e.g. EUR/kW and EUR/kWh are both fine).

@Flix6x Flix6x merged commit e7aaa76 into main Nov 1, 2025
8 checks passed
@Flix6x Flix6x deleted the feat/flex-commitments branch November 1, 2025 12:28
@Flix6x Flix6x mentioned this pull request Nov 4, 2025
5 tasks
@Flix6x Flix6x changed the title Feat: Expand FlexContextSchema with previous commitments Feat: Expand FlexContextSchema with prior commitments Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expand FlexContextSchema with previous commitments

2 participants