[ML] Trained Models: Prevents multiple clicks in Delete Model dialog#211580
[ML] Trained Models: Prevents multiple clicks in Delete Model dialog#211580rbrtj merged 14 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/ml-ui (:ml) |
| force: pipelinesCount > 0, | ||
| }) | ||
| .subscribe({ | ||
| next: () => { |
There was a problem hiding this comment.
I decided to keep the selection and the modal open if the deletion fails
x-pack/platform/plugins/shared/ml/common/types/trained_models.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/ml/public/application/model_management/delete_models_modal.tsx
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/ml/public/application/model_management/trained_models_service.ts
Outdated
Show resolved
Hide resolved
| public deleteModel(modelIds: string[], options: DeleteModelOptions) { | ||
| return of(modelIds).pipe( | ||
| tap(() => modelIds.forEach((modelId) => this.removeScheduledDeployments({ modelId }))), | ||
| switchMap(() => | ||
| forkJoin( | ||
| modelIds.map((modelId) => | ||
| from(this.trainedModelsApiService.deleteTrainedModel(modelId, options)) | ||
| ) | ||
| ) | ||
| ), | ||
| tap({ | ||
| next: () => this.fetchModels(), | ||
| error: (error) => { | ||
| this.displayErrorToast?.( | ||
| error, | ||
| i18n.translate('xpack.ml.trainedModels.modelsList.fetchDeletionErrorMessage', { | ||
| defaultMessage: '{modelsCount, plural, one {Model} other {Models}} deletion failed', | ||
| values: { | ||
| modelsCount: modelIds.length, | ||
| }, | ||
| }) | ||
| ); | ||
| this.fetchModels(); | ||
| }, | ||
| }) | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
What is the advantage of using RxJS in this case? Additionally, what is the reasoning behind moving this logic to the service?
There was a problem hiding this comment.
I wouldn't say there's much advantage, I just wanted to keep model actions within the trained models service, as it is currently responsible for downloading, updating, deploying... Additionally, it's quicker to unit test now since there are already existing tests for the service.
x-pack/platform/plugins/shared/ml/public/application/model_management/trained_models_service.ts
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/ml/public/application/model_management/delete_models_modal.tsx
Show resolved
Hide resolved
x-pack/platform/plugins/shared/ml/public/application/model_management/delete_models_modal.tsx
Outdated
Show resolved
Hide resolved
x-pack/platform/plugins/shared/ml/public/application/model_management/models_list.tsx
Show resolved
Hide resolved
| } | ||
|
|
||
| public async deleteModels(modelIds: string[], options: DeleteModelParams['options']) { | ||
| modelIds.forEach((modelId) => this.removeScheduledDeployments({ modelId })); |
There was a problem hiding this comment.
By calling removeScheduledDeployments up front for each model before deleting, you might end up in an unexpected state if one of the models fails to delete. I think it would be safer to call this inside the map below for each successful model deletion.
Also I think it might be safer to delete the models one at a time, so we can correctly report which models have failed to delete. I appreciate this will take longer to run compared to a Promise.all.
Alternatively It could still happen inside a Promise.all, but we catch and report the failure on a per model basis.
There was a problem hiding this comment.
Updated to use Promise.allSettled and correctly report which models have failed to delete.
d11b67c
darnautov
left a comment
There was a problem hiding this comment.
LGTM! Please check the error message text with István
| undefined, | ||
| i18n.translate('xpack.ml.trainedModels.modelsList.fetchDeletionErrorMessage', { | ||
| defaultMessage: | ||
| 'Failed to delete the following {count, plural, one {model} other {models}}: {modelIds}', |
There was a problem hiding this comment.
I wonder if we need such a long message a in the error toast. Would it be enough just to list the models? cc @szabosteve
There was a problem hiding this comment.
Yup, as the toast title already contains the main message – {modelsCount, plural, one {Model} other {Models}} deletion failed – just the list of models should be enough here.
💚 Build Succeeded
Metrics [docs]Async chunks
Public APIs missing exports
Page load bundle
History
cc @rbrtj |
|
Starting backport for target branches: 8.x |
…lastic#211580) Fix for elastic#210004 Additionally: * Prevents the deletion of already deployed models * Fixes a bug where, after selecting a model and deleting it from the selected models actions, the model remained selected (cherry picked from commit efcc63c)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…alog (#211580) (#212595) # Backport This will backport the following commits from `main` to `8.x`: - [[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (#211580)](#211580) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Robert Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-26T22:46:15Z","message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:3rd Party Models","Team:ML","backport:version","v9.1.0","v8.19.0"],"title":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog","number":211580,"url":"https://github.com/elastic/kibana/pull/211580","mergeCommit":{"message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211580","number":211580,"mergeCommit":{"message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
…lastic#211580) Fix for elastic#210004 Additionally: * Prevents the deletion of already deployed models * Fixes a bug where, after selecting a model and deleting it from the selected models actions, the model remained selected
…alog (elastic#211580) (elastic#212595) # Backport This will backport the following commits from `main` to `8.x`: - [[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (elastic#211580)](elastic#211580) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Robert Jaszczurek","email":"92210485+rbrtj@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-26T22:46:15Z","message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (elastic#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","Feature:3rd Party Models","Team:ML","backport:version","v9.1.0","v8.19.0"],"title":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog","number":211580,"url":"https://github.com/elastic/kibana/pull/211580","mergeCommit":{"message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (elastic#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211580","number":211580,"mergeCommit":{"message":"[ML] Trained Models: Prevent multiple clicks in Delete Model dialog (elastic#211580)\n\nFix for https://github.com/elastic/kibana/issues/210004\nAdditionally:\n* Prevents the deletion of already deployed models\n* Fixes a bug where, after selecting a model and deleting it from the\nselected models actions, the model remained selected","sha":"efcc63c01c626770d0b94cbf26c12d1852e61904"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Robert Jaszczurek <92210485+rbrtj@users.noreply.github.com>
…lastic#211580) Fix for elastic#210004 Additionally: * Prevents the deletion of already deployed models * Fixes a bug where, after selecting a model and deleting it from the selected models actions, the model remained selected

Fix for #210004
Additionally: