-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: use time series collection yaml classes #328
Conversation
@@ -269,8 +273,15 @@ def facility_inputs(self): | |||
return self._internal_datamodel.get(EcalcYamlKeywords.facility_inputs, []) | |||
|
|||
@property | |||
def time_series(self): | |||
return self._internal_datamodel.get(EcalcYamlKeywords.time_series, []) | |||
def time_series(self) -> List[YamlTimeSeriesCollection]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should do this for all values in yaml model IMO. Doing it here when the properties are used makes it possible to work with the yaml file without everything being valid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, to only actually parse accordign to schema when we use a property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can have a separate validate function if we need to make sure the full model is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also require the model to be valid.
It would be nice if this class took care of it though. This class would then read the model, then we can get the properties in the model as yaml classes, removing the need to validate a lot of stuff in other places.
@@ -11,6 +13,7 @@ | |||
class YamlTimeSeriesCollectionBase(YamlBase): | |||
class Config: | |||
title = "TimeSeries" | |||
use_enum_values = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes enum a str when calling dict()
@@ -112,7 +112,8 @@ def map_yaml_to_variables( | |||
result_options: dto.ResultOptions, | |||
) -> dto.VariablesMap: | |||
timeseries_collections = [ | |||
TimeSeriesCollectionMapper(resources).from_yaml_to_dto(timeseries) for timeseries in configuration.time_series | |||
TimeSeriesCollectionMapper(resources).from_yaml_to_dto(timeseries.dict(by_alias=True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should look into removing this mapper and the classes, should be able to handle it in the yaml classes?
Converting back to dict as that is expected in TimeSeriesCollectionMapper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean to implicitly and automatically handle the conversion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://equinor-ecalc.atlassian.net/browse/ECALC-586 Explained a bit here.
TimeSeriesCollectionMapper should not need to deal with validation of the yaml at least, it could be simplified to only deal with reading the resources and creating something that can easily be added to variables map
Validate when getting time_series from yaml model.
aceffca
to
93baf08
Compare
@@ -269,8 +273,15 @@ def facility_inputs(self): | |||
return self._internal_datamodel.get(EcalcYamlKeywords.facility_inputs, []) | |||
|
|||
@property | |||
def time_series(self): | |||
return self._internal_datamodel.get(EcalcYamlKeywords.time_series, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was returned here? a "string dict"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously it was a list of dicts, each dict was a time series entry from yaml
Validate when getting time_series from yaml model.