Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Inference models management #74978

Merged
merged 37 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e796419
[ML] init tabs
darnautov Aug 11, 2020
02e17b3
[ML] init inference API service in UI
darnautov Aug 12, 2020
6620328
[ML] server-side routes
darnautov Aug 12, 2020
646ef99
[ML] basic table
darnautov Aug 12, 2020
c5a56ca
[ML] support deletion
darnautov Aug 13, 2020
3801a38
[ML] delete multiple models
darnautov Aug 13, 2020
dd2f28c
[ML] WIP expanded row
darnautov Aug 13, 2020
96e6919
[ML] fix types
darnautov Aug 13, 2020
976b46a
[ML] expanded row
darnautov Aug 13, 2020
043f4f2
[ML] fix types
darnautov Aug 13, 2020
4c04e6b
[ML] fix i18n id
darnautov Aug 14, 2020
5c4dcc4
[ML] change server-side permission check
darnautov Aug 14, 2020
d6123a3
[ML] refactor types
darnautov Aug 14, 2020
4ce85fb
[ML] show success toast on model deletion, fix models counter
darnautov Aug 14, 2020
41a8a10
[ML] update expanded row
darnautov Aug 14, 2020
77ba463
[ML] pipelines stats
darnautov Aug 14, 2020
72da967
[ML] use refresh observable
darnautov Aug 14, 2020
43f320d
[ML] endpoint to fetch associated pipelines
darnautov Aug 14, 2020
5b12bfd
[ML] update the endpoint to fetch associated pipelines
darnautov Aug 17, 2020
14f8d7b
[ML] show pipelines definition in expanded row
darnautov Aug 17, 2020
3e6f2ec
[ML] change stats layout
darnautov Aug 17, 2020
36182a0
[ML] fix headers
darnautov Aug 17, 2020
4eab787
[ML] change breadcrumb title
darnautov Aug 17, 2020
98e3751
Merge remote-tracking branch 'upstream/master' into ML-model-management
darnautov Aug 17, 2020
a41209f
[ML] fetch models config with pipelines
darnautov Aug 17, 2020
19d5e5c
[ML] change default size to 1000
darnautov Aug 17, 2020
2fde1ad
[ML] fix collections keys, fix double fetch on initial page load
darnautov Aug 18, 2020
4fdf6b7
[ML] adjust models deletion text
darnautov Aug 18, 2020
e5e10d1
[ML] fix DFA jobs on the management page
darnautov Aug 18, 2020
0b63d74
[ML] small tabs in expanded row
darnautov Aug 18, 2020
54ced0c
[ML] fix headers text
darnautov Aug 18, 2020
6f546b8
[ML] fix models fetching without pipelines get permissions
darnautov Aug 18, 2020
1a7fe35
[ML] stats rendering as a description list
darnautov Aug 18, 2020
a7e21c0
[ML] fix i18n id
darnautov Aug 18, 2020
06e4534
Merge remote-tracking branch 'upstream/master' into ML-model-management
darnautov Aug 18, 2020
e8a46b3
[ML] remove an extra copyright comment, add selectable messages
darnautov Aug 19, 2020
5985295
[ML] update stats on refresh
darnautov Aug 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions x-pack/plugins/ml/common/types/data_frame_analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,77 @@
*/

import { CustomHttpResponseOptions, ResponseError } from 'kibana/server';

export interface DeleteDataFrameAnalyticsWithIndexStatus {
success: boolean;
error?: CustomHttpResponseOptions<ResponseError>;
}

export type IndexName = string;
export type DataFrameAnalyticsId = string;

export interface OutlierAnalysis {
[key: string]: {};

outlier_detection: {};
}

interface Regression {
dependent_variable: string;
training_percent?: number;
num_top_feature_importance_values?: number;
prediction_field_name?: string;
}

interface Classification {
dependent_variable: string;
training_percent?: number;
num_top_classes?: string;
num_top_feature_importance_values?: number;
prediction_field_name?: string;
}

export interface RegressionAnalysis {
[key: string]: Regression;

regression: Regression;
}

export interface ClassificationAnalysis {
[key: string]: Classification;

classification: Classification;
}

interface GenericAnalysis {
[key: string]: Record<string, any>;
}

export type AnalysisConfig =
| OutlierAnalysis
| RegressionAnalysis
| ClassificationAnalysis
| GenericAnalysis;

export interface DataFrameAnalyticsConfig {
id: DataFrameAnalyticsId;
description?: string;
dest: {
index: IndexName;
results_field: string;
};
source: {
index: IndexName | IndexName[];
query?: any;
};
analysis: AnalysisConfig;
analyzed_fields: {
includes: string[];
excludes: string[];
};
model_memory_limit: string;
max_num_threads?: number;
create_time: number;
version: string;
allow_lazy_start?: boolean;
}
81 changes: 81 additions & 0 deletions x-pack/plugins/ml/common/types/inference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { DataFrameAnalyticsConfig } from './data_frame_analytics';

export interface IngestStats {
count: number;
time_in_millis: number;
current: number;
failed: number;
}

export interface TrainedModelStat {
model_id: string;
pipeline_count: number;
inference_stats?: {
failure_count: number;
inference_count: number;
cache_miss_count: number;
missing_all_fields_count: number;
timestamp: number;
};
ingest?: {
total: IngestStats;
pipelines: Record<
string,
IngestStats & {
processors: Array<
Record<
string,
{
// TODO use type from ingest_pipelines plugin
type: string;
stats: IngestStats;
}
>
>;
}
>;
};
}

export interface ModelConfigResponse {
created_by: string;
create_time: string;
default_field_map: Record<string, string>;
estimated_heap_memory_usage_bytes: number;
estimated_operations: number;
license_level: string;
metadata?:
| {
analytics_config: DataFrameAnalyticsConfig;
input: any;
}
| Record<string, any>;
model_id: string;
tags: string;
version: string;
inference_config?: Record<string, any>;
pipelines?: Record<string, PipelineDefinition> | null;
}

export interface PipelineDefinition {
processors?: Array<Record<string, any>>;
description?: string;
}

export interface ModelPipelines {
model_id: string;
pipelines: Record<string, PipelineDefinition>;
}

/**
* Get inference response from the ES endpoint
*/
export interface InferenceConfigResponse {
trained_model_configs: ModelConfigResponse[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { StatsBar, AnalyticStatsBarStats, JobStatsBarStats } from './stats_bar';
export { StatsBar, AnalyticStatsBarStats, JobStatsBarStats, ModelsBarStats } from './stats_bar';
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ export interface AnalyticStatsBarStats extends Stats {
stopped: StatsBarStat;
}

export type StatsBarStats = JobStatsBarStats | AnalyticStatsBarStats;
export interface ModelsBarStats {
total: StatsBarStat;
}

export type StatsBarStats = JobStatsBarStats | AnalyticStatsBarStats | ModelsBarStats;
type StatsKey = keyof StatsBarStats;

interface StatsBarProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
*/

import { useEffect } from 'react';
import { BehaviorSubject } from 'rxjs';
import { filter, distinctUntilChanged } from 'rxjs/operators';
import { Subscription } from 'rxjs';
import { BehaviorSubject, Subscription } from 'rxjs';
import { distinctUntilChanged, filter } from 'rxjs/operators';
import { cloneDeep } from 'lodash';
import { ml } from '../../services/ml_api_service';
import { Dictionary } from '../../../../common/types/common';
import { getErrorMessage } from '../../../../common/util/errors';
import { SavedSearchQuery } from '../../contexts/ml';
import {
AnalysisConfig,
ClassificationAnalysis,
OutlierAnalysis,
RegressionAnalysis,
} from '../../../../common/types/data_frame_analytics';

export type IndexName = string;
export type IndexPattern = string;
export type DataFrameAnalyticsId = string;

export enum ANALYSIS_CONFIG_TYPE {
OUTLIER_DETECTION = 'outlier_detection',
Expand Down Expand Up @@ -46,34 +49,6 @@ export enum OUTLIER_ANALYSIS_METHOD {
DISTANCE_KNN = 'distance_knn',
}

interface OutlierAnalysis {
[key: string]: {};
outlier_detection: {};
}

interface Regression {
dependent_variable: string;
training_percent?: number;
num_top_feature_importance_values?: number;
prediction_field_name?: string;
}
export interface RegressionAnalysis {
[key: string]: Regression;
regression: Regression;
}

interface Classification {
dependent_variable: string;
training_percent?: number;
num_top_classes?: string;
num_top_feature_importance_values?: number;
prediction_field_name?: string;
}
export interface ClassificationAnalysis {
[key: string]: Classification;
classification: Classification;
}

export interface LoadExploreDataArg {
filterByIsTraining?: boolean;
searchQuery: SavedSearchQuery;
Expand Down Expand Up @@ -165,22 +140,12 @@ export interface ClassificationEvaluateResponse {
};
}

interface GenericAnalysis {
[key: string]: Record<string, any>;
}

interface LoadEvaluateResult {
success: boolean;
eval: RegressionEvaluateResponse | ClassificationEvaluateResponse | null;
error: string | null;
}

type AnalysisConfig =
| OutlierAnalysis
| RegressionAnalysis
| ClassificationAnalysis
| GenericAnalysis;

export const getAnalysisType = (analysis: AnalysisConfig): string => {
const keys = Object.keys(analysis);

Expand Down Expand Up @@ -342,29 +307,6 @@ export interface UpdateDataFrameAnalyticsConfig {
max_num_threads?: number;
}

export interface DataFrameAnalyticsConfig {
id: DataFrameAnalyticsId;
description?: string;
dest: {
index: IndexName;
results_field: string;
};
source: {
index: IndexName | IndexName[];
query?: any;
};
analysis: AnalysisConfig;
analyzed_fields: {
includes: string[];
excludes: string[];
};
model_memory_limit: string;
max_num_threads?: number;
create_time: number;
version: string;
allow_lazy_start?: boolean;
}

export enum REFRESH_ANALYTICS_LIST_STATE {
ERROR = 'error',
IDLE = 'idle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {
isClassificationAnalysis,
isOutlierAnalysis,
isRegressionAnalysis,
DataFrameAnalyticsConfig,
} from './analytics';
import { Field } from '../../../../common/types/fields';
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '../../../../../../../src/plugins/data/public';
import { newJobCapsService } from '../../services/new_job_capabilities_service';

import { FEATURE_IMPORTANCE, FEATURE_INFLUENCE, OUTLIER_SCORE, TOP_CLASSES } from './constants';
import { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';

export type EsId = string;
export type EsDocSource = Record<string, any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { ml } from '../../services/ml_api_service';
import { isKeywordAndTextType } from '../common/fields';
import { SavedSearchQuery } from '../../contexts/ml';

import { DataFrameAnalyticsConfig, INDEX_STATUS } from './analytics';
import { INDEX_STATUS } from './analytics';
import { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';

export const getIndexData = async (
jobConfig: DataFrameAnalyticsConfig | undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export {
isOutlierAnalysis,
refreshAnalyticsList$,
useRefreshAnalyticsList,
DataFrameAnalyticsId,
DataFrameAnalyticsConfig,
UpdateDataFrameAnalyticsConfig,
IndexName,
IndexPattern,
REFRESH_ANALYTICS_LIST_STATE,
ANALYSIS_CONFIG_TYPE,
Expand Down Expand Up @@ -45,3 +42,6 @@ export { getIndexData } from './get_index_data';
export { getIndexFields } from './get_index_fields';

export { useResultsViewConfig } from './use_results_view_config';
export { DataFrameAnalyticsConfig } from '../../../../common/types/data_frame_analytics';
export { DataFrameAnalyticsId } from '../../../../common/types/data_frame_analytics';
export { IndexName } from '../../../../common/types/data_frame_analytics';
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import { FormattedMessage } from '@kbn/i18n/react';
import { useMlContext } from '../../../contexts/ml';
import { newJobCapsService } from '../../../services/new_job_capabilities_service';
import { ml } from '../../../services/ml_api_service';
import { DataFrameAnalyticsId } from '../../common/analytics';
import { useCreateAnalyticsForm } from '../analytics_management/hooks/use_create_analytics_form';
import { CreateAnalyticsAdvancedEditor } from './components/create_analytics_advanced_editor';
import { AdvancedStep, ConfigurationStep, CreateStep, DetailsStep } from './components';
import { DataFrameAnalyticsId } from '../../../../../common/types/data_frame_analytics';

export enum ANALYTICS_STEPS {
CONFIGURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ export const DataFrameAnalyticsList: FC<Props> = ({
return (
<>
{modals}
<EuiSpacer size="m" />
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
{analyticsStats && (
Expand Down
Loading