Skip to content

[ML] Trained Models: Prevents multiple clicks in Delete Model dialog#211580

Merged
rbrtj merged 14 commits intoelastic:mainfrom
rbrtj:ml-delete-model-dialog-allows-multiple-clicks
Feb 26, 2025
Merged

[ML] Trained Models: Prevents multiple clicks in Delete Model dialog#211580
rbrtj merged 14 commits intoelastic:mainfrom
rbrtj:ml-delete-model-dialog-allows-multiple-clicks

Conversation

@rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Feb 18, 2025

Fix for #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
@rbrtj rbrtj added release_note:fix :ml Feature:3rd Party Models ML 3rd party models Team:ML Team label for ML (also use :ml) t// backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Feb 18, 2025
@rbrtj rbrtj self-assigned this Feb 18, 2025
@rbrtj rbrtj requested a review from a team as a code owner February 18, 2025 14:15
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@rbrtj rbrtj requested a review from darnautov February 18, 2025 14:15
force: pipelinesCount > 0,
})
.subscribe({
next: () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to keep the selection and the modal open if the deletion fails

Comment on lines 221 to 248
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();
},
})
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the advantage of using RxJS in this case? Additionally, what is the reasoning behind moving this logic to the service?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rbrtj rbrtj requested a review from darnautov February 20, 2025 12:58
@rbrtj rbrtj requested a review from darnautov February 21, 2025 11:05
}

public async deleteModels(modelIds: string[], options: DeleteModelParams['options']) {
modelIds.forEach((modelId) => this.removeScheduledDeployments({ modelId }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use Promise.allSettled and correctly report which models have failed to delete.
d11b67c

@rbrtj rbrtj requested a review from darnautov February 21, 2025 16:05
@rbrtj rbrtj requested a review from jgowdyelastic February 21, 2025 16:05
Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in: f5d1140
image

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 5.2MB 5.2MB +932.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
ml 105 106 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 77.2KB 77.3KB +18.0B

History

cc @rbrtj

@rbrtj rbrtj merged commit efcc63c into elastic:main Feb 26, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13554876589

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 26, 2025
…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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 27, 2025
…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>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Feb 27, 2025
…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
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Mar 4, 2025
…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>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…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
@nastasha-solomon nastasha-solomon changed the title [ML] Trained Models: Prevent multiple clicks in Delete Model dialog Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels Feature:3rd Party Models ML 3rd party models :ml release_note:fix Team:ML Team label for ML (also use :ml) t// v8.19.0 v9.1.0

6 participants