Skip to content

Comments

Fixed external load hours forecast strategy, the current implementati…#1554

Merged
spyrostz merged 3 commits intomasterfrom
fix_external_load_forecast_strategy
Nov 18, 2022
Merged

Fixed external load hours forecast strategy, the current implementati…#1554
spyrostz merged 3 commits intomasterfrom
fix_external_load_forecast_strategy

Conversation

@spyrostz
Copy link
Member

…on was failing due to the fact that the energy tracking of the load hours energy parameters was still partially active and was trying to decrease the operating hours of the strategy without being activated.

Reason for the proposed changes

This was revealed while implementing this PR gridsingularity/gsy-e-sdk#234, the CI failed for no apparent reason. After debugging the integration tests, pinpointed the root cause to the gsy-e failing due to this error:

gsy-e -l INFO run -t 60s -s 60m -d 24h --slot-length-realtime 2s --paused --enable-external-connection --setup strategy_tests.external_devices_settlement_market 

.... redacted ....

    listener(event, market_id=self.id, **kwargs)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/area/event_dispatcher.py", line 178, in broadcast_notification
    child.dispatcher.event_listener(event_type, **kwargs)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/area/event_dispatcher.py", line 230, in event_listener
    self.area.strategy.event_listener(event_type, **kwargs)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/strategy/__init__.py", line 621, in event_listener
    super().event_listener(event_type, **kwargs)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/events/__init__.py", line 58, in event_listener
    self._event_mapping(event_type)(**kwargs)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/strategy/external_strategies/__init__.py", line 570, in event_bid_traded
    super().event_bid_traded(market_id=market_id, bid_trade=bid_trade)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/strategy/load_hours.py", line 397, in event_bid_traded
    self._energy_params.decrease_hours_per_day(
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/strategy/energy_parameters/load.py", line 159, in decrease_hours_per_day
    self.hrs_per_day[current_day] -= self._operating_hours(energy_Wh / 1000.0)
  File "/media/Data/grid_singularity/gsy-e/src/gsy_e/models/strategy/energy_parameters/load.py", line 162, in _operating_hours
    return (((energy_kWh * 1000) / self.energy_per_slot_Wh)
TypeError: unsupported operand type(s) for /: 'float' and 'NoneType'

The forecast strategy was trying to decrease the hours_per_day parameter, which is not supported in the forecast strategy (essentially the forecast strategy uses forecasts to track the energy and not a constant value). The only reason why we still have this strategy exposed to the user is in order to maintain the ability of a user to use the template strategy, and switch to forecasts only when the SDK connects to it.

Proposed changes

This change overrides the decrease of the hours_per_day parameter for the forecast strategy with an empty implementation. That way the forecasts will be used instead of the hours per day parameter.
Note for the future, try to minimise the use of this strategy in favor of the LoadProfileForecastExternalStrategy (which is the only one used by GSy Maps ATM).

INTEGRATION_TESTS_BRANCH=master
GSY_FRAMEWORK_BRANCH=master

…on was failing due to the fact that the energy tracking of the load hours energy parameters was still partially active and was trying to decrease the operating hours of the strategy without being activated.
@spyrostz spyrostz requested a review from a team October 20, 2022 08:07
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Merging #1554 (f8de4ad) into master (c3fdbd9) will decrease coverage by 0.02%.
The diff coverage is 50.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1554      +/-   ##
==========================================
- Coverage   67.89%   67.86%   -0.03%     
==========================================
  Files         129      129              
  Lines       12610    12611       +1     
  Branches     1884     1884              
==========================================
- Hits         8562     8559       -3     
- Misses       3586     3590       +4     
  Partials      462      462              

Copy link
Member

@hannesdiedrich hannesdiedrich left a comment

Choose a reason for hiding this comment

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

Wow! Indeed tricky one. Thanks a lot!

Copy link
Member

@hannesdiedrich hannesdiedrich left a comment

Choose a reason for hiding this comment

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

LGTM

@spyrostz spyrostz merged commit e89ea7f into master Nov 18, 2022
@spyrostz spyrostz deleted the fix_external_load_forecast_strategy branch November 18, 2022 10:46
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.

2 participants