Skip to content

Commit

Permalink
fix module
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv committed Jul 2, 2024
1 parent de81ad7 commit 8620d1d
Show file tree
Hide file tree
Showing 27 changed files with 373 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# from primary.services.sumo_access.inplace_volumetrics_access import InplaceVolumetricsAccess
from primary.services.inplace_volumetrics_provider.inplace_volumetrics_provider import InplaceVolumetricsProvider
from primary.services.sumo_access.inplace_volumetrics_acces_NEW import InplaceVolumetricsAccess
from primary.services.sumo_access.inplace_volumetrics_access import InplaceVolumetricsAccess as InplaceVolumetricsAccess_OLD
from primary.services.utils.authenticated_user import AuthenticatedUser
from primary.auth.auth_helper import AuthHelper

Expand Down Expand Up @@ -42,7 +43,7 @@ async def get_result_data_per_realization(
index_filter: List[schemas.InplaceVolumetricsIndex] = Body(embed=True, description="Categorical filter"),
) -> schemas.InplaceVolumetricData:
"""Get volumetric data summed per realization for a given table, result and categories/index filter."""
access = await InplaceVolumetricsAccess.from_case_uuid(
access = await InplaceVolumetricsAccess_OLD.from_case_uuid_async(
authenticated_user.get_sumo_access_token(), case_uuid, ensemble_name
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ async def get_inplace_volumetrics_table_names_async(
)
table_names = await vol_table_collection.names_async
return table_names


async def get_inplace_volumetrics_table_no_throw_async(
self, table_name: str, column_names: Optional[set[str]] = None
) -> Optional[pa.Table]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ class InplaceVolumetricData(BaseModel):


class InplaceVolumetricsAccess:
def __init__(self, case: Case, case_uuid: str):
def __init__(self, case: Case,case_uuid:str, iteration_name: str):
self._case: Case = case
self._case_uuid: str = case_uuid
self._iteration_name: str = iteration_name

@classmethod
async def from_case_uuid_async(cls, access_token: str, case_uuid: str) -> "InplaceVolumetricsAccess":
async def from_case_uuid_async(cls, access_token: str, case_uuid: str, iteration_name: str) -> "InplaceVolumetricsAccess":
sumo_client = create_sumo_client(access_token)
case: Case = await create_sumo_case_async(client=sumo_client, case_uuid=case_uuid, want_keepalive_pit=False)
return cls(case=case, case_uuid=case_uuid)
return cls(case=case,case_uuid=case_uuid, iteration_name=iteration_name)

async def get_inplace_volumetrics_table_definitions_async(self) -> List[InplaceVolumetricsTableDefinition]:
"""Retrieve the table definitions for the volumetric tables"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
else:
group_name = parameter_name_components[0]
parameter_name = parameter_name_components[1]
"GLOBVAR:PORO"


ensemble_parameters.append(
EnsembleParameter(
name=parameter_name,
Expand All @@ -151,3 +154,4 @@ def parameter_table_to_ensemble_parameters(parameter_table: pa.Table) -> List[En
)
)
return ensemble_parameters

2 changes: 2 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type { OpenAPIConfig } from './core/OpenAPI';
export { B64FloatArray as B64FloatArray_api } from './models/B64FloatArray';
export { B64UintArray as B64UintArray_api } from './models/B64UintArray';
export type { Body_get_result_data_per_realization as Body_get_result_data_per_realization_api } from './models/Body_get_result_data_per_realization';
export type { Body_post_get_aggregated_table_data as Body_post_get_aggregated_table_data_api } from './models/Body_post_get_aggregated_table_data';
export type { Body_post_get_polyline_intersection as Body_post_get_polyline_intersection_api } from './models/Body_post_get_polyline_intersection';
export type { Body_post_get_seismic_fence as Body_post_get_seismic_fence_api } from './models/Body_post_get_seismic_fence';
export type { Body_post_get_surface_intersection as Body_post_get_surface_intersection_api } from './models/Body_post_get_surface_intersection';
Expand All @@ -30,6 +31,7 @@ export type { EnsembleSensitivity as EnsembleSensitivity_api } from './models/En
export type { EnsembleSensitivityCase as EnsembleSensitivityCase_api } from './models/EnsembleSensitivityCase';
export type { FenceMeshSection as FenceMeshSection_api } from './models/FenceMeshSection';
export type { FieldInfo as FieldInfo_api } from './models/FieldInfo';
export { FluidZone as FluidZone_api } from './models/FluidZone';
export { Frequency as Frequency_api } from './models/Frequency';
export type { GraphUserPhoto as GraphUserPhoto_api } from './models/GraphUserPhoto';
export type { Grid3dDimensions as Grid3dDimensions_api } from './models/Grid3dDimensions';
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/api/models/Body_post_get_aggregated_table_data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { InplaceVolumetricsIndex } from './InplaceVolumetricsIndex';
export type Body_post_get_aggregated_table_data = {
/**
* Categorical filter
*/
index_filter: Array<InplaceVolumetricsIndex>;
};

9 changes: 9 additions & 0 deletions frontend/src/api/models/FluidZone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* generated using openapi-typescript-codegen -- do no edit */
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
export enum FluidZone {
OIL = 'Oil',
GAS = 'Gas',
WATER = 'Water',
}
9 changes: 3 additions & 6 deletions frontend/src/api/models/InplaceVolumetricsIndex.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
/* generated using openapi-typescript-codegen -- do no edit */

/* istanbul ignore file */

/* tslint:disable */

/* eslint-disable */
import type { InplaceVolumetricsIndexNames } from "./InplaceVolumetricsIndexNames";

import type { InplaceVolumetricsIndexNames } from './InplaceVolumetricsIndexNames';
/**
* Unique values for an index column in a volumetric table
* All values should ideally be strings, but it is commmon to see integers, especially for REGION
*/
export type InplaceVolumetricsIndex = {
index_name: InplaceVolumetricsIndexNames;
values: Array<string | number>;
values: Array<(string | number)>;
};

6 changes: 4 additions & 2 deletions frontend/src/api/models/InplaceVolumetricsTableDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import type { FluidZone } from './FluidZone';
import type { InplaceVolumetricsIndex } from './InplaceVolumetricsIndex';
/**
* Definition of a volumetric table
*/
export type InplaceVolumetricsTableDefinition = {
name: string;
indexes: Array<InplaceVolumetricsIndex>;
table_name: string;
fluid_zones: Array<FluidZone>;
result_names: Array<string>;
indexes: Array<InplaceVolumetricsIndex>;
};

41 changes: 41 additions & 0 deletions frontend/src/api/services/InplaceVolumetricsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* tslint:disable */
/* eslint-disable */
import type { Body_get_result_data_per_realization } from '../models/Body_get_result_data_per_realization';
import type { Body_post_get_aggregated_table_data } from '../models/Body_post_get_aggregated_table_data';
import type { InplaceVolumetricData } from '../models/InplaceVolumetricData';
import type { InplaceVolumetricResponseNames } from '../models/InplaceVolumetricResponseNames';
import type { InplaceVolumetricsTableDefinition } from '../models/InplaceVolumetricsTableDefinition';
Expand Down Expand Up @@ -71,4 +72,44 @@ export class InplaceVolumetricsService {
},
});
}
/**
* Post Get Aggregated Table Data
* Get aggregated volumetric data for a given table, result and categories/index filter.
* @param caseUuid Sumo case uuid
* @param ensembleName Ensemble name
* @param tableName Table name
* @param responseNames The name of the volumetric result/response
* @param aggregateBy The index types to aggregate by
* @param realizations Realizations
* @param requestBody
* @returns InplaceVolumetricData Successful Response
* @throws ApiError
*/
public postGetAggregatedTableData(
caseUuid: string,
ensembleName: string,
tableName: string,
responseNames: Array<InplaceVolumetricResponseNames>,
aggregateBy: Array<string>,
realizations: Array<number>,
requestBody: Body_post_get_aggregated_table_data,
): CancelablePromise<InplaceVolumetricData> {
return this.httpRequest.request({
method: 'POST',
url: '/inplace_volumetrics/get_aggregated_table_data/',
query: {
'case_uuid': caseUuid,
'ensemble_name': ensembleName,
'table_name': tableName,
'response_names': responseNames,
'aggregate_by': aggregateBy,
'realizations': realizations,
},
body: requestBody,
mediaType: 'application/json',
errors: {
422: `Validation Error`,
},
});
}
}
18 changes: 0 additions & 18 deletions frontend/src/modules/InplaceVolumetrics/registerModule.ts

This file was deleted.

7 changes: 6 additions & 1 deletion frontend/src/modules/InplaceVolumetrics/registerModule.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { ModuleCategory, ModuleDevState } from "@framework/Module";
import { ModuleRegistry } from "@framework/ModuleRegistry";

import { Interface } from "./settingsToViewInterface";
import { State } from "./state";

export const MODULE_NAME = "InplaceVolumetrics";
ModuleRegistry.registerModule<State, Interface>({

ModuleRegistry.registerModule<State, Interface, Record<string, never>>({
moduleName: MODULE_NAME,
defaultTitle: "Inplace Volumetrics",
category: ModuleCategory.MAIN,
devState: ModuleDevState.DEV,
description: "Inplace Volumetrics",
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { InplaceVolumetricsIndex_api } from "@api";
import { FluidZone_api, InplaceVolumetricsIndex_api } from "@api";
import { EnsembleIdent } from "@framework/EnsembleIdent";
import { atomWithCompare } from "@framework/utils/atomUtils";
import { FluidZoneTypeEnum } from "@modules/_shared/InplaceVolumetrics/types";

import { atom } from "jotai";

import { availableInplaceResponsesAtom } from "./derivedAtoms";

import { PlotGroupingEnum, PlotTypeEnum } from "../../typesAndEnums";

function areEnsembleIdentListsEqual(a: EnsembleIdent[], b: EnsembleIdent[]) {
Expand All @@ -25,5 +24,6 @@ export const plotTypeAtom = atom<PlotTypeEnum>(PlotTypeEnum.HISTOGRAM);
export const groupByAtom = atomWithCompare<PlotGroupingEnum>(PlotGroupingEnum.ENSEMBLE, (a, b) => a === b);
export const colorByAtom = atomWithCompare<PlotGroupingEnum>(PlotGroupingEnum.ENSEMBLE, (a, b) => a === b);
export const userSelectedInplaceTableNameAtom = atom<string | null>(null);
export const userSelectedInplaceFluidZonesAtom = atom<FluidZone_api[]>([]);
export const userSelectedInplaceResponseAtom = atom<string | null>(null);
export const userSelectedInplaceCategoriesAtom = atom<InplaceVolumetricsIndex_api[]>([]);
export const userSelectedInplaceIndexesAtom = atom<InplaceVolumetricsIndex_api[]>([]);
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { InplaceVolumetricsTableDefinition_api } from "@api";
import { EnsembleSetAtom } from "@framework/GlobalAtoms";
import InplaceVolumetricsTable from "@modules/InplaceVolumetricsTable/components/InplaceVolumetricsTable";
import { QueriesStatus } from "@modules/InplaceVolumetricsTable/types";
import { InplaceVolumesTablesInfoAccessor } from "@modules/_shared/InplaceVolumetrics/InplaceVolumetricsTablesInfoAccessor";

import { atom } from "jotai";

import {
colorByAtom,
groupByAtom,
userSelectedEnsembleIdentsAtom,
userSelectedInplaceCategoriesAtom,
userSelectedInplaceFluidZonesAtom,
userSelectedInplaceIndexesAtom,
userSelectedInplaceResponseAtom,
userSelectedInplaceTableNameAtom,
} from "./baseAtoms";
import { inplaceTableInfosQueryAtom } from "./queryAtoms";

import { findCommonTablesAcrossCollections } from "../../utils/intersectTableInfos";
import { inplaceTableDefinitionsQueriesAtom } from "./queryAtoms";

export const selectedEnsembleIdentsAtom = atom((get) => {
const ensembleSet = get(EnsembleSetAtom);
Expand All @@ -30,68 +33,86 @@ export const selectedEnsembleIdentsAtom = atom((get) => {
return computedEnsembleIdents;
});

export const intersectedTablesAtom = atom((get) => {
const inplaceTableInfosQuery = get(inplaceTableInfosQueryAtom);
return findCommonTablesAcrossCollections(inplaceTableInfosQuery.tableInfoCollections);
export const isInplaceTableDefinitionsQueriesFetchingAtom = atom<boolean>((get) => {
const inplaceTableDefinitionsQueries = get(inplaceTableDefinitionsQueriesAtom);

return inplaceTableDefinitionsQueries.isFetching;
});

export const availableInplaceTableNamesAtom = atom((get) => {
const intersectedTables = get(intersectedTablesAtom);
return intersectedTables.map((table) => table.name);
export const inplaceVolumetricsTableInfosAccessorAtom = atom((get) => {
const inplaceTableDefinitionsQueries = get(inplaceTableDefinitionsQueriesAtom);
const isFetching = get(isInplaceTableDefinitionsQueriesFetchingAtom);
if (isFetching) {
return new InplaceVolumesTablesInfoAccessor([]);
}

const accessor = new InplaceVolumesTablesInfoAccessor(inplaceTableDefinitionsQueries.tableInfos);
return accessor;
});

export const selectedInplaceTableNameAtom = atom((get) => {
const accessor = get(inplaceVolumetricsTableInfosAccessorAtom);
const availableInplaceTableNames = accessor.getTableNames();

const userSelectedInplaceTableName = get(userSelectedInplaceTableNameAtom);
const availableInplaceTableNames = get(availableInplaceTableNamesAtom);
if (userSelectedInplaceTableName && availableInplaceTableNames.includes(userSelectedInplaceTableName)) {
return userSelectedInplaceTableName;
}
return availableInplaceTableNames.length ? availableInplaceTableNames[0] : null;
});

export const availableInplaceResponsesAtom = atom((get) => {
const intersectedTables = get(intersectedTablesAtom);
const selectedInplaceTableName = get(selectedInplaceTableNameAtom);
const selectedTable = intersectedTables.find((table) => table.name === selectedInplaceTableName);
return selectedTable?.result_names || [];
export const selectedInplaceFluidZonesAtom = atom((get) => {
const accessor = get(inplaceVolumetricsTableInfosAccessorAtom);
const availableInplaceFluidZones = accessor.getFluidZones();

const userSelectedInplaceFluidZones = get(userSelectedInplaceFluidZonesAtom);

if (userSelectedInplaceFluidZones.length === 0) {
return availableInplaceFluidZones;
}

const intersection = availableInplaceFluidZones.filter((zone) => userSelectedInplaceFluidZones.includes(zone));

return intersection;
});

export const selectedInplaceResponseAtom = atom((get) => {
const availableInplaceResponses = get(availableInplaceResponsesAtom);
const accessor = get(inplaceVolumetricsTableInfosAccessorAtom);
const availableInplaceResponses = accessor.getResponseNames();

const userSelectedInplaceResponse = get(userSelectedInplaceResponseAtom);
if (userSelectedInplaceResponse && availableInplaceResponses.includes(userSelectedInplaceResponse)) {
return userSelectedInplaceResponse;
}
if (availableInplaceResponses.length) {
if (availableInplaceResponses.includes("STOIIP_OIL")) {
return "STOIIP_OIL";
if (availableInplaceResponses.includes("STOIIP")) {
return "STOIIP";
}
if (availableInplaceResponses.includes("GIIP")) {
return "GIIP";
}
return availableInplaceResponses[0];
}
return null;
});
export const availableInplaceCategoriesAtom = atom((get) => {
const intersectedTables = get(intersectedTablesAtom);
const selectedInplaceTableName = get(selectedInplaceTableNameAtom);
const selectedTable = intersectedTables.find((table) => table.name === selectedInplaceTableName);
return selectedTable?.indexes ?? [];
});

export const selectedInplaceCategoriesAtom = atom((get) => {
const availableInplaceCategories = get(availableInplaceCategoriesAtom);
export const selectedInplaceIndexesAtom = atom((get) => {
const accessor = get(inplaceVolumetricsTableInfosAccessorAtom);
const availableInplaceIndexes = accessor.getIndexes();

const userSelectedInplaceCategories = get(userSelectedInplaceCategoriesAtom);
const userSelectedInplaceIndexes = get(userSelectedInplaceIndexesAtom);

if (userSelectedInplaceCategories.length) {
return availableInplaceCategories.map((category) => {
const userSelectedCategory = userSelectedInplaceCategories.find(
(selectedCategory) => selectedCategory.index_name === category.index_name
if (userSelectedInplaceIndexes.length) {
return availableInplaceIndexes.map((category) => {
const userSelectedIndex = userSelectedInplaceIndexes.find(
(selectedIndex) => selectedIndex.index_name === category.index_name
);
if (userSelectedCategory && userSelectedCategory.values.length) {
return userSelectedCategory;
if (userSelectedIndex && userSelectedIndex.values.length) {
return userSelectedIndex;
}
return category;
});
}

return availableInplaceCategories;
return availableInplaceIndexes;
});
Loading

0 comments on commit 8620d1d

Please sign in to comment.