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

fix(parsers): handle missing storage values for BE #6782

Merged
merged 3 commits into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions parsers/ENTSOE.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def parse_production(
# Loop over the grouped data and create production and storage mixes for each datetime.
for dt, values in grouped_data.items():
production, storage = _create_production_and_storage_mixes(
dt, values, expected_length, logger
zoneKey, dt, values, expected_length, logger
)
# If production and storage are None, the datapoint is considered invalid and is skipped
# in order to not crash the parser.
Expand Down Expand Up @@ -806,7 +806,11 @@ def _get_raw_production_events(soup: BeautifulSoup) -> list[dict[str, Any]]:


def _create_production_and_storage_mixes(
dt: datetime, values: list[dict[str, Any]], expected_length: int, logger: Logger
zoneKey: ZoneKey,
dt: datetime,
values: list[dict[str, Any]],
expected_length: int,
logger: Logger,
) -> tuple[ProductionMix, StorageMix] | tuple[None, None]:
"""
Creates a populated ProductionMix and StorageMix object from a list of production values and ensures that the expected length is met.
Expand All @@ -815,10 +819,15 @@ def _create_production_and_storage_mixes(
value_length = len(values)
# Checks that the number of values have the expected length and skips the datapoint if not.
if value_length < expected_length:
logger.warning(
f"Expected {expected_length} production values for {dt}, recived {value_length} instead. Discarding datapoint..."
)
return None, None
if zoneKey == "BE" and value_length == expected_length - 1:
logger.warning(
f"BE only has {value_length} production values for {dt}, but should have {expected_length}. BE doesn't report 0 values for storage so we will continue."
)
Comment on lines +822 to +825
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, this overall makes sense, but there is a risk that an important mode might be missing and thus this would falsely parse. But up to you to decide if that is enough of a problem/risk to do more work here :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed but the alternative would be to set up a validation that checks all expected modes per zone. Possibly something we can and should do but I think this is fine for now as it's just limited to BE and there is a secondary level of validation that is happening in the backend as well.

else:
logger.warning(
f"Expected {expected_length} production values for {dt}, received {value_length} instead. Discarding datapoint..."
)
return None, None
production = ProductionMix()
storage = StorageMix()
for production_mode in values:
Expand Down
Loading