Skip to content

Make scheduler clearly fail when sensors are missing #2250

Description

@nhoening

If sensors are deleted (via SQL), the scheduler should report this in a clean way.

The PR for this issue should improve what happens if a sensor that is referenced in the flex-model or flex-context does not exist.

I tested two situations, with differing outcomes:

  1. sensor in flex-context is missing

With my --flex-context parameter in the CLI being {"consumption-price": {"sensor": 222222}}, I got:

marshmallow.exceptions.ValidationError: {'consumption-price': ['No sensor found with ID 222222.']}

That is helpful.

  1. sensor in flex-model is missing

With my --flex-model parameter in the CLI being [{"sensor": 44207999, "soc-at-start": "4 kWh", "roundtrip-efficiency": 0.9, "soc-min": "2 kWh"}], I got:

  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/services/scheduling.py", line 252, in create_scheduling_job
    scheduler.collect_flex_config()
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/models/planning/__init__.py", line 211, in collect_flex_config
    asset_id = sensor.asset_id
               ^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'asset_id'

That is not helpful enough.

Bonus: check if the forecaster fails clearly in this situation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions