[8.12] [ML] Sharing install elastic model service (#171918) (#173729)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[ML] Sharing install elastic model service
(#171918)](https://github.com/elastic/kibana/pull/171918)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"James
Gowdy","email":"jgowdy@elastic.co"},"sourceCommit":{"committedDate":"2023-12-20T12:00:55Z","message":"[ML]
Sharing install elastic model service (#171918)\n\nShares our
[recently\r\nadded](https://github.com/elastic/kibana/pull/169939)
install elastic\r\nmodel endpoint as a shared
service.","sha":"6a43e94e6c3de4378c583a266611f30049332662","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement",":ml","Feature:3rd
Party
Models","v8.12.0","v8.13.0"],"number":171918,"url":"https://github.com/elastic/kibana/pull/171918","mergeCommit":{"message":"[ML]
Sharing install elastic model service (#171918)\n\nShares our
[recently\r\nadded](https://github.com/elastic/kibana/pull/169939)
install elastic\r\nmodel endpoint as a shared
service.","sha":"6a43e94e6c3de4378c583a266611f30049332662"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/171918","number":171918,"mergeCommit":{"message":"[ML]
Sharing install elastic model service (#171918)\n\nShares our
[recently\r\nadded](https://github.com/elastic/kibana/pull/169939)
install elastic\r\nmodel endpoint as a shared
service.","sha":"6a43e94e6c3de4378c583a266611f30049332662"}}]}]
BACKPORT-->

Co-authored-by: James Gowdy <jgowdy@elastic.co>
This commit is contained in:
Kibana Machine 2023-12-20 08:19:36 -05:00 committed by GitHub
parent f4d642d472
commit afc7e7a62d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -18,6 +18,7 @@ const trainedModelsServiceMock = {
putTrainedModel: jest.fn(),
getELSER: jest.fn().mockResolvedValue({ model_id: '.elser_model_2' }),
getCuratedModelConfig: jest.fn().mockResolvedValue({ model_id: '.elser_model_2' }),
installElasticModel: jest.fn(),
} as jest.Mocked<TrainedModels>;
export const createTrainedModelsProviderMock = () =>

View file

@ -53,6 +53,7 @@ export interface TrainedModelsProvider {
): Promise<estypes.MlPutTrainedModelResponse>;
getELSER(params?: GetModelDownloadConfigOptions): Promise<ModelDefinitionResponse>;
getCuratedModelConfig(...params: GetCuratedModelConfigParams): Promise<ModelDefinitionResponse>;
installElasticModel(modelId: string): Promise<estypes.MlTrainedModelConfig>;
};
}
@ -144,6 +145,17 @@ export function getTrainedModelsProvider(
return modelsProvider(scopedClient, mlClient, cloud).getCuratedModelConfig(...params);
});
},
async installElasticModel(modelId: string) {
return await guards
.isFullLicense()
.hasMlCapabilities(['canGetTrainedModels'])
.ok(async ({ scopedClient, mlClient, mlSavedObjectService }) => {
return modelsProvider(scopedClient, mlClient, cloud).installElasticModel(
modelId,
mlSavedObjectService
);
});
},
};
},
};