Skip to content

Commit

Permalink
Merge pull request #27 from modelon-community/topic/expose-experiment…
Browse files Browse the repository at this point in the history
…-execution-options

fix: add options input to runExperiment
  • Loading branch information
maraberg authored Jan 4, 2024
2 parents 0599c9b + 59feb40 commit 29be1f2
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ProjectId,
WorkspaceProtocol,
WorkspaceId,
ExecutionOptions,
} from './types'

import { wrapper as axiosCookieWrapper } from 'axios-cookiejar-support'
Expand Down Expand Up @@ -403,10 +404,12 @@ class Api {
cases,
experimentId,
workspaceId,
options,
}: {
cases: CaseId[]
experimentId: ExperimentId
workspaceId: WorkspaceId
options?: ExecutionOptions
}): Promise<void> =>
new Promise((resolve, reject) => {
this.ensureImpactToken()
Expand All @@ -418,9 +421,7 @@ class Api {
includeCases: {
ids: cases,
},
options: {
forceCompilation: true,
},
options
}
)
.then(() => resolve())
Expand Down
4 changes: 3 additions & 1 deletion src/experiment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
CaseId,
ExecutionOptions,
ExperimentId,
ExperimentMetaData,
ExperimentRunInfo,
Expand Down Expand Up @@ -125,11 +126,12 @@ class Experiment {
})
}

run = async (cases: CaseId[]): Promise<void> =>
run = async (cases: CaseId[], options?: ExecutionOptions): Promise<void> =>
this.api.runExperiment({
cases,
experimentId: this.id,
workspaceId: this.workspaceId,
options,
})

executionDone = async (timeout: number): Promise<void> => {
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
CaseTrajectories,
CustomFunction,
CustomFunctionOptions,
ExecutionOptions,
ExecutionStatusType,
ExperimentId,
ExperimentRunInfo,
Expand Down Expand Up @@ -52,6 +53,7 @@ export {
ExperimentId,
ExperimentRunInfo,
ExperimentTrajectories,
ExecutionOptions,
FmuModel,
InvalidApiKey,
JhTokenError,
Expand Down
3 changes: 3 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export type CustomFunctionOptions =
export type CustomFunction =
operations['getCustomFunction']['responses']['200']['content']['application/json']

export type ExecutionOptions =
NonNullable<NonNullable<operations['execute']['requestBody']>['content']['application/json']['options']>

export type ExecutionStatusType =
operations['getExecutionStatus']['responses']['200']['content']['application/json']

Expand Down
4 changes: 4 additions & 0 deletions src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CaseId,
CustomFunction,
CustomFunctionOptions,
ExecutionOptions,
ExperimentId,
ExperimentItem,
WorkspaceDefinition,
Expand Down Expand Up @@ -51,16 +52,19 @@ class Workspace {
executeExperiment = async ({
caseIds,
experimentDefinition,
options,
}: {
caseIds: CaseId[]
experimentDefinition: ExperimentDefinition
options?: ExecutionOptions
}): Promise<Experiment> => {
const experiment = await this.createExperiment(experimentDefinition)

await this.api.runExperiment({
cases: caseIds,
experimentId: experiment.id,
workspaceId: this.id,
options
})

return new Experiment({
Expand Down

0 comments on commit 29be1f2

Please sign in to comment.