Skip to content

Commit f9a0511

Browse files
committed
Integrate with synchronous provisioning feature
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent bcf5156 commit f9a0511

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

common/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ export const MAX_BYTES_FORMATTED = '1,048,576';
654654
export const MAX_WORKFLOW_NAME_TO_DISPLAY = 40;
655655
export const WORKFLOW_NAME_REGEXP = RegExp('^[a-zA-Z0-9_-]*$');
656656
export const INDEX_NAME_REGEXP = WORKFLOW_NAME_REGEXP;
657+
export const PROVISION_TIMEOUT = '10s'; // the timeout config for synchronous provisioning. https://github.com/opensearch-project/flow-framework/pull/990
657658
export const EMPTY_MAP_ENTRY = { key: '', value: '' } as MapEntry;
658659
export const EMPTY_INPUT_MAP_ENTRY = {
659660
key: '',
@@ -662,7 +663,6 @@ export const EMPTY_INPUT_MAP_ENTRY = {
662663
value: '',
663664
},
664665
} as InputMapEntry;
665-
666666
export const EMPTY_OUTPUT_MAP_ENTRY = {
667667
...EMPTY_INPUT_MAP_ENTRY,
668668
value: {

public/pages/workflow_detail/workflow_inputs/workflow_inputs.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ export function WorkflowInputs(props: WorkflowInputsProps) {
400400
)
401401
.unwrap()
402402
.then(async (result) => {
403-
await sleep(1000);
404-
405403
await dispatch(
406404
getWorkflow({
407405
workflowId: updatedWorkflow.id as string,

public/utils/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export function getEmbeddingModelDimensions(
626626
// so we check for that first.
627627
if (connector?.parameters?.dimensions !== undefined) {
628628
return connector.parameters?.dimensions;
629-
} else if (connector.parameters?.model !== undefined) {
629+
} else if (connector?.parameters?.model !== undefined) {
630630
return (
631631
// @ts-ignore
632632
COHERE_CONFIGS[connector.parameters?.model]?.dimension ||

server/cluster/flow_framework_plugin.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
FLOW_FRAMEWORK_SEARCH_WORKFLOWS_ROUTE,
88
FLOW_FRAMEWORK_SEARCH_WORKFLOW_STATE_ROUTE,
99
FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX,
10+
PROVISION_TIMEOUT,
1011
} from '../../common';
1112

1213
/**
@@ -75,7 +76,7 @@ export function flowFrameworkPlugin(Client: any, config: any, components: any) {
7576

7677
flowFramework.updateWorkflow = ca({
7778
url: {
78-
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>?update_fields=<%=update_fields%>&reprovision=<%=reprovision%>`,
79+
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>?update_fields=<%=update_fields%>`,
7980
req: {
8081
workflow_id: {
8182
type: 'string',
@@ -85,7 +86,21 @@ export function flowFrameworkPlugin(Client: any, config: any, components: any) {
8586
type: 'boolean',
8687
required: true,
8788
},
88-
reprovision: {
89+
},
90+
},
91+
needBody: true,
92+
method: 'PUT',
93+
});
94+
95+
flowFramework.updateAndReprovisionWorkflow = ca({
96+
url: {
97+
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>?update_fields=<%=update_fields%>&reprovision=true&wait_for_completion_timeout=${PROVISION_TIMEOUT}`,
98+
req: {
99+
workflow_id: {
100+
type: 'string',
101+
required: true,
102+
},
103+
update_fields: {
89104
type: 'boolean',
90105
required: true,
91106
},
@@ -97,7 +112,7 @@ export function flowFrameworkPlugin(Client: any, config: any, components: any) {
97112

98113
flowFramework.provisionWorkflow = ca({
99114
url: {
100-
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>/_provision`,
115+
fmt: `${FLOW_FRAMEWORK_WORKFLOW_ROUTE_PREFIX}/<%=workflow_id%>/_provision?wait_for_completion_timeout=${PROVISION_TIMEOUT}`,
101116
req: {
102117
workflow_id: {
103118
type: 'string',

server/routes/flow_framework_routes_service.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,21 @@ export class FlowFrameworkRoutesService {
475475
data_source_id,
476476
this.client
477477
);
478-
await callWithRequest('flowFramework.updateWorkflow', {
479-
workflow_id,
480-
// default update_fields to false if not explicitly set otherwise
481-
update_fields: update_fields,
482-
reprovision: reprovision,
483-
body: workflowTemplate,
484-
});
478+
if (reprovision) {
479+
await callWithRequest('flowFramework.updateAndReprovisionWorkflow', {
480+
workflow_id,
481+
// default update_fields to false if not explicitly set otherwise
482+
update_fields,
483+
body: workflowTemplate,
484+
});
485+
} else {
486+
await callWithRequest('flowFramework.updateWorkflow', {
487+
workflow_id,
488+
// default update_fields to false if not explicitly set otherwise
489+
update_fields,
490+
body: workflowTemplate,
491+
});
492+
}
485493

486494
return res.ok({ body: { workflowId: workflow_id, workflowTemplate } });
487495
} catch (err: any) {

0 commit comments

Comments
 (0)