Skip to content

Commit

Permalink
feat(simint-alpha): adopt breaking changes from the API (#1105)
Browse files Browse the repository at this point in the history
- remove simulator.enable property
- remove simulatorIntegration.runApiEnabled property
- remove name- fields on simulation runs
- remove filters by name- fields on simulation runs
- make externalId-, dataSetId, logId fields required on the output type of the simulation run
- remove invalid aggregation types
- remove calculationType property from the routine type
  • Loading branch information
polomani authored May 24, 2024
1 parent a170bf3 commit 8f8dba6
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describeIf('simulation run data api', () => {
test('list simulation run data', async () => {
const runs = await client.simulators.listRuns({
filter: {
simulatorName: 'DWSIM',
simulatorExternalIds: ['DWSIM'],
status: 'success',
},
});
Expand Down
12 changes: 6 additions & 6 deletions packages/alpha/src/__tests__/api/simulationRunsApi.int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ describeIf('simulator integrations api', () => {

const item = res[0];

expect(item.simulatorName).toBe('DWSIM');
expect(item.modelName).toBe('Shower Mixer');
expect(item.routineName).toBe('Steady State Calculation');
expect(item.simulatorExternalId).toBe('DWSIM');
expect(item.modelExternalId).toBe('DWSIM-ShowerMixer');
expect(item.routineExternalId).toBe('DWSIM-ShowerMixer-SteadyState');
expect(['ready', 'running']).toContain(item.status);
expect(item.runType).toBe('external');
expect(item.runTime?.valueOf()).toBe(ts);
Expand All @@ -42,7 +42,7 @@ describeIf('simulator integrations api', () => {
test('list simulation runs', async () => {
const res = await client.simulators.listRuns({
filter: {
simulatorName: 'DWSIM',
simulatorExternalIds: ['DWSIM'],
status: 'success',
createdTime: {
max: new Date(),
Expand All @@ -61,7 +61,7 @@ describeIf('simulator integrations api', () => {

const item = res.items[0];

expect(item.simulatorName).toBe('DWSIM');
expect(item.simulatorExternalId).toBe('DWSIM');
expect(item.status).toBe('success');
expect(item.createdTime.valueOf()).toBeGreaterThan(0);
expect(item.lastUpdatedTime.valueOf()).toBeGreaterThan(0);
Expand All @@ -77,7 +77,7 @@ describeIf('simulator integrations api', () => {

const item = res[0];

expect(item.simulatorName).toBe('DWSIM');
expect(item.simulatorExternalId).toBe('DWSIM');
expect(['ready', 'running', 'success']).toContain(item.status);
expect(item.id).toBe(runId);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ describeIf('simulator integrations api', () => {
externalId: simulatorExternalId,
name: simulatorName,
fileExtensionTypes,
enabled: true,
stepFields,
unitQuantities,
modelTypes,
Expand All @@ -47,7 +46,6 @@ describeIf('simulator integrations api', () => {
dataSetId: 4097666328084896,
connectorVersion: '1.0.0',
simulatorVersion: '1.0.0',
runApiEnabled: true,
licenseStatus: 'active',
licenseLastCheckedTime: new Date(),
connectorStatus: 'unknown',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describeIf('simulator models api', () => {
externalId: simulatorExternalId,
name: simulatorName,
fileExtensionTypes,
enabled: true,
stepFields,
unitQuantities,
modelTypes,
Expand Down
2 changes: 0 additions & 2 deletions packages/alpha/src/__tests__/api/simulatorRoutinesApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describeIf('simulator routines api', () => {
externalId: simulatorExternalId,
name: simulatorName,
fileExtensionTypes,
enabled: true,
stepFields,
unitQuantities,
modelTypes,
Expand All @@ -53,7 +52,6 @@ describeIf('simulator routines api', () => {
dataSetId: 4097666328084896,
connectorVersion: '1.0.0',
simulatorVersion: '1.0.0',
runApiEnabled: true,
licenseStatus: 'active',
connectorStatus: 'unknown',
},
Expand Down
6 changes: 1 addition & 5 deletions packages/alpha/src/__tests__/api/simulatorsApi.int.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describeIf('simulators api', () => {
externalId: simulatorExternalId,
name: simulatorName,
fileExtensionTypes,
enabled: true,
stepFields,
unitQuantities,
modelTypes,
Expand All @@ -38,7 +37,6 @@ describeIf('simulators api', () => {
expect(response.length).toBe(1);
expect(response[0].externalId).toBe(simulatorExternalId);
expect(response[0].fileExtensionTypes).toEqual(['csv', 'yaml']);
expect(response[0].enabled).toBe(true);
expect(response[0].stepFields).toEqual(stepFields);
expect(response[0].unitQuantities).toEqual(unitQuantities);
expect(response[0].modelTypes).toEqual(modelTypes);
Expand Down Expand Up @@ -104,9 +102,7 @@ describeIf('simulators api', () => {
});

test('list simulators', async () => {
const response = await client.simulators.list({
filter: { enabled: true },
});
const response = await client.simulators.list({});
expect(response.items.length).toBeGreaterThan(0);
const simulatorFound = response.items.find(
(item) => item.externalId === simulatorExternalId
Expand Down
53 changes: 11 additions & 42 deletions packages/alpha/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,21 @@ export interface Simulator {
name: string;
fileExtensionTypes: string[];
modelTypes: SimulatorModelType[];
enabled: boolean;
stepFields?: SimulatorStep[];
unitQuantities?: SimulatorUnitQuantity[];
createdTime: Date;
lastUpdatedTime: Date;
}

export interface SimulatorFilter {
enabled?: boolean;
}

export interface SimulatorFilterQuery extends FilterQuery {
filter?: SimulatorFilter;
filter?: {};
}

export interface SimulatorCreate {
externalId: CogniteExternalId;
fileExtensionTypes: string[];
name: string;
modelTypes?: SimulatorModelType[];
enabled?: boolean;
stepFields?: SimulatorStep[];
unitQuantities?: SimulatorUnitQuantity[];
}
Expand All @@ -98,7 +92,6 @@ export interface SimulatorIntegration {
dataSetId: CogniteInternalId;
connectorVersion: string;
simulatorVersion: string;
runApiEnabled: boolean;
licenseStatus?: string;
licenseLastCheckedTime?: Date;
connectorStatus?: string;
Expand All @@ -114,7 +107,6 @@ export interface SimulatorIntegrationCreate {
heartbeat?: Date;
connectorVersion?: string;
simulatorVersion?: string;
runApiEnabled?: boolean;
licenseStatus?: string;
licenseLastCheckedTime?: Date;
connectorStatus?: string;
Expand All @@ -130,9 +122,6 @@ export interface SimulatorIntegrationFilterQuery extends FilterQuery {
}

export interface SimulationRunFilter {
simulatorName?: string;
modelName?: string;
routineName?: string;
status?: SimulationRunStatus;
runType?: SimulationRunType;
simulatorIntegrationExternalIds?: CogniteExternalId[];
Expand Down Expand Up @@ -160,7 +149,6 @@ export interface SimulatorPatch {
fileExtensionTypes?: SinglePatch<string[]>;
name?: SinglePatch<string>;
modelTypes?: SinglePatch<SimulatorModelType[]>;
enabled?: SinglePatch<boolean>;
stepFields?: SinglePatch<SimulatorStep[]>;
unitQuantities?: SinglePatch<SimulatorUnitQuantity[]>;
};
Expand Down Expand Up @@ -194,24 +182,22 @@ export const SimulationRunStatus = {

export interface SimulationRun {
id: CogniteInternalId;
simulatorName: string;
modelName: string;
routineName: string;
simulatorExternalId?: CogniteExternalId;
simulatorIntegrationExternalId?: CogniteExternalId;
modelExternalId?: CogniteExternalId;
modelRevisionExternalId?: CogniteExternalId;
routineExternalId?: CogniteExternalId;
routineRevisionExternalId?: CogniteExternalId;

simulatorExternalId: CogniteExternalId;
simulatorIntegrationExternalId: CogniteExternalId;
modelExternalId: CogniteExternalId;
modelRevisionExternalId: CogniteExternalId;
routineExternalId: CogniteExternalId;
routineRevisionExternalId: CogniteExternalId;
status: SimulationRunStatus;
runTime?: Date;
simulationTime?: Date;
statusMessage?: string;
dataSetId?: CogniteInternalId;
dataSetId: CogniteInternalId;
eventId?: CogniteInternalId;
runType: SimulationRunType;
userId?: string;
logId?: CogniteInternalId;
logId: CogniteInternalId;
createdTime: Date;
lastUpdatedTime: Date;
}
Expand Down Expand Up @@ -380,26 +366,11 @@ export interface SimulatorModelRevisionFilterQuery extends FilterQuery {
limit?: number;
}

export type SimulatorCalculationType =
| 'IPR/VLP'
| 'ChokeDp'
| 'VLP'
| 'IPR'
| 'BhpFromRate'
| 'BhpFromGradientTraverse'
| 'BhpFromGaugeBhp';
export type SimulatorRoutineOperator = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
export type SimulatorDataPointsAggregate =
| 'average'
| 'max'
| 'min'
| 'count'
| 'sum'
| 'interpolation'
| 'stepInterpolation'
| 'totalVariation'
| 'continuousVariance'
| 'discreteVariance';
| 'stepInterpolation';

export interface SimulatorRoutine {
id: CogniteInternalId;
Expand All @@ -419,7 +390,6 @@ export interface SimulatorRoutineCreate {
modelExternalId: CogniteExternalId;
simulatorIntegrationExternalId: CogniteExternalId;
name: string;
calculationType?: SimulatorCalculationType;
}

export interface SimulatorRoutineFilter {
Expand Down Expand Up @@ -531,7 +501,6 @@ export interface SimulatorRoutineRevision {
lastUpdatedTime: Date;
configuration: SimulatorRoutineRevisionConfiguration;
script: SimulatorRoutineScript[];
calculationType?: SimulatorCalculationType;
}

export interface SimulatorRoutineRevisionCreate {
Expand Down

0 comments on commit 8f8dba6

Please sign in to comment.