@@ -282,7 +282,7 @@ def generator_config_to_json(self, generator_config: Optional[GeneratorConfig])
282282 }
283283 }
284284
285- def work_package_config_to_json (self , work_package : Optional [ WorkPackageConfig ] ) -> Optional [ dict ] :
285+ def work_package_config_to_json (self , work_package : WorkPackageConfig ) -> dict :
286286 return {
287287 "feederConfigs" : {
288288 "configs" : [
@@ -379,44 +379,54 @@ def work_package_config_to_json(self, work_package: Optional[WorkPackageConfig])
379379 }
380380 }
381381 },
382- "intervention" : work_package .intervention and {
383- "baseWorkPackageId" : work_package .intervention .base_work_package_id ,
384- "yearRange" : {
385- "maxYear" : work_package .intervention .year_range .max_year ,
386- "minYear" : work_package .intervention .year_range .min_year
387- },
388- "allocationLimitPerYear" : work_package .intervention .allocation_limit_per_year ,
389- "interventionType" : work_package .intervention .intervention_type .name ,
390- "candidateGeneration" : work_package .intervention .candidate_generation and {
391- "type" : work_package .intervention .candidate_generation .type .name ,
392- "interventionCriteriaName" : work_package .intervention .candidate_generation .intervention_criteria_name ,
393- "voltageDeltaAvgThreshold" : work_package .intervention .candidate_generation .voltage_delta_avg_threshold ,
394- "voltageUnderLimitHoursThreshold" : work_package .intervention .candidate_generation .voltage_under_limit_hours_threshold ,
395- "voltageOverLimitHoursThreshold" : work_package .intervention .candidate_generation .voltage_over_limit_hours_threshold ,
396- "tapWeightingFactorLowerThreshold" : work_package .intervention .candidate_generation .tap_weighting_factor_lower_threshold ,
397- "tapWeightingFactorUpperThreshold" : work_package .intervention .candidate_generation .tap_weighting_factor_upper_threshold ,
398- },
399- "allocationCriteria" : work_package .intervention .allocation_criteria ,
400- "specificAllocationInstance" : work_package .intervention .specific_allocation_instance ,
401- "phaseRebalanceProportions" : work_package .intervention .phase_rebalance_proportions and {
402- "a" : work_package .intervention .phase_rebalance_proportions .a ,
403- "b" : work_package .intervention .phase_rebalance_proportions .b ,
404- "c" : work_package .intervention .phase_rebalance_proportions .c
405- },
406- "dvms" : work_package .intervention .dvms and {
407- "lowerLimit" : work_package .intervention .dvms .lower_limit ,
408- "upperLimit" : work_package .intervention .dvms .upper_limit ,
409- "lowerPercentile" : work_package .intervention .dvms .lower_percentile ,
410- "upperPercentile" : work_package .intervention .dvms .upper_percentile ,
411- "maxIterations" : work_package .intervention .dvms .max_iterations ,
412- "regulatorConfig" : {
413- "puTarget" : work_package .intervention .dvms .regulator_config .pu_target ,
414- "puDeadbandPercent" : work_package .intervention .dvms .regulator_config .pu_deadband_percent ,
415- "maxTapChangePerStep" : work_package .intervention .dvms .regulator_config .max_tap_change_per_step ,
416- "allowPushToLimit" : work_package .intervention .dvms .regulator_config .allow_push_to_limit
382+ "intervention" : work_package .intervention and (
383+ {
384+ "baseWorkPackageId" : work_package .intervention .base_work_package_id ,
385+ "interventionType" : work_package .intervention .intervention_type .name ,
386+ "candidateGeneration" : work_package .intervention .candidate_generation and {
387+ "type" : work_package .intervention .candidate_generation .type .name ,
388+ "interventionCriteriaName" : work_package .intervention .candidate_generation .intervention_criteria_name ,
389+ "voltageDeltaAvgThreshold" : work_package .intervention .candidate_generation .voltage_delta_avg_threshold ,
390+ "voltageUnderLimitHoursThreshold" : work_package .intervention .candidate_generation .voltage_under_limit_hours_threshold ,
391+ "voltageOverLimitHoursThreshold" : work_package .intervention .candidate_generation .voltage_over_limit_hours_threshold ,
392+ "tapWeightingFactorLowerThreshold" : work_package .intervention .candidate_generation .tap_weighting_factor_lower_threshold ,
393+ "tapWeightingFactorUpperThreshold" : work_package .intervention .candidate_generation .tap_weighting_factor_upper_threshold ,
394+ },
395+ "allocationCriteria" : work_package .intervention .allocation_criteria ,
396+ "specificAllocationInstance" : work_package .intervention .specific_allocation_instance ,
397+ "phaseRebalanceProportions" : work_package .intervention .phase_rebalance_proportions and {
398+ "a" : work_package .intervention .phase_rebalance_proportions .a ,
399+ "b" : work_package .intervention .phase_rebalance_proportions .b ,
400+ "c" : work_package .intervention .phase_rebalance_proportions .c
401+ },
402+ "dvms" : work_package .intervention .dvms and {
403+ "lowerLimit" : work_package .intervention .dvms .lower_limit ,
404+ "upperLimit" : work_package .intervention .dvms .upper_limit ,
405+ "lowerPercentile" : work_package .intervention .dvms .lower_percentile ,
406+ "upperPercentile" : work_package .intervention .dvms .upper_percentile ,
407+ "maxIterations" : work_package .intervention .dvms .max_iterations ,
408+ "regulatorConfig" : {
409+ "puTarget" : work_package .intervention .dvms .regulator_config .pu_target ,
410+ "puDeadbandPercent" : work_package .intervention .dvms .regulator_config .pu_deadband_percent ,
411+ "maxTapChangePerStep" : work_package .intervention .dvms .regulator_config .max_tap_change_per_step ,
412+ "allowPushToLimit" : work_package .intervention .dvms .regulator_config .allow_push_to_limit
413+ }
417414 }
418- }
419- }
415+ } |
416+ (
417+ { "allocationLimitPerYear" : work_package .intervention .allocation_limit_per_year }
418+ if work_package .intervention .allocation_limit_per_year is not None else {}
419+ ) |
420+ (
421+ {
422+ "yearRange" : {
423+ "maxYear" : work_package .intervention .year_range .max_year ,
424+ "minYear" : work_package .intervention .year_range .min_year
425+ }
426+ }
427+ if work_package .intervention .year_range is not None else {}
428+ )
429+ )
420430 }
421431
422432 def run_hosting_capacity_work_package (self , work_package : WorkPackageConfig ):
0 commit comments