Skip to content

Commit

Permalink
Removed workflow-steps.json entries and the file completely
Browse files Browse the repository at this point in the history
Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
  • Loading branch information
owaiskazi19 committed Feb 15, 2024
1 parent dd3e118 commit d5f9240
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 202 deletions.
2 changes: 1 addition & 1 deletion DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,14 +139,13 @@ public List<ProcessNode> sortProcessNodes(Workflow workflow, String workflowId)
* @throws Exception if validation fails
*/
public void validate(List<ProcessNode> processNodes, PluginsService pluginsService) throws Exception {
WorkflowValidator validator = readWorkflowValidator();
List<String> installedPlugins = pluginsService.info()
.getPluginInfos()
.stream()
.map(PluginInfo::getName)
.collect(Collectors.toList());
validatePluginsInstalled(processNodes, installedPlugins);
validateGraph(processNodes, validator);
validateGraph(processNodes);
}

/**
Expand Down Expand Up @@ -182,7 +180,7 @@ public void validatePluginsInstalled(List<ProcessNode> processNodes, List<String
* @param validator The validation definitions for the workflow steps
* @throws Exception on validation failure
*/
public void validateGraph(List<ProcessNode> processNodes, WorkflowValidator validator) throws Exception {
public void validateGraph(List<ProcessNode> processNodes) throws Exception {

// Iterate through process nodes in graph
for (ProcessNode processNode : processNodes) {
Expand Down Expand Up @@ -222,18 +220,6 @@ public void validateGraph(List<ProcessNode> 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,
Expand Down
183 changes: 0 additions & 183 deletions src/main/resources/mappings/workflow-steps.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<String> registeredWorkflowValidatorTypes = new ArrayList<String>(workflowValidator.getWorkflowStepValidators().keySet());
Expand Down

0 comments on commit d5f9240

Please sign in to comment.