Skip to content

Commit

Permalink
[ML] Consolidating shared types and util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed May 5, 2020
1 parent 03f4622 commit fe80f32
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import React from 'react';

import { EuiToolTip } from '@elastic/eui';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { getMLJobTypeAriaLabel } from '../../util/field_types_utils';
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
import { i18n } from '@kbn/i18n';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import PropTypes from 'prop-types';

import { EuiCallOut } from '@elastic/eui';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { MESSAGE_LEVEL } from '../../../../common/constants/message_levels';

function getCallOutAttributes(message, status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import { FormattedMessage } from '@kbn/i18n/react';

import { getDocLinks } from '../../util/dependency_cache';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { VALIDATION_STATUS } from '../../../../common/constants/validation';
import { getMostSevereMessageStatus } from '../../../../common/util/validation_utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import d3 from 'd3';
import $ from 'jquery';
import moment from 'moment';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { formatHumanReadableDateTime } from '../../util/date_utils';
import { formatValue } from '../../formatters/format_value';
import { getSeverityColor, getSeverityWithLow } from '../../../../common/util/anomaly_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import d3 from 'd3';
import $ from 'jquery';
import moment from 'moment';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { formatHumanReadableDateTime } from '../../util/date_utils';
import { formatValue } from '../../formatters/format_value';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import _ from 'lodash';
import d3 from 'd3';
import moment from 'moment';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { i18n } from '@kbn/i18n';
import { Subscription } from 'rxjs';
import { TooltipValue } from '@elastic/charts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import React, { Component } from 'react';

import { EuiButton, EuiToolTip } from '@elastic/eui';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { FORECAST_REQUEST_STATE, JOB_STATE } from '../../../../../common/constants/states';
import { MESSAGE_LEVEL } from '../../../../../common/constants/message_levels';
import { isJobVersionGte } from '../../../../../common/util/job_utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
EuiToolTip,
} from '@elastic/eui';

// don't use something like plugins/ml/../common
// because it won't work with the jest tests
import { JOB_STATE } from '../../../../../common/constants/states';
import { FORECAST_DURATION_MAX_DAYS } from './forecasting_modal';
import { ForecastProgress } from './forecast_progress';
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/ml/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export const plugin: PluginInitializer<
> = () => new MlPlugin();

export { MlPluginSetup, MlPluginStart };
export * from './shared';
14 changes: 14 additions & 0 deletions x-pack/plugins/ml/public/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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.
*/

export * from '../common/constants/anomalies';

export * from '../common/types/data_recognizer';
export * from '../common/types/capabilities';
export * from '../common/types/anomalies';
export * from '../common/types/modules';

export * from '../common/util/anomaly_utils';
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import moment from 'moment';
import { AnnotationTooltipFormatter, RectAnnotation } from '@elastic/charts';
import { RectAnnotationDatum } from '@elastic/charts/dist/chart_types/xy_chart/utils/specs';
import { AnnotationTooltip } from './annotation_tooltip';
import { ANOMALY_SEVERITY } from '../../../../../../plugins/ml/common/constants/anomalies';
import {
ANOMALY_SEVERITY,
getSeverityColor,
getSeverityType,
} from '../../../../../../plugins/ml/common/util/anomaly_utils';
} from '../../../../../../plugins/ml/public';

interface Props {
anomalies: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { getMLJobId } from '../../../state/api/ml_anomaly';
import * as labels from './translations';
import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';
import { ManageMLJobComponent } from './manage_ml_job';
import { JobStat } from '../../../../../../plugins/ml/common/types/data_recognizer';
import { JobStat } from '../../../../../../plugins/ml/public';
import { useMonitorId } from '../../../hooks';

export const MLIntegrationComponent = () => {
Expand Down
8 changes: 5 additions & 3 deletions x-pack/plugins/uptime/public/state/actions/ml_anomaly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@

import { createAction } from 'redux-actions';
import { createAsyncAction } from './utils';
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
import { AnomaliesTableRecord } from '../../../../../plugins/ml/common/types/anomalies';
import {
MlCapabilitiesResponse,
AnomaliesTableRecord,
JobExistResult,
} from '../../../../../plugins/ml/public';
import {
CreateMLJobSuccess,
DeleteJobResults,
MonitorIdParam,
HeartbeatIndicesParam,
} from './types';
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';

export const resetMLState = createAction('RESET_ML_STATE');

Expand Down
8 changes: 5 additions & 3 deletions x-pack/plugins/uptime/public/state/api/ml_anomaly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import moment from 'moment';
import { apiService } from './utils';
import { AnomalyRecords, AnomalyRecordsParams } from '../actions';
import { API_URLS, ML_JOB_ID, ML_MODULE_ID } from '../../../common/constants';
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
import {
MlCapabilitiesResponse,
DataRecognizerConfigResponse,
JobExistResult,
} from '../../../../../plugins/ml/public';
import {
CreateMLJobSuccess,
DeleteJobResults,
MonitorIdParam,
HeartbeatIndicesParam,
} from '../actions/types';
import { DataRecognizerConfigResponse } from '../../../../../plugins/ml/common/types/modules';
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';

const getJobPrefix = (monitorId: string) => {
// ML App doesn't support upper case characters in job name
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/uptime/public/state/reducers/ml_anomaly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import {
} from '../actions';
import { getAsyncInitialState, handleAsyncAction } from './utils';
import { AsyncInitialState } from './types';
import { MlCapabilitiesResponse } from '../../../../../plugins/ml/common/types/capabilities';
import { MlCapabilitiesResponse, JobExistResult } from '../../../../../plugins/ml/public';
import { CreateMLJobSuccess, DeleteJobResults } from '../actions/types';
import { JobExistResult } from '../../../../../plugins/ml/common/types/data_recognizer';

export interface MLJobState {
mlJob: AsyncInitialState<JobExistResult>;
Expand Down

0 comments on commit fe80f32

Please sign in to comment.