Skip to content

Commit

Permalink
refactor: add ModelReference type
Browse files Browse the repository at this point in the history
  • Loading branch information
jsolaas committed Jun 28, 2024
1 parent bca7ffe commit 20be473
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from libecalc.presentation.yaml.yaml_types.yaml_temporal_model import YamlTemporalModel


class YamlInstallation(YamlBase): # TODO: conditional required, either fuelconsumers or gensets
class YamlInstallation(YamlBase):
model_config = ConfigDict(title="Installation")

name: ComponentNameStr = Field(
Expand Down Expand Up @@ -82,7 +82,7 @@ class YamlInstallation(YamlBase): # TODO: conditional required, either fuelcons
)

@model_validator(mode="after")
def check_fuel_consumers_or_venting_emitters_exist(self):
def check_some_consumer_or_emitter(self):
try:
if self.fuel_consumers or self.venting_emitters or self.generator_sets:
return self
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ModelReference = str
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing_extensions import Annotated

from libecalc.presentation.yaml.yaml_types import YamlBase
from libecalc.presentation.yaml.yaml_types.models.model_reference import ModelReference
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import (
YamlChartType,
YamlModelType,
Expand Down Expand Up @@ -53,7 +54,7 @@ class YamlUnits(YamlBase):


class YamlSingleSpeedChart(YamlBase):
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand All @@ -69,7 +70,7 @@ class YamlSingleSpeedChart(YamlBase):


class YamlVariableSpeedChart(YamlBase):
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand All @@ -87,7 +88,7 @@ class YamlVariableSpeedChart(YamlBase):


class YamlGenericFromInputChart(YamlBase):
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand All @@ -107,7 +108,7 @@ class YamlGenericFromInputChart(YamlBase):


class YamlGenericFromDesignPointChart(YamlBase):
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from pydantic import Field

from libecalc.presentation.yaml.yaml_types import YamlBase
from libecalc.presentation.yaml.yaml_types.models.model_reference import ModelReference
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlModelType


class YamlCompressorWithTurbine(YamlBase):
compressor_model: str = Field(..., description="Reference to a compressor model", title="COMPRESSOR_MODEL")
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing_extensions import Annotated

from libecalc.presentation.yaml.yaml_types import YamlBase
from libecalc.presentation.yaml.yaml_types.models.model_reference import ModelReference
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlModelType


Expand Down Expand Up @@ -32,7 +33,7 @@ class YamlPredefinedFluidModel(YamlBase):
eos_model: YamlEosModel = YamlEosModel.SRK
fluid_model_type: Literal[YamlFluidModelType.PREDEFINED] = YamlFluidModelType.PREDEFINED
gas_type: YamlPredefinedFluidType = None
name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand Down Expand Up @@ -68,8 +69,8 @@ class YamlCompositionFluidModel(YamlBase):
)
eos_model: Optional[YamlEosModel] = YamlEosModel.SRK
fluid_model_type: Literal[YamlFluidModelType.COMPOSITION] = YamlFluidModelType.COMPOSITION
name: Optional[str] = Field(
None,
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pydantic import ConfigDict, Field

from libecalc.presentation.yaml.yaml_types import YamlBase
from libecalc.presentation.yaml.yaml_types.models.model_reference import ModelReference
from libecalc.presentation.yaml.yaml_types.models.yaml_enums import YamlModelType


Expand All @@ -23,7 +24,7 @@ class YamlTurbine(YamlBase):
},
)

name: str = Field(
name: ModelReference = Field(
...,
description="Name of the model. See documentation for more information.",
title="NAME",
Expand Down

0 comments on commit 20be473

Please sign in to comment.