Skip to content

Commit

Permalink
fix: pass enum value to literal string type
Browse files Browse the repository at this point in the history
Instead of relying on pydantic conversion or str behavior of enum we
pass the string value directly.
  • Loading branch information
jsolaas committed Jul 5, 2024
1 parent 60cf1c6 commit 212b01f
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/libecalc/presentation/json_result/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _evaluate_installations(
name=installation_node_info.name,
parent=asset.id,
component_level=installation_node_info.component_level,
componentType=installation_node_info.component_type,
componentType=installation_node_info.component_type.value,
timesteps=variables_map.time_vector,
is_valid=TimeSeriesBoolean(
timesteps=variables_map.time_vector,
Expand Down Expand Up @@ -861,7 +861,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
CompressorModelResult(
parent=consumer_id,
name=model.name,
componentType=model.component_type,
componentType=model.component_type.value,
component_level=ComponentLevel.MODEL,
energy_usage=TimeSeriesRate.from_timeseries_stream_day_rate(
model.energy_usage, regularity=regularity
Expand Down Expand Up @@ -902,7 +902,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
PumpModelResult(
parent=consumer_id,
name=model.name,
componentType=model.component_type,
componentType=model.component_type.value,
component_level=ComponentLevel.MODEL,
energy_usage=TimeSeriesRate.from_timeseries_stream_day_rate(
model.energy_usage, regularity=regularity
Expand Down Expand Up @@ -966,7 +966,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
{
**model.model_dump(),
"parent": consumer_id,
"componentType": model.component_type,
"componentType": model.component_type.value,
"component_level": ComponentLevel.MODEL,
"energy_usage_cumulative": TimeSeriesRate.from_timeseries_stream_day_rate(
model.energy_usage, regularity=regularity
Expand Down Expand Up @@ -999,7 +999,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1081,7 +1081,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1123,7 +1123,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1163,7 +1163,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1203,10 +1203,10 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
name=consumer_node_info.name,
parent=graph_result.graph.get_predecessor(consumer_id),
component_level=consumer_node_info.component_level,
componentType=consumer_node_info.component_type,
componentType=consumer_node_info.component_type.value,
consumer_type=graph_result.graph.get_node_info(
graph_result.graph.get_successors(consumer_id)[0]
).component_type,
).component_type.value,
emissions=_parse_emissions(graph_result.emission_results[consumer_id], regularity)
if consumer_id in graph_result.emission_results
else {},
Expand Down Expand Up @@ -1248,7 +1248,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
"name": consumer_node_info.name,
"parent": graph_result.graph.get_predecessor(consumer_id),
"component_level": consumer_node_info.component_level,
"componentType": consumer_node_info.component_type,
"componentType": consumer_node_info.component_type.value,
"emissions": emissions,
"energy_usage_cumulative": TimeSeriesRate.from_timeseries_stream_day_rate(
consumer_result.component_result.energy_usage, regularity=regularity
Expand Down Expand Up @@ -1310,7 +1310,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
libecalc.presentation.json_result.result.VentingEmitterResult(
id=venting_emitter.id,
name=venting_emitter.name,
componentType=venting_emitter.component_type,
componentType=venting_emitter.component_type.value,
component_level=ComponentLevel.CONSUMER,
parent=installation.id,
emissions=_parse_emissions(
Expand Down Expand Up @@ -1411,7 +1411,7 @@ def get_asset_result(graph_result: GraphResult) -> libecalc.presentation.json_re
id=asset.id,
name=asset_node_info.name,
component_level=asset_node_info.component_level,
componentType=asset_node_info.component_type,
componentType=asset_node_info.component_type.value,
timesteps=graph_result.variables_map.time_vector,
is_valid=TimeSeriesBoolean(
timesteps=graph_result.variables_map.time_vector,
Expand Down

0 comments on commit 212b01f

Please sign in to comment.