From 639c9b7505020baf5dc5d31122d8924b301a77fc Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Fri, 22 Nov 2024 11:26:56 +0100 Subject: [PATCH] [ML] Trained Models: fix `NaN` in a progress bar during the download task initialization (#201221) ## Summary When we request a status of the download task right after initializing a download, `total_parts` might be returned with a `0` value, hence dividing by 0 for the progress bar causing in `NaN%` value rendered. This PR adds a fallback to `-1` for that, to make sure we render 0%. ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../ml/public/application/model_management/models_list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ml/public/application/model_management/models_list.tsx b/x-pack/plugins/ml/public/application/model_management/models_list.tsx index a717995d4ee14..d66ab1ab3db16 100644 --- a/x-pack/plugins/ml/public/application/model_management/models_list.tsx +++ b/x-pack/plugins/ml/public/application/model_management/models_list.tsx @@ -697,7 +697,7 @@ export const ModelsList: FC = ({ <> {downloadState ? ( - (downloadState.downloaded_parts / downloadState.total_parts) * + (downloadState.downloaded_parts / (downloadState.total_parts || -1)) * 100 ).toFixed(0) + '%' : '100%'}