Skip to content

Commit 9db3ca7

Browse files
authored
fix(parser): do not raise exception when conventional is missing for one day, only logs it (#8162)
1 parent 055c15d commit 9db3ca7

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

parsers/IN.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ def fetch_production(
464464
days_lookback_to_try = list(range(1, 8))
465465
for days_lookback in days_lookback_to_try:
466466
_target_datetime = target_datetime - timedelta(days=days_lookback)
467+
468+
renewable_production = {}
467469
try:
468470
renewable_production = fetch_cea_production(
469471
zone_key=zone_key,
@@ -474,26 +476,27 @@ def fetch_production(
474476
logger.warning(
475477
f"{zone_key}: renewable production not available for {_target_datetime} - will compute production with conventional production only"
476478
)
477-
renewable_production = {}
479+
480+
conventional_production = None
478481
try:
479482
conventional_production = fetch_npp_production(
480483
zone_key=zone_key,
481484
session=session,
482485
target_datetime=_target_datetime,
483486
)
484-
except ParserException as e:
487+
except ParserException:
485488
logger.warning(
486489
f"{zone_key}: conventional production not available for {_target_datetime} - do not return any production data"
487490
)
488-
raise e
489-
490-
production = {**conventional_production, **renewable_production}
491-
all_data_points += daily_to_hourly_production_data(
492-
target_datetime=_target_datetime,
493-
production=production,
494-
zone_key=zone_key,
495-
logger=logger,
496-
)
491+
492+
if conventional_production is not None:
493+
production = {**conventional_production, **renewable_production}
494+
all_data_points += daily_to_hourly_production_data(
495+
target_datetime=_target_datetime,
496+
production=production,
497+
zone_key=zone_key,
498+
logger=logger,
499+
)
497500
return all_data_points
498501

499502

0 commit comments

Comments
 (0)