From 59feb40373b1423174288334502882663be8aee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20=C3=85berg?= Date: Thu, 4 Jan 2024 13:50:23 +0100 Subject: [PATCH] fix: add options input to runExperiment - add options to all implementations - expose ExecutionOptions type --- src/api.ts | 7 ++++--- src/experiment.ts | 4 +++- src/index.ts | 2 ++ src/types/index.d.ts | 3 +++ src/workspace.ts | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/api.ts b/src/api.ts index 9f3ecb4..0f38425 100644 --- a/src/api.ts +++ b/src/api.ts @@ -28,6 +28,7 @@ import { ProjectId, WorkspaceProtocol, WorkspaceId, + ExecutionOptions, } from './types' import { wrapper as axiosCookieWrapper } from 'axios-cookiejar-support' @@ -403,10 +404,12 @@ class Api { cases, experimentId, workspaceId, + options, }: { cases: CaseId[] experimentId: ExperimentId workspaceId: WorkspaceId + options?: ExecutionOptions }): Promise => new Promise((resolve, reject) => { this.ensureImpactToken() @@ -418,9 +421,7 @@ class Api { includeCases: { ids: cases, }, - options: { - forceCompilation: true, - }, + options } ) .then(() => resolve()) diff --git a/src/experiment.ts b/src/experiment.ts index 8a198ae..d2011cc 100644 --- a/src/experiment.ts +++ b/src/experiment.ts @@ -1,5 +1,6 @@ import { CaseId, + ExecutionOptions, ExperimentId, ExperimentMetaData, ExperimentRunInfo, @@ -125,11 +126,12 @@ class Experiment { }) } - run = async (cases: CaseId[]): Promise => + run = async (cases: CaseId[], options?: ExecutionOptions): Promise => this.api.runExperiment({ cases, experimentId: this.id, workspaceId: this.workspaceId, + options, }) executionDone = async (timeout: number): Promise => { diff --git a/src/index.ts b/src/index.ts index 8c65824..382a19c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,6 +17,7 @@ import { CaseTrajectories, CustomFunction, CustomFunctionOptions, + ExecutionOptions, ExecutionStatusType, ExperimentId, ExperimentRunInfo, @@ -52,6 +53,7 @@ export { ExperimentId, ExperimentRunInfo, ExperimentTrajectories, + ExecutionOptions, FmuModel, InvalidApiKey, JhTokenError, diff --git a/src/types/index.d.ts b/src/types/index.d.ts index f83b3aa..92f2445 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -7,6 +7,9 @@ export type CustomFunctionOptions = export type CustomFunction = operations['getCustomFunction']['responses']['200']['content']['application/json'] +export type ExecutionOptions = + NonNullable['content']['application/json']['options']> + export type ExecutionStatusType = operations['getExecutionStatus']['responses']['200']['content']['application/json'] diff --git a/src/workspace.ts b/src/workspace.ts index dff54a1..9855a14 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -2,6 +2,7 @@ import { CaseId, CustomFunction, CustomFunctionOptions, + ExecutionOptions, ExperimentId, ExperimentItem, WorkspaceDefinition, @@ -51,9 +52,11 @@ class Workspace { executeExperiment = async ({ caseIds, experimentDefinition, + options, }: { caseIds: CaseId[] experimentDefinition: ExperimentDefinition + options?: ExecutionOptions }): Promise => { const experiment = await this.createExperiment(experimentDefinition) @@ -61,6 +64,7 @@ class Workspace { cases: caseIds, experimentId: experiment.id, workspaceId: this.id, + options }) return new Experiment({