Skip to content

Commit

Permalink
[ML] Trained Models: fix NaN in a progress bar during the download …
Browse files Browse the repository at this point in the history
…task initialization (elastic#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
  • Loading branch information
darnautov authored and paulinashakirova committed Nov 26, 2024
1 parent 252a2dd commit e722ef9
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ export const ModelsList: FC<Props> = ({
<>
{downloadState
? (
(downloadState.downloaded_parts / downloadState.total_parts) *
(downloadState.downloaded_parts / (downloadState.total_parts || -1)) *
100
).toFixed(0) + '%'
: '100%'}
Expand Down

0 comments on commit e722ef9

Please sign in to comment.