-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathreference_service.py
More file actions
86 lines (68 loc) · 3.17 KB
/
Copy pathreference_service.py
File metadata and controls
86 lines (68 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import abc
from collections.abc import Iterable
from typing import Protocol
from libecalc.common.errors.ecalc_validation_error import EcalcValidationException
from libecalc.presentation.yaml.mappers.yaml_path import YamlPath
from libecalc.presentation.yaml.yaml_types.facility_model.yaml_facility_model import (
YamlCompressorTabularModel,
YamlGeneratorSetModel,
YamlPumpChartSingleSpeed,
YamlPumpChartVariableSpeed,
YamlTabularModel,
)
from libecalc.presentation.yaml.yaml_types.fuel_type.yaml_fuel_type import YamlFuelType
from libecalc.presentation.yaml.yaml_types.models import (
YamlCompressorChart,
YamlCompressorWithTurbine,
YamlFluidModel,
YamlTurbine,
)
from libecalc.presentation.yaml.yaml_types.models.yaml_compressor_trains import (
YamlSimplifiedVariableSpeedCompressorTrain,
YamlSingleSpeedCompressorTrain,
YamlVariableSpeedCompressorTrain,
YamlVariableSpeedCompressorTrainMultipleStreamsAndPressures,
)
from libecalc.presentation.yaml.yaml_types.process.yaml_process_pipeline import YamlProcessPipeline
from libecalc.presentation.yaml.yaml_types.process.yaml_process_units import YamlProcessUnitDefinition
from libecalc.presentation.yaml.yaml_types.streams.yaml_inlet_stream import YamlInletStream
class InvalidReferenceException(EcalcValidationException):
def __init__(self, reference_type: str, reference: str, available_references: Iterable[str] = None):
if available_references is not None:
available_message = f"Available references: {', '.join(available_references)}"
else:
available_message = ""
super().__init__(message=f"Invalid {reference_type} reference '{reference}'. {available_message}")
YamlCompressorModel = (
YamlSimplifiedVariableSpeedCompressorTrain
| YamlVariableSpeedCompressorTrain
| YamlSingleSpeedCompressorTrain
| YamlCompressorWithTurbine
| YamlVariableSpeedCompressorTrainMultipleStreamsAndPressures
| YamlCompressorTabularModel
)
class ReferenceService(Protocol):
@abc.abstractmethod
def get_yaml_path(self, reference: str) -> YamlPath: ...
@abc.abstractmethod
def get_fluid(self, reference: str) -> YamlFluidModel: ...
@abc.abstractmethod
def get_turbine(self, reference: str) -> YamlTurbine: ...
@abc.abstractmethod
def get_compressor_chart(self, reference: str) -> YamlCompressorChart: ...
@abc.abstractmethod
def get_fuel_reference(self, reference: str) -> YamlFuelType: ...
@abc.abstractmethod
def get_generator_set_model(self, reference: str) -> YamlGeneratorSetModel: ...
@abc.abstractmethod
def get_compressor_model(self, reference: str) -> YamlCompressorModel: ...
@abc.abstractmethod
def get_pump_model(self, reference: str) -> YamlPumpChartSingleSpeed | YamlPumpChartVariableSpeed: ...
@abc.abstractmethod
def get_tabulated_model(self, reference: str) -> YamlTabularModel: ...
@abc.abstractmethod
def get_process_pipeline(self, reference: str) -> YamlProcessPipeline: ...
@abc.abstractmethod
def get_process_unit(self, reference: str) -> YamlProcessUnitDefinition: ...
@abc.abstractmethod
def get_stream(self, reference: str) -> YamlInletStream: ...