Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flex context sensors are not handled correctly in scheduler yet when used as fallback attributes #1370

Open
nhoening opened this issue Mar 17, 2025 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@nhoening
Copy link
Contributor

To replicate: set "Site Consumption Capacity" field of an asset to a sensor, and attempt to create a schedule (e.g. using the toy tutorial)

In the line below, asset.get_attribute() was extended to return also flex context fields:
https://github.com/FlexMeasures/flexmeasures/pull/1293/files#diff-9a3e4dca97ba0f73dab16ea74e2711fdbf6cbb3c6a0fe71784ec52f26df2f7a0R331

The scheduler will try to read data for attributes with get_continuous_series_sensor_or_quantity(), also using fallback attributes, which in my case (the site-consumption-capacity field is set in the flex context, as sensor) turns out to be something like {"sensor": 26}, and fail.

This is what I see when testing scheduling (from CLI): HANDLING RQ SCHEDULING WORKER EXCEPTION: <class 'TypeError'>:Invalid magnitude for Quantity: {'sensor': 26}

We could support that these utils understand the sensor structure, or we rethink the idea that flex context fields are available as asset attributes. I don't know why it was needed.
We could give asset.get_attribute() a parameter (values_only) to avoid this kind of lookup.
But in general, I believe users probably believe they receive some value with an attribute lookup, not a sensor spec.

Opinions?

@nhoening nhoening added the bug Something isn't working label Mar 17, 2025
@nhoening nhoening changed the title Flex context sensors are not handled correctly in scheduler yet Flex context sensors are not handled correctly in scheduler yet when used as fallback attributes Mar 17, 2025
@nhoening nhoening added this to the 0.25.0 milestone Mar 18, 2025
@nhoening
Copy link
Contributor Author

Tagging @Flix6x and @victorgarcia98 to help me sort out what the right follow-up would be. I hope I added viable options at the end.

@Flix6x
Copy link
Contributor

Flix6x commented Mar 18, 2025

In my opinion:

  • The fallback fetching logic should be adapted to support sensor references.
  • The fallback logic should be adapted to look for the relevant field in the db flex-context only (which is where our db migration moved them to).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants