diff --git a/api/turing/api/ensemblers_api.go b/api/turing/api/ensemblers_api.go index aacd7aec9..5de348504 100644 --- a/api/turing/api/ensemblers_api.go +++ b/api/turing/api/ensemblers_api.go @@ -255,6 +255,11 @@ func (c EnsemblersController) checkCurrentRouterVersion(options EnsemblersPathOp } func (c EnsemblersController) checkActiveEnsemblingJob(options EnsemblersPathOptions) (int, error) { + // Batch ensembling is not enabled + if c.EnsemblingJobService == nil { + return http.StatusOK, nil + } + ensemblingJobActiveOption := service.EnsemblingJobListOptions{ EnsemblerID: options.EnsemblerID, Statuses: []models.Status{ @@ -298,6 +303,11 @@ func (c EnsemblersController) deleteInactiveRouterVersion(options EnsemblersPath return http.StatusOK, nil } func (c EnsemblersController) deleteInactiveEnsemblingJob(options EnsemblersPathOptions) (int, error) { + // Batch ensembling is not enabled + if c.EnsemblingJobService == nil { + return http.StatusOK, nil + } + ensemblingJobInactiveOption := service.EnsemblingJobListOptions{ EnsemblerID: options.EnsemblerID, Statuses: []models.Status{ diff --git a/api/turing/api/ensemblers_api_test.go b/api/turing/api/ensemblers_api_test.go index 88e69995c..6766ac66f 100644 --- a/api/turing/api/ensemblers_api_test.go +++ b/api/turing/api/ensemblers_api_test.go @@ -889,6 +889,36 @@ func TestEnsemblerController_DeleteEnsembler(t *testing.T) { }, expected: InternalServerError("failed to delete the ensembler", "failed to delete"), }, + "success | batch ensembling is not enabled": { + vars: RequestVars{ + "project_id": {"2"}, + "ensembler_id": {"2"}, + }, + ensemblerSvc: func() service.EnsemblersService { + ensemblerSvc := &mocks.EnsemblersService{} + ensemblerSvc. + On("FindByID", models.ID(2), service.EnsemblersFindByIDOptions{ + ProjectID: models.NewID(2), + }). + Return(original, nil) + ensemblerSvc. + On("Delete", original). + Return(nil) + return ensemblerSvc + }, + routerVersionsSvc: func() service.RouterVersionsService { + routerVersionSvc := &mocks.RouterVersionsService{} + routerVersionSvc.On("ListRouterVersionsWithFilter", mock.Anything).Return([]*models.RouterVersion{}, nil) + + return routerVersionSvc + }, + mlflowSvc: func() mlflow.Service { + mlflowSvc := &mlflowMock.Service{} + mlflowSvc.On("DeleteExperiment", mock.Anything, "1", true).Return(nil) + return mlflowSvc + }, + expected: Ok(models.ID(2)), + }, "success": { vars: RequestVars{ "project_id": {"2"}, @@ -951,7 +981,7 @@ func TestEnsemblerController_DeleteEnsembler(t *testing.T) { ensemblingJobSvc = tt.ensemblingJobSvc() } var routerVersionsSvc service.RouterVersionsService - if tt.ensemblingJobSvc != nil { + if tt.routerVersionsSvc != nil { routerVersionsSvc = tt.routerVersionsSvc() } diff --git a/ui/src/ensembler/components/modal/DeleteEnsemblerModal.js b/ui/src/ensembler/components/modal/DeleteEnsemblerModal.js index f3cd7d068..277be5962 100644 --- a/ui/src/ensembler/components/modal/DeleteEnsemblerModal.js +++ b/ui/src/ensembler/components/modal/DeleteEnsemblerModal.js @@ -7,6 +7,7 @@ import { isEmpty } from "../../../utils/object"; import { ListEnsemblingJobsForEnsemblerTable } from "../table/ListEnsemblingJobsForEnsemblerTable"; import { ListRouterVersionsForEnsemblerTable } from "../table/ListRouterVersionsForEnsemblerTable"; import { EuiFieldText } from "@elastic/eui"; +import {useConfig} from "../../../config"; export const DeleteEnsemblerModal = ({ onSuccess, @@ -23,6 +24,10 @@ export const DeleteEnsemblerModal = ({ const [deleteConfirmation, setDeleteConfirmation] = useState('') const [ensembler = {}, openModal, closeModal] = useEnsemblerModal(closeModalRef); + const { + appConfig: { batchEnsemblingEnabled }, + } = useConfig(); + useEffect(() => { // if ensembler is used by one of the component, immediately set can delete ensembler to false setCanDeleteEnsembler(!(ensemblerUsedByActiveEnsemblingJob || ensemblerUsedByActiveRouterVersion || ensemblerUsedByCurrentRouterVersion)) @@ -93,7 +98,7 @@ export const DeleteEnsemblerModal = ({ )} {/* Only show The Ensembling Table if ensembler is not used by current router version */} - {!ensemblerUsedByCurrentRouterVersion && ( + {!ensemblerUsedByCurrentRouterVersion && batchEnsemblingEnabled && (