-
Notifications
You must be signed in to change notification settings - Fork 12
Combine parameters and sensitivities into a single endpoint #1397
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
base: main
Are you sure you want to change the base?
Conversation
jorgenherje
left a comment
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.
Looks good. Some minor comments from my side :)
| sumo_client = create_sumo_client(access_token) | ||
| return cls(sumo_client=sumo_client, case_uuid=case_uuid, ensemble_name=ensemble_name) | ||
|
|
||
| async def get_parameters_and_sensitivities_async(self) -> EnsembleParameters: |
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.
Consider changing return type to be a tuple: (list[EnsembleParameter], list[EnsembleSensitivity]
|
|
||
| parameters: List[EnsembleParameter] | ||
| sensitivities: Optional[List[EnsembleSensitivity]] = None | ||
| sensitivities: List[EnsembleSensitivity] |
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.
I think we can remove the EnsembleParameters class and then just make the return type of ParameterAccess.get_parameters_and_sensitivities_async() to be tuple: (list[EnsembleParameter], list[EnsembleSensitivity]). If not we should rename the class to EnsembleParametersAndSensitivities
| @@ -1,2 +1,2 @@ | |||
| import logging | |||
| from typing import List, Optional, Literal | |||
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.
Unused imports
|
|
||
| from primary.auth.auth_helper import AuthHelper | ||
| from webviz_services.sumo_access.parameter_access import ParameterAccess | ||
| from webviz_services.sumo_access.parameter_types import EnsembleParameter, EnsembleSensitivity |
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.
Unused imports (assume it will still be unused if you adjust according to previous comments)
| class EnsembleParameter(BaseModel): | ||
| """Description/data for a single parameter in an ensemble""" | ||
|
|
||
| name: str | ||
| is_logarithmic: bool | ||
| is_discrete: bool # values are string or integer | ||
| is_constant: bool # all values are equal | ||
| group_name: Optional[str] = None | ||
| descriptive_name: Optional[str] = None | ||
| is_discrete: bool | ||
| realizations: List[int] | ||
| values: Union[List[float], List[int], List[str]] |
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.
I know it hasn't been added now, but should we have camelCase naming in this file?
| const parametersAndSensitivitiesOutcome = parametersAndSensitivitiesOutcomeArray[i]; | ||
| console.debug(`parametersAndSensitivitiesOutcome[${i}]:`, parametersAndSensitivitiesOutcome.status); | ||
| let parameterArray: EnsembleParameter_api[] = []; | ||
| if (parametersOutcome.status === "fulfilled") { | ||
| parameterArray = parametersOutcome.value; | ||
| let sensitivityArray: EnsembleSensitivity_api[] = []; | ||
| if (parametersAndSensitivitiesOutcome.status === "fulfilled") { | ||
| parameterArray = parametersAndSensitivitiesOutcome.value.parameters; | ||
| sensitivityArray = parametersAndSensitivitiesOutcome.value.sensitivities; | ||
| } else { | ||
| const errorMessage = "Error fetching ensemble parameters, dropping ensemble."; | ||
| console.error(errorMessage, ensembleIdentString); | ||
| ensembleLoadingErrorInfoMap[ensembleIdentString] = { | ||
| errorMessage: errorMessage, | ||
| displayName: createRegularEnsembleDisplayName(ensembleIdents[i]), | ||
| }; | ||
| continue; | ||
| } |
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.
I know we did not check it previously, because the back-end failed if there was no parameters. But should we have a check for parameterArray.length === 0 to ensure that the ensemble has non-empty parameter array?
Closes #1396