-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Fixes display of model state in trained models list with startin…
…g and stopping deployments (#188847) ## Summary Fixes #188035 and #181093 <img width="1434" alt="image" src="https://github.com/user-attachments/assets/6c14afa3-2908-45ff-a68d-88ee18f18964"> ### Checklist - [x] [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
Showing
4 changed files
with
158 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
x-pack/plugins/ml/public/application/model_management/get_model_state.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getModelDeploymentState } from './get_model_state'; | ||
import { MODEL_STATE } from '@kbn/ml-trained-models-utils'; | ||
import type { ModelItem } from './models_list'; | ||
|
||
describe('getModelDeploymentState', () => { | ||
it('returns STARTED if any deployment is in STARTED state', () => { | ||
const model = { | ||
stats: { | ||
model_id: '.elser_model_2', | ||
model_size_stats: { | ||
model_size_bytes: 438123914, | ||
required_native_memory_bytes: 2101346304, | ||
}, | ||
|
||
deployment_stats: [ | ||
{ | ||
deployment_id: '.elser_model_2_01', | ||
model_id: '.elser_model_2', | ||
state: 'starting', | ||
}, | ||
{ | ||
deployment_id: '.elser_model_2', | ||
model_id: '.elser_model_2', | ||
state: 'started', | ||
allocation_status: { | ||
allocation_count: 1, | ||
target_allocation_count: 1, | ||
state: 'fully_allocated', | ||
}, | ||
}, | ||
], | ||
}, | ||
} as unknown as ModelItem; | ||
const result = getModelDeploymentState(model); | ||
expect(result).toEqual(MODEL_STATE.STARTED); | ||
}); | ||
|
||
it('returns MODEL_STATE.STARTING if any deployment is in STARTING state', () => { | ||
const model = { | ||
stats: { | ||
model_id: '.elser_model_2', | ||
model_size_stats: { | ||
model_size_bytes: 438123914, | ||
required_native_memory_bytes: 2101346304, | ||
}, | ||
|
||
deployment_stats: [ | ||
{ | ||
deployment_id: '.elser_model_2', | ||
model_id: '.elser_model_2', | ||
state: 'stopping', | ||
}, | ||
{ | ||
deployment_id: '.elser_model_2_01', | ||
model_id: '.elser_model_2', | ||
state: 'starting', | ||
}, | ||
{ | ||
deployment_id: '.elser_model_2', | ||
model_id: '.elser_model_2', | ||
state: 'stopping', | ||
}, | ||
], | ||
}, | ||
} as unknown as ModelItem; | ||
const result = getModelDeploymentState(model); | ||
expect(result).toEqual(MODEL_STATE.STARTING); | ||
}); | ||
|
||
it('returns MODEL_STATE.STOPPING if every deployment is in STOPPING state', () => { | ||
const model = { | ||
stats: { | ||
model_id: '.elser_model_2', | ||
model_size_stats: { | ||
model_size_bytes: 438123914, | ||
required_native_memory_bytes: 2101346304, | ||
}, | ||
|
||
deployment_stats: [ | ||
{ | ||
deployment_id: '.elser_model_2', | ||
model_id: '.elser_model_2', | ||
state: 'stopping', | ||
}, | ||
{ | ||
deployment_id: '.elser_model_2_01', | ||
model_id: '.elser_model_2', | ||
state: 'stopping', | ||
}, | ||
], | ||
}, | ||
} as unknown as ModelItem; | ||
const result = getModelDeploymentState(model); | ||
expect(result).toEqual(MODEL_STATE.STOPPING); | ||
}); | ||
|
||
it('returns undefined for empty deployment stats', () => { | ||
const model = { | ||
stats: { | ||
model_id: '.elser_model_2', | ||
model_size_stats: { | ||
model_size_bytes: 438123914, | ||
required_native_memory_bytes: 2101346304, | ||
}, | ||
|
||
deployment_stats: [], | ||
}, | ||
} as unknown as ModelItem; | ||
const result = getModelDeploymentState(model); | ||
expect(result).toEqual(undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters