Skip to content

Commit

Permalink
[8.16] [ML] Trained Models: Show deployment stats for unallocated dep…
Browse files Browse the repository at this point in the history
…loyments (#202005) (#202166)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[ML] Trained Models: Show deployment stats for unallocated
deployments (#202005)](#202005)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dima
Arnautov","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-28T13:22:31Z","message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Feature:3rd
Party
Models","Team:ML","ci:cloud-deploy","backport:version","v8.17.0","v8.18.0","v8.16.2"],"title":"[ML]
Trained Models: Show deployment stats for unallocated deployments
","number":202005,"url":"https://github.com/elastic/kibana/pull/202005","mergeCommit":{"message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x","8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202005","number":202005,"mergeCommit":{"message":"[ML]
Trained Models: Show deployment stats for unallocated deployments
(#202005)\n\n## Summary\r\n\r\nFixes #201930 \r\n\r\nShow deployment on
the Deployent stats table even if it hasn't been\r\nallocated to any
node yet.\r\n\r\n\r\n<img width=\"875\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/858041fd-16d4-44f3-8d13-1ad45550452e\">","sha":"c06adbc8ec55cb211aba6a154f8d740b25c2b9c0"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Dima Arnautov <[email protected]>
  • Loading branch information
kibanamachine and darnautov authored Nov 28, 2024
1 parent 3e98d3f commit 2e1ed36
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/ml/common/types/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export interface AllocatedModel {
*/
model_id?: string;
state: string;
reason?: string;
model_size_bytes: number;
required_native_memory_bytes: number;
node: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
{
width: '8%',
name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.modelRoutingStateHeader', {
defaultMessage: 'Routing state',
defaultMessage: 'State',
}),
'data-test-subj': 'mlAllocatedModelsTableRoutingState',
render: (v: AllocatedModel) => {
const { routing_state: routingState, reason } = v.node.routing_state;

const isFailed = routingState === 'failed';

return (
<EuiToolTip content={reason ? reason : ''}>
<EuiBadge color={reason ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
<EuiBadge color={isFailed ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
</EuiToolTip>
);
},
Expand Down Expand Up @@ -252,7 +254,7 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
}),
'data-test-subj': 'mlAllocatedModelsTableStartedTime',
render: (v: AllocatedModel) => {
return dateFormatter(v.node.start_time);
return v.node.start_time ? dateFormatter(v.node.start_time) : '-';
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,40 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
license_level,
]);

const deploymentStatItems: AllocatedModel[] = useMemo<AllocatedModel[]>(() => {
const deploymentStatItems = useMemo<AllocatedModel[]>(() => {
const deploymentStats = stats.deployment_stats;
const modelSizeStats = stats.model_size_stats;

if (!deploymentStats || !modelSizeStats) return [];

const items: AllocatedModel[] = deploymentStats.flatMap((perDeploymentStat) => {
return deploymentStats.flatMap((perDeploymentStat) => {
// A deployment can be in a starting state and not allocated to any node yet.
if (perDeploymentStat.nodes.length < 1) {
return [
{
key: `${perDeploymentStat.deployment_id}_no_node`,
...perDeploymentStat,
...modelSizeStats,
node: {
name: '-',
average_inference_time_ms: 0,
inference_count: 0,
routing_state: {
routing_state: perDeploymentStat.state,
reason: perDeploymentStat.reason,
},
last_access: 0,
number_of_pending_requests: 0,
start_time: 0,
throughput_last_minute: 0,
number_of_allocations: 0,
threads_per_allocation: 0,
error_count: 0,
},
},
];
}

return perDeploymentStat.nodes.map((n) => {
const nodeName = Object.values(n.node)[0].name;
return {
Expand All @@ -200,8 +227,6 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
};
});
});

return items;
}, [stats]);

const hideColumns = useMemo(() => {
Expand Down

0 comments on commit 2e1ed36

Please sign in to comment.