Feat: make flex-config more explicit about production vs consumption (#2041)#2156
Draft
Copilot wants to merge 6 commits into
Draft
Feat: make flex-config more explicit about production vs consumption (#2041)#2156Copilot wants to merge 6 commits into
Copilot wants to merge 6 commits into
Conversation
…2041) CHANGE 1 - flex-context: inflexible-device-sensors → inflexible-loads / inflexible-generators - Add inflexible-loads (consumption-positive) and inflexible-generators (production-positive) fields to FlexContextSchema - Deprecate inflexible-device-sensors with warnings.warn on load - Update DBFlexContextSchema validation to validate all three lists - Add entries for new fields to UI_FLEX_CONTEXT_SCHEMA - Add consumption_is_positive parameter to get_power_values() in utils.py - Update MetaStorageScheduler._prepare() to build combined all_inflexible list with explicit sign conventions per field type CHANGE 2 - flex-model: sensor → consumption / production - Expand MultiSensorFlexModelSchema with consumption, production, is_consumption_sensor fields - unwrap_envelope maps consumption/production → sensor and sets is_consumption_sensor - Preserve is_consumption_sensor through StorageScheduler.deserialize_flex_config() - Include is_consumption_sensor in result dicts from both StorageScheduler.schedule() and StorageFallbackScheduler.compute() - Extract is_consumption_sensor in create_sequential_scheduling_jobs and pass to create_scheduling_job as scheduler_kwargs - Add is_consumption_sensor param to make_schedule(); use it in sign logic with fallback to sensor attribute CHANGE 3 - database migration - Add Alembic migration 9ed0e39b0447 that upgrades existing flex_context and flex_model JSON columns on generic_asset: - inflexible-device-sensors → inflexible-loads or inflexible-generators based on each sensor's consumption_is_positive attribute (defaults to False → generators) - flex_model[].sensor → consumption or production based on same attribute - downgrade reverses both transforms Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…sumption PR - Clarify deprecation warning: note production-positive is the FlexMeasures default - Extract _build_is_consumption_sensor_map() helper on MetaStorageScheduler to avoid duplication between StorageFallbackScheduler.compute() and StorageScheduler.schedule() - Rename confusing variable result_consumption_is_positive → consumption_is_positive in make_schedule() sign logic - Add mutual-exclusion validation in unwrap_envelope: raise ValidationError when both 'consumption' and 'production' are specified in the same flex-model entry Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…le in production) DeprecationWarning is silenced by default in Python for non-__main__ code, meaning it would be invisible to API users in production Flask deployments. Change to UserWarning which is always visible, following the existing pattern in api/dev/sensors.py which uses FutureWarning for the same reason. Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
- warn on inflexible-device-sensors presence (not just non-empty), since the field itself is deprecated regardless of its value - improve docstring for warn_deprecated_sensor_field to clarify that is_consumption_sensor is an internal marker set by @pre_load - improve unwrap_envelope docstring to mention is_consumption_sensor Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…ction fields Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
…n/consumption flex-model keys Co-authored-by: Flix6x <30658763+Flix6x@users.noreply.github.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
inflexible-loadsandinflexible-generatorsto FlexContextSchema (deprecateinflexible-device-sensors)consumptionandproductionto MultiSensorFlexModelSchema (deprecatesensorkey)