Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a noop workflow step to delete model group #376

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.opensearch.flowframework.workflow.CreateIngestPipelineStep;
import org.opensearch.flowframework.workflow.DeleteAgentStep;
import org.opensearch.flowframework.workflow.DeleteConnectorStep;
import org.opensearch.flowframework.workflow.DeleteModelGroupStep;
import org.opensearch.flowframework.workflow.DeleteModelStep;
import org.opensearch.flowframework.workflow.DeployModelStep;
import org.opensearch.flowframework.workflow.ModelGroupStep;
Expand All @@ -41,7 +42,7 @@ public enum WorkflowResources {
/** Workflow steps for registering/deleting a local model and associated created resource */
REGISTER_LOCAL_MODEL(RegisterLocalModelStep.NAME, WorkflowResources.MODEL_ID, DeleteModelStep.NAME),
/** Workflow steps for registering a model group and associated created resource */
REGISTER_MODEL_GROUP(ModelGroupStep.NAME, WorkflowResources.MODEL_GROUP_ID, null), // TODO delete step
REGISTER_MODEL_GROUP(ModelGroupStep.NAME, WorkflowResources.MODEL_GROUP_ID, DeleteModelGroupStep.NAME),
/** Workflow steps for deploying/undeploying a model and associated created resource */
DEPLOY_MODEL(DeployModelStep.NAME, WorkflowResources.MODEL_ID, UndeployModelStep.NAME),
/** Workflow steps for creating an ingest-pipeline and associated created resource */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.flowframework.workflow;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
* Step to delete a model group
*/
public class DeleteModelGroupStep implements WorkflowStep {

/** Instantiate this class */
public DeleteModelGroupStep() {}

/** The name of this step, used as a key in the template and the {@link WorkflowStepFactory} */
public static final String NAME = "delete_model_group";

@Override
public CompletableFuture<WorkflowData> execute(
String currentNodeId,
WorkflowData currentNodeInputs,
Map<String, WorkflowData> outputs,
Map<String, String> previousNodeInputs
) {
return CompletableFuture.completedFuture(WorkflowData.EMPTY);
}

@Override
public String getName() {
return NAME;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class ModelGroupStep implements WorkflowStep {
private final FlowFrameworkIndicesHandler flowFrameworkIndicesHandler;

/** The name of this step, used as a key in the template and the {@link WorkflowStepFactory} */
public static final String NAME = "register_model_group";
public static final String NAME = "model_group";

/**
* Instantiate this class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public WorkflowStepFactory(
stepMap.put(CreateConnectorStep.NAME, () -> new CreateConnectorStep(mlClient, flowFrameworkIndicesHandler));
stepMap.put(DeleteConnectorStep.NAME, () -> new DeleteConnectorStep(mlClient));
stepMap.put(ModelGroupStep.NAME, () -> new ModelGroupStep(mlClient, flowFrameworkIndicesHandler));
stepMap.put(DeleteModelGroupStep.NAME, DeleteModelGroupStep::new);
stepMap.put(ToolStep.NAME, ToolStep::new);
stepMap.put(RegisterAgentStep.NAME, () -> new RegisterAgentStep(mlClient, flowFrameworkIndicesHandler));
stepMap.put(DeleteAgentStep.NAME, () -> new DeleteAgentStep(mlClient));
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/mappings/workflow-steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"opensearch-ml"
]
},
"register_model_group": {
"model_group": {
"inputs":[
"name"
],
Expand All @@ -135,6 +135,11 @@
"opensearch-ml"
]
},
"delete_model_group": {
"inputs":[],
"outputs":[],
"required_plugins":[]
},
"register_agent": {
"inputs":[
"name",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.flowframework.workflow;

import org.opensearch.test.OpenSearchTestCase;

import java.io.IOException;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;

public class DeleteModelGroupTests extends OpenSearchTestCase {

public void testDeleteModelGroup() throws IOException {
DeleteModelGroupStep deleteModelGroupStep = new DeleteModelGroupStep();
assertEquals(DeleteModelGroupStep.NAME, deleteModelGroupStep.getName());
CompletableFuture<WorkflowData> future = deleteModelGroupStep.execute(
"nodeId",
WorkflowData.EMPTY,
Collections.emptyMap(),
Collections.emptyMap()
);
assertTrue(future.isDone());
assertFalse(future.isCompletedExceptionally());
}
}
Loading