Skip to content

Conversation

@HansKallekleiv
Copy link
Collaborator

Closes #1396

  • Combine parameters and sensitivity data into a single endpoint to avoid querying Sumo for the same data twice.
  • Remove unused endpoints
  • Return an empty array for sensitivities instead of None. Frontend modules using sensitivity functionality already checks the length of the array.

Copy link
Collaborator

@jorgenherje jorgenherje left a 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:
Copy link
Collaborator

@jorgenherje jorgenherje Dec 16, 2025

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]
Copy link
Collaborator

@jorgenherje jorgenherje Dec 16, 2025

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
Copy link
Collaborator

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
Copy link
Collaborator

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)

Comment on lines 7 to 17
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]]
Copy link
Collaborator

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?

Comment on lines 335 to 350
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;
}
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combine parameters and sensitivities into a single query

2 participants