Skip to content

Commit

Permalink
[ML] Support multiple model deployments (#155375)
Browse files Browse the repository at this point in the history
## Summary

With elastic/elasticsearch#95168 it's possible
to provide an optional deployment ID for start, stop and infer.
elastic/elasticsearch#95440 also updated the
`_stats` API to provide state per deployment.

This PR update the Trained Models UI to support multiple model
deployments.

- Adds support for specifying deployment ID during the start model
deployment
<img width="1009" alt="image"
src="https://user-images.githubusercontent.com/5236598/234074150-bccf079f-7c46-4222-ab83-48369c4ce4c2.png">

-  Stopping specific deployments 
<img width="730" alt="image"
src="https://user-images.githubusercontent.com/5236598/234291886-9ee14a82-a324-4ce7-9db5-57ab912d0385.png">

- Specify the deployment ID for the Test model action 
<img width="600" alt="image"
src="https://user-images.githubusercontent.com/5236598/234074977-645d2e91-e291-4a27-b3ed-44be9ccbc005.png">

- Show deployment stats for every deployment 
<img width="1668" alt="image"
src="https://user-images.githubusercontent.com/5236598/234075620-da9190e1-c796-4df1-abf1-a130f04d90e0.png">

- Show pipelines with associated deployments 
<img width="1585" alt="image"
src="https://user-images.githubusercontent.com/5236598/234268631-79b4724c-e537-44da-9a30-5bdb1ea3ecb0.png">


### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [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
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)
  • Loading branch information
darnautov committed Apr 25, 2023
1 parent 6e85cd2 commit 609228b
Show file tree
Hide file tree
Showing 30 changed files with 644 additions and 286 deletions.
5 changes: 4 additions & 1 deletion x-pack/plugins/ml/common/types/trained_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface TrainedModelStat {
}
>;
};
deployment_stats?: Omit<TrainedModelDeploymentStatsResponse, 'model_id'>;
deployment_stats?: TrainedModelDeploymentStatsResponse;
model_size_stats?: TrainedModelModelSizeStats;
}

Expand Down Expand Up @@ -128,6 +128,7 @@ export interface InferenceConfigResponse {

export interface TrainedModelDeploymentStatsResponse {
model_id: string;
deployment_id: string;
inference_threads: number;
model_threads: number;
state: DeploymentState;
Expand Down Expand Up @@ -163,6 +164,8 @@ export interface TrainedModelDeploymentStatsResponse {
}

export interface AllocatedModel {
key: string;
deployment_id: string;
inference_threads: number;
allocation_status: {
target_allocation_count: number;
Expand Down
10 changes: 10 additions & 0 deletions x-pack/plugins/ml/common/util/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,13 @@ export function timeIntervalInputValidator() {
return null;
};
}

export function dictionaryValidator(dict: string[], shouldInclude: boolean = false) {
const dictSet = new Set(dict);
return (value: string) => {
if (dictSet.has(value) !== shouldInclude) {
return { matchDict: value };
}
return null;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
const euiTheme = useEuiTheme();

const columns: Array<EuiBasicTableColumn<AllocatedModel>> = [
{
id: 'deployment_id',
field: 'deployment_id',
name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.deploymentIdHeader', {
defaultMessage: 'ID',
}),
width: '150px',
sortable: true,
truncateText: false,
'data-test-subj': 'mlAllocatedModelsTableDeploymentId',
},
{
name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.modelRoutingStateHeader', {
defaultMessage: 'Routing state',
}),
width: '100px',
'data-test-subj': 'mlAllocatedModelsTableRoutingState',
render: (v: AllocatedModel) => {
const { routing_state: routingState, reason } = v.node.routing_state;

return (
<EuiToolTip content={reason ? reason : ''}>
<EuiBadge color={reason ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
</EuiToolTip>
);
},
},
{
id: 'node_name',
field: 'node.name',
Expand Down Expand Up @@ -193,22 +220,6 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
return v.node.number_of_pending_requests;
},
},
{
name: i18n.translate('xpack.ml.trainedModels.nodesList.modelsList.modelRoutingStateHeader', {
defaultMessage: 'Routing state',
}),
width: '100px',
'data-test-subj': 'mlAllocatedModelsTableRoutingState',
render: (v: AllocatedModel) => {
const { routing_state: routingState, reason } = v.node.routing_state;

return (
<EuiToolTip content={reason ? reason : ''}>
<EuiBadge color={reason ? 'danger' : 'hollow'}>{routingState}</EuiBadge>
</EuiToolTip>
);
},
},
].filter((v) => !hideColumns.includes(v.id!));

return (
Expand All @@ -219,7 +230,7 @@ export const AllocatedModels: FC<AllocatedModelsProps> = ({
isExpandable={false}
isSelectable={false}
items={models}
itemId={'model_id'}
itemId={'key'}
rowProps={(item) => ({
'data-test-subj': `mlAllocatedModelTableRow row-${item.model_id}`,
})}
Expand Down
Loading

0 comments on commit 609228b

Please sign in to comment.