Skip to content

Commit c911a10

Browse files
committed
fix: issue with expression validation in genset and venting emitter
Use YamlExpressionType to validate expression when validating for run. Refs: equinor/ecalc-internal#1050
1 parent 1e34bbd commit c911a10

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/libecalc/presentation/yaml/yaml_types/components/yaml_generator_set.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
from libecalc.dto.types import ConsumerUserDefinedCategoryType
44
from libecalc.dto.utils.validators import ComponentNameStr
5-
from libecalc.expression.expression import ExpressionType
65
from libecalc.presentation.yaml.ltp_validation import validate_generator_set_power_from_shore
76
from libecalc.presentation.yaml.yaml_types import YamlBase
87
from libecalc.presentation.yaml.yaml_types.components.legacy.yaml_electricity_consumer import YamlElectricityConsumer
98
from libecalc.presentation.yaml.yaml_types.components.yaml_category_field import CategoryField
9+
from libecalc.presentation.yaml.yaml_types.components.yaml_expression_type import YamlExpressionType
1010
from libecalc.presentation.yaml.yaml_types.models.model_reference_validation import GeneratorSetModelReference
1111
from libecalc.presentation.yaml.yaml_types.yaml_temporal_model import YamlTemporalModel
1212

@@ -31,10 +31,10 @@ class YamlGeneratorSet(YamlBase):
3131
description="Specifies the correlation between the electric power delivered and the fuel burned by a "
3232
"generator set.\n\n$ECALC_DOCS_KEYWORDS_URL/ELECTRICITY2FUEL",
3333
)
34-
cable_loss: ExpressionType | None = Field(
34+
cable_loss: YamlExpressionType | None = Field(
3535
None, title="CABLE_LOSS", description="Cable loss from shore, fraction of from shore consumption"
3636
)
37-
max_usage_from_shore: ExpressionType | None = Field(
37+
max_usage_from_shore: YamlExpressionType | None = Field(
3838
None,
3939
title="MAX_USAGE_FROM_SHORE",
4040
description="The peak load/effect that is expected for one hour, per year (MW)",

src/libecalc/presentation/yaml/yaml_types/emitters/yaml_venting_emitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from libecalc.common.string.string_utils import generate_id
1313
from libecalc.dto.types import ConsumerUserDefinedCategoryType
1414
from libecalc.dto.utils.validators import ComponentNameStr
15-
from libecalc.expression.expression import ExpressionType
1615
from libecalc.presentation.yaml.yaml_types import YamlBase
1716
from libecalc.presentation.yaml.yaml_types.components.yaml_category_field import (
1817
CategoryField,
1918
)
19+
from libecalc.presentation.yaml.yaml_types.components.yaml_expression_type import YamlExpressionType
2020
from libecalc.presentation.yaml.yaml_types.yaml_stream_conditions import (
2121
YamlEmissionRate,
2222
YamlOilVolumeRate,
@@ -34,7 +34,7 @@ class YamlVentingVolumeEmission(YamlBase):
3434
title="NAME",
3535
description="Name of emission",
3636
)
37-
emission_factor: ExpressionType = Field(
37+
emission_factor: YamlExpressionType = Field(
3838
..., title="EMISSION_FACTOR", description="Loading/storage volume-emission factor"
3939
)
4040

0 commit comments

Comments
 (0)