diff --git a/src/workflow/factory.ts b/src/workflow/factory.ts index 90756ac..dbdfc72 100644 --- a/src/workflow/factory.ts +++ b/src/workflow/factory.ts @@ -19,9 +19,9 @@ export class WorkflowEngineFactory { try { this.prepareWorkflow(workflow, options); const optionsInteranl = options as WorkflowOptionsInternal; - const executor = await WorkflowUtils.getExecutor(workflow, optionsInteranl); const bindings = await this.prepareBindings(workflow.bindings || [], optionsInteranl); optionsInteranl.currentBindings = bindings; + const executor = await WorkflowUtils.getExecutor(workflow, optionsInteranl); const stepExecutors = await this.createStepExecutors(workflow.steps, optionsInteranl); return new WorkflowEngine(workflow.name, executor, bindings, stepExecutors); } catch (error: any) { diff --git a/src/workflow/types.ts b/src/workflow/types.ts index c73d30a..a4d2f74 100644 --- a/src/workflow/types.ts +++ b/src/workflow/types.ts @@ -37,10 +37,8 @@ export type Workflow = { bindings?: Binding[]; steps: Step[]; templateType?: TemplateType; - executor?: { - name: string; - path: string; - }; + // Executor name will be searched in the bindings + executor?: string; }; export type WorkflowOutput = { diff --git a/src/workflow/utils.ts b/src/workflow/utils.ts index 98af24e..a6abb3e 100644 --- a/src/workflow/utils.ts +++ b/src/workflow/utils.ts @@ -136,17 +136,12 @@ export class WorkflowUtils { workflow: Workflow, options: WorkflowOptionsInternal, ): Promise { - if (workflow?.executor?.path) { - let executor = await this.getModuleExportsFromAllPaths(workflow.executor.path, options); - - if ( - !executor || - !executor[workflow.executor.name] || - !executor[workflow.executor.name].execute - ) { - throw new WorkflowCreationError('Workflow executor not found', workflow.name); + if (workflow?.executor) { + let executor = options.currentBindings[workflow.executor]; + if (!executor?.execute) { + throw new WorkflowCreationError('Workflow executor not found', workflow.executor); } - return executor[workflow.executor.name]; + return executor; } return options.executor || DefaultWorkflowExecutor.INSTANCE; } diff --git a/test/scenarios/custom_executor/bad_executor.yaml b/test/scenarios/custom_executor/bad_executor.yaml index 61a8842..e883e73 100644 --- a/test/scenarios/custom_executor/bad_executor.yaml +++ b/test/scenarios/custom_executor/bad_executor.yaml @@ -1,6 +1,5 @@ -executor: - path: ./custom_executors - name: invalidExecutor +executor: invalidExecutor + steps: - name: dummy template: | diff --git a/test/scenarios/custom_executor/workflow.yaml b/test/scenarios/custom_executor/workflow.yaml index a9e9f67..e8c43d3 100644 --- a/test/scenarios/custom_executor/workflow.yaml +++ b/test/scenarios/custom_executor/workflow.yaml @@ -1,6 +1,8 @@ -executor: - path: ./custom_executors - name: customWorkflowExecutor +bindings: + - path: ./custom_executors + name: customWorkflowExecutor + +executor: customWorkflowExecutor steps: - name: dummy template: |