From d5f9240bb81dcdc3c4a7bb75cca1d99286b2e706 Mon Sep 17 00:00:00 2001 From: Owais Kazi Date: Wed, 14 Feb 2024 22:59:07 -0800 Subject: [PATCH] Removed workflow-steps.json entries and the file completely Signed-off-by: Owais Kazi --- DEVELOPER_GUIDE.md | 2 +- .../workflow/WorkflowProcessSorter.java | 18 +- .../resources/mappings/workflow-steps.json | 183 ------------------ .../model/WorkflowValidatorTests.java | 3 +- 4 files changed, 4 insertions(+), 202 deletions(-) delete mode 100644 src/main/resources/mappings/workflow-steps.json diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index ad822dee2..7b76a7dfe 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -108,6 +108,6 @@ To add functionality to workflows, add new Workflow Steps to the [`org.opensearc 1. Implement the [Workflow](https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/workflow/WorkflowStep.java) interface. See existing steps for examples for input, output, and API execution. 2. Choose a unique name for the step which is not used by other steps. This will align with the `step_type` field in the templates and should be descriptive of what the step does. 3. Add a constructor and call it from the [WorkflowStepFactory](https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/workflow/WorkflowStepFactory.java). -4. Add a configuration to the [`workflow-steps.json`](https://github.com/dbwiddis/flow-framework/blob/main/src/main/resources/mappings/workflow-steps.json) file specifying required inputs, outputs, required plugins, and optionally a different timeout than the default. +4. Add an entry to the [WorkflowStepFactory](https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/workflow/WorkflowStepFactory.java) enum specifying required inputs, outputs, required plugins, and optionally a different timeout than the default. 5. If your step provisions a resource that should be deprovisioned, create the corresponding step and add both steps to the [`WorkflowResources`](https://github.com/opensearch-project/flow-framework/blob/main/src/main/java/org/opensearch/flowframework/common/WorkflowResources.java) enum. 6. Write unit and integration tests. diff --git a/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java b/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java index 8b61733ca..d6bae7411 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java +++ b/src/main/java/org/opensearch/flowframework/workflow/WorkflowProcessSorter.java @@ -19,7 +19,6 @@ import org.opensearch.flowframework.model.Workflow; import org.opensearch.flowframework.model.WorkflowEdge; import org.opensearch.flowframework.model.WorkflowNode; -import org.opensearch.flowframework.model.WorkflowValidator; import org.opensearch.plugins.PluginInfo; import org.opensearch.plugins.PluginsService; import org.opensearch.threadpool.ThreadPool; @@ -140,14 +139,13 @@ public List sortProcessNodes(Workflow workflow, String workflowId) * @throws Exception if validation fails */ public void validate(List processNodes, PluginsService pluginsService) throws Exception { - WorkflowValidator validator = readWorkflowValidator(); List installedPlugins = pluginsService.info() .getPluginInfos() .stream() .map(PluginInfo::getName) .collect(Collectors.toList()); validatePluginsInstalled(processNodes, installedPlugins); - validateGraph(processNodes, validator); + validateGraph(processNodes); } /** @@ -182,7 +180,7 @@ public void validatePluginsInstalled(List processNodes, List processNodes, WorkflowValidator validator) throws Exception { + public void validateGraph(List processNodes) throws Exception { // Iterate through process nodes in graph for (ProcessNode processNode : processNodes) { @@ -222,18 +220,6 @@ public void validateGraph(List processNodes, WorkflowValidator vali } } - private WorkflowValidator readWorkflowValidator() { - try { - return workflowStepFactory.getWorkflowValidator(); - } catch (Exception e) { - logger.error("Failed at reading workflow-steps mapping file", e); - throw new FlowFrameworkException( - "Failed at reading workflow-steps.json mapping file for a new workflow.", - RestStatus.INTERNAL_SERVER_ERROR - ); - } - } - /** * A method for parsing workflow timeout value. * The value could be parsed from node NODE_TIMEOUT_FIELD, the timeout field in workflow-step.json, diff --git a/src/main/resources/mappings/workflow-steps.json b/src/main/resources/mappings/workflow-steps.json deleted file mode 100644 index f1ff99de6..000000000 --- a/src/main/resources/mappings/workflow-steps.json +++ /dev/null @@ -1,183 +0,0 @@ -{ - "noop": { - "inputs":[], - "outputs":[], - "required_plugins":[] - }, - "create_connector": { - "inputs":[ - "name", - "description", - "version", - "protocol", - "parameters", - "credential", - "actions" - ], - "outputs":[ - "connector_id" - ], - "required_plugins":[ - "opensearch-ml" - ], - "timeout": "60s" - }, - "delete_connector": { - "inputs": [ - "connector_id" - ], - "outputs":[ - "connector_id" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "register_local_custom_model": { - "inputs":[ - "name", - "version", - "model_format", - "function_name", - "model_content_hash_value", - "url", - "model_type", - "embedding_dimension", - "framework_type" - ], - "outputs":[ - "model_id", - "register_model_status" - ], - "required_plugins":[ - "opensearch-ml" - ], - "timeout": "60s" - }, - "register_local_sparse_encoding_model": { - "inputs":[ - "name", - "version", - "model_format", - "function_name", - "model_content_hash_value", - "url" - ], - "outputs":[ - "model_id", - "register_model_status" - ], - "required_plugins":[ - "opensearch-ml" - ], - "timeout": "60s" - }, - "register_local_pretrained_model": { - "inputs":[ - "name", - "version", - "model_format" - ], - "outputs":[ - "model_id", - "register_model_status" - ], - "required_plugins":[ - "opensearch-ml" - ], - "timeout": "60s" - }, - "register_remote_model": { - "inputs": [ - "name", - "connector_id" - ], - "outputs": [ - "model_id", - "register_model_status" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "delete_model": { - "inputs": [ - "model_id" - ], - "outputs":[ - "model_id" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "deploy_model": { - "inputs":[ - "model_id" - ], - "outputs":[ - "deploy_model_status" - ], - "required_plugins":[ - "opensearch-ml" - ], - "timeout": "15s" - }, - "undeploy_model": { - "inputs":[ - "model_id" - ], - "outputs":[ - "success" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "register_model_group": { - "inputs":[ - "name" - ], - "outputs":[ - "model_group_id", - "model_group_status" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "register_agent": { - "inputs":[ - "name", - "type" - ], - "outputs":[ - "agent_id" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "delete_agent": { - "inputs": [ - "agent_id" - ], - "outputs":[ - "agent_id" - ], - "required_plugins":[ - "opensearch-ml" - ] - }, - "create_tool": { - "inputs": [ - "type" - ], - "outputs": [ - "tools" - ], - "required_plugins":[ - "opensearch-ml" - ] - } -} diff --git a/src/test/java/org/opensearch/flowframework/model/WorkflowValidatorTests.java b/src/test/java/org/opensearch/flowframework/model/WorkflowValidatorTests.java index 46f1e7950..bacdf3aa2 100644 --- a/src/test/java/org/opensearch/flowframework/model/WorkflowValidatorTests.java +++ b/src/test/java/org/opensearch/flowframework/model/WorkflowValidatorTests.java @@ -106,8 +106,7 @@ public void testWorkflowStepFactoryHasValidators() throws IOException { flowFrameworkSettings ); - // Read in workflow-steps.json - WorkflowValidator workflowValidator = WorkflowValidator.parse("mappings/workflow-steps.json"); + WorkflowValidator workflowValidator = workflowStepFactory.getWorkflowValidator(); // Get all workflow step validator types List registeredWorkflowValidatorTypes = new ArrayList(workflowValidator.getWorkflowStepValidators().keySet());