-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up conversion between UI flow and template sub-workflows
Signed-off-by: Tyler Ohlsen <[email protected]>
- Loading branch information
Showing
6 changed files
with
112 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
WorkspaceFlowState, | ||
ReactFlowComponent, | ||
initComponentData, | ||
TextEmbeddingTransformer, | ||
KnnIndexer, | ||
generateId, | ||
ReactFlowEdge, | ||
TemplateFlows, | ||
} from './'; | ||
|
||
// TODO: implement this and remove hardcoded return values | ||
/** | ||
* Converts a ReactFlow workspace flow to a backend-compatible set of ingest and/or search sub-workflows, | ||
* along with a provision sub-workflow if resources are to be created. | ||
*/ | ||
export function toTemplateFlows( | ||
workspaceFlow: WorkspaceFlowState | ||
): TemplateFlows { | ||
return { | ||
provision: { | ||
user_params: {} as Map<string, any>, | ||
nodes: [], | ||
edges: [], | ||
}, | ||
}; | ||
} | ||
|
||
// TODO: implement this and remove hardcoded return values | ||
/** | ||
* Converts a backend set of provision/ingest/search sub-workflows into a UI-compatible set of | ||
* ReactFlow nodes and edges | ||
*/ | ||
export function toWorkspaceFlow( | ||
templateFlows: TemplateFlows | ||
): WorkspaceFlowState { | ||
const id1 = generateId('text_embedding_processor'); | ||
const id2 = generateId('text_embedding_processor'); | ||
const id3 = generateId('knn_index'); | ||
const dummyNodes = [ | ||
{ | ||
id: id1, | ||
position: { x: 0, y: 500 }, | ||
data: initComponentData(new TextEmbeddingTransformer().toObj(), id1), | ||
type: 'customComponent', | ||
}, | ||
{ | ||
id: id2, | ||
position: { x: 0, y: 200 }, | ||
data: initComponentData(new TextEmbeddingTransformer().toObj(), id2), | ||
type: 'customComponent', | ||
}, | ||
{ | ||
id: id3, | ||
position: { x: 500, y: 500 }, | ||
data: initComponentData(new KnnIndexer().toObj(), id3), | ||
type: 'customComponent', | ||
}, | ||
] as ReactFlowComponent[]; | ||
|
||
return { | ||
nodes: dummyNodes, | ||
edges: [] as ReactFlowEdge[], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters