[ML] Fix Allocation rendering for failed deployments (#174882)

## Summary

Fixes "Allocation" rendering for failed deployments of trained models.

_We should also update the type definition in elasticsearch
specification marking `number_of_allocations` and
`threads_per_allocation` as optional for [Get Trained Model
Stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-trained-models-stats.html)
endpoint._

#### How to reproduce
1. Start a model deployment 
2. Find a Process ID 
```
ps -ef | grep pytorch_inference
```
3. Kill the inference process manually 
```
kill -9 <PID>
```

Before:

![image](b89545a6-6216-4ac8-b0c3-f2b755a41179)

After: 
<img width="1732" alt="image"
src="be970ae8-f4a2-4b06-aff4-f27ce374178c">
This commit is contained in:
Dima Arnautov 2024-01-16 13:43:31 +01:00 committed by GitHub
parent 1172c0ec09
commit 2a61da251b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -203,8 +203,8 @@ export interface AllocatedModel {
number_of_pending_requests: number;
start_time: number;
throughput_last_minute: number;
number_of_allocations: number;
threads_per_allocation: number;
number_of_allocations?: number;
threads_per_allocation?: number;
error_count?: number;
};
}

View file

@ -118,6 +118,12 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
truncateText: false,
'data-test-subj': 'mlAllocatedModelsTableAllocation',
render: (v: AllocatedModel) => {
if (
v.node.number_of_allocations === undefined ||
v.node.threads_per_allocation === undefined
) {
return '-';
}
return `${v.node.number_of_allocations} * ${v.node.threads_per_allocation}`;
},
},