[ML] Adds ability to deploy trained models for data frame analytics jobs (#162537)

## Summary

Related issue: https://github.com/elastic/kibana/issues/161026

This PR adds a 'Deploy model' action in Machine Learning > Model
Management > Trained models.

Action in list:
<img width="1392" alt="image"
src="65978519-a2c2-41ff-8709-9a868587c5af">

Details step:
<img width="1406" alt="image"
src="eba9ebf3-ab69-4e8e-9c02-120982d94373">

Configure processor:
<img width="1403" alt="image"
src="39ae977f-163f-4a86-9034-817abf123ac2">

Configure processor edit:
<img width="1394" alt="image"
src="8dcee306-baef-4871-8ca7-668c77fa95cb">

Configure processor additional:
<img width="1396" alt="image"
src="268c7cf8-19eb-4f29-afbb-8d5e8a0c8598">

Handle failures:
<img width="1310" alt="image"
src="a692c892-6730-4a93-8c27-2acc417505e1">

<img width="1310" alt="image"
src="37087120-b9e6-4399-a2ce-012a17d57a52">

<img width="1308" alt="image"
src="57d840a8-41bf-40ff-9702-39ca7facf610">

Test:
<img width="1397" alt="image"
src="2a07b358-1945-47c7-8ba3-82942f3cf359">

Create:
<img width="1404" alt="image"
src="8bd163b3-64df-4611-924e-06f0e8df1330">

Create success:
<img width="1404" alt="image"
src="be9c7732-9635-465f-9e03-28f11e157711">



### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] 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))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] 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))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Melissa Alvarez 2023-08-08 14:01:28 -04:00 committed by GitHub
parent c7053d4d4b
commit 327448b726
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 2651 additions and 4 deletions

View file

@ -6,6 +6,11 @@
*/
import type { IScopedClusterClient } from '@kbn/core/server';
import {
IngestPipeline,
IngestSimulateDocument,
IngestSimulateRequest,
} from '@elastic/elasticsearch/lib/api/types';
import type { PipelineDefinition } from '../../../common/types/trained_models';
export type ModelService = ReturnType<typeof modelsProvider>;
@ -64,5 +69,64 @@ export function modelsProvider(client: IScopedClusterClient) {
pipelinesIds.map((id) => client.asCurrentUser.ingest.deletePipeline({ id }))
);
},
/**
* Simulates the effect of the pipeline on given document.
*
*/
async simulatePipeline(docs: IngestSimulateDocument[], pipelineConfig: IngestPipeline) {
const simulateRequest: IngestSimulateRequest = {
docs,
pipeline: pipelineConfig,
};
let result = {};
try {
result = await client.asCurrentUser.ingest.simulate(simulateRequest);
} catch (error) {
if (error.statusCode === 404) {
// ES returns 404 when there are no pipelines
// Instead, we should return an empty response and a 200
return result;
}
throw error;
}
return result;
},
/**
* Creates the pipeline
*
*/
async createInferencePipeline(pipelineConfig: IngestPipeline, pipelineName: string) {
let result = {};
result = await client.asCurrentUser.ingest.putPipeline({
id: pipelineName,
...pipelineConfig,
});
return result;
},
/**
* Retrieves existing pipelines.
*
*/
async getPipelines() {
let result = {};
try {
result = await client.asCurrentUser.ingest.getPipeline();
} catch (error) {
if (error.statusCode === 404) {
// ES returns 404 when there are no pipelines
// Instead, we should return an empty response and a 200
return result;
}
throw error;
}
return result;
},
};
}