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] Server info service refactor #50302

Merged
merged 7 commits into from
Nov 13, 2019
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import { getFileDataVisualizerBreadcrumbs } from './breadcrumbs';
import { checkBasicLicense } from '../../license/check_license';
import { checkFindFileStructurePrivilege } from '../../privilege/check_privilege';
import { getMlNodeCount } from '../../ml_nodes_check/check_ml_nodes';
import { loadNewJobDefaults } from '../../jobs/new_job_new/utils/new_job_defaults';
import { loadMlServerInfo } from '../../services/ml_server_info';
import { loadIndexPatterns } from '../../util/index_utils';
import { FileDataVisualizerPage } from './file_datavisualizer';

@@ -36,7 +36,7 @@ uiRoutes
privileges: checkFindFileStructurePrivilege,
indexPatterns: loadIndexPatterns,
mlNodeCount: getMlNodeCount,
loadNewJobDefaults,
loadMlServerInfo,
}
});

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

import { difference } from 'lodash';
import chrome from 'ui/chrome';
import { newJobLimits } from 'plugins/ml/jobs/new_job_new/utils/new_job_defaults';
import { getNewJobLimits } from '../../../../services/ml_server_info';
import { mlJobService } from 'plugins/ml/services/job_service';
import { processCreatedBy } from '../../../../../common/util/job_utils';

@@ -157,7 +157,7 @@ function extractGroups(job, newJobData) {
}

function extractMML(job, newJobData) {
const jobLimits = newJobLimits();
const jobLimits = getNewJobLimits();
const mmlData = {};
// if the job's model_memory_limit has changed, add it to the jobData json
if (job.analysis_limits.model_memory_limit !== undefined) {
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ import {
} from '@elastic/eui';

import { calculateDatafeedFrequencyDefaultSeconds } from 'plugins/ml/../common/util/job_utils';
import { newJobDefaults } from 'plugins/ml/jobs/new_job_new/utils/new_job_defaults';
import { getNewJobDefaults } from '../../../../../services/ml_server_info';
import { parseInterval } from 'plugins/ml/../common/util/parse_interval';
import { MLJobEditor } from '../../ml_job_editor';
import { FormattedMessage } from '@kbn/i18n/react';
@@ -47,7 +47,7 @@ export class Datafeed extends Component {
frequency: '',
scrollSize: 0,
},
jobDefaults: newJobDefaults()
jobDefaults: getNewJobDefaults()
};

this.setDatafeed = props.setDatafeed;
Original file line number Diff line number Diff line change
@@ -9,58 +9,58 @@ import React, { Fragment, FC } from 'react';
import { EuiCallOut, EuiLink, EuiSpacer } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { mlNodesAvailable, permissionToViewMlNodeCount } from '../../../../ml_nodes_check';
import { cloudDeploymentId, isCloud } from '../../../../jobs/new_job_new/utils/new_job_defaults';
import { getCloudDeploymentId, isCloud } from '../../../../services/ml_server_info';

export const NodeAvailableWarning: FC = () => {
if (mlNodesAvailable() === true || permissionToViewMlNodeCount() === false) {
return null;
} else {
const id = cloudDeploymentId();
return (
<Fragment>
<EuiCallOut
title={
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableTitle"
defaultMessage="No ML nodes available"
/>
}
color="warning"
iconType="alert"
>
<p>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableDescription"
defaultMessage="There are no ML nodes available."
/>
<br />
}

const id = getCloudDeploymentId();
return (
<Fragment>
<EuiCallOut
title={
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableTitle"
defaultMessage="No ML nodes available"
/>
}
color="warning"
iconType="alert"
>
<div>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableDescription"
defaultMessage="There are no ML nodes available."
/>
</div>
<div>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.unavailableCreateOrRunJobsDescription"
defaultMessage="You will not be able to create or run jobs."
/>
</div>
{isCloud && id !== null && (
<div>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.unavailableCreateOrRunJobsDescription"
defaultMessage="You will not be able to create or run jobs."
id="xpack.ml.jobsList.nodeAvailableWarning.linkToCloudDescription"
defaultMessage="Please edit your {link}. You may enable a free 1GB machine learning node or expand your existing ML configuration."
values={{
link: (
<EuiLink href={`https://cloud.elastic.co/deployments?q=${id}`}>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.linkToCloud.hereLinkText"
defaultMessage="Elastic Cloud deployment"
/>
</EuiLink>
),
}}
/>
{isCloud && id !== null && (
<Fragment>
<br />
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.linkToCloudDescription"
defaultMessage="Please edit your {link}. You may enable a free 1GB machine learning node or expand your existing ML configuration."
values={{
link: (
<EuiLink href={`https://cloud.elastic.co/deployments?q=${id}`}>
<FormattedMessage
id="xpack.ml.jobsList.nodeAvailableWarning.linkToCloud.hereLinkText"
defaultMessage="Elastic Cloud deployment"
/>
</EuiLink>
),
}}
/>
</Fragment>
)}
</p>
</EuiCallOut>
<EuiSpacer size="m" />
</Fragment>
);
}
</div>
)}
</EuiCallOut>
<EuiSpacer size="m" />
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
*/


import { newJobLimits } from '../../new_job_new/utils/new_job_defaults';
import { getNewJobLimits } from '../../../services/ml_server_info';
import { populateValidationMessages } from '../../new_job_new/common/job_validator/util';

import {
@@ -16,7 +16,7 @@ import {
import { isValidLabel, isValidTimeRange } from '../../../util/custom_url_utils';

export function validateModelMemoryLimit(mml) {
const limits = newJobLimits();
const limits = getNewJobLimits();
const tempJob = {
analysis_limits: {
model_memory_limit: mml
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/ml/public/jobs/jobs_list/directive.js
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ import { checkFullLicense } from 'plugins/ml/license/check_license';
import { checkGetJobsPrivilege } from 'plugins/ml/privilege/check_privilege';
import { getMlNodeCount } from 'plugins/ml/ml_nodes_check/check_ml_nodes';
import { getJobManagementBreadcrumbs } from 'plugins/ml/jobs/breadcrumbs';
import { loadNewJobDefaults } from 'plugins/ml/jobs/new_job_new/utils/new_job_defaults';
import { loadMlServerInfo } from 'plugins/ml/services/ml_server_info';

import uiRoutes from 'ui/routes';

@@ -31,7 +31,7 @@ uiRoutes
indexPatterns: loadIndexPatterns,
privileges: checkGetJobsPrivilege,
mlNodeCount: getMlNodeCount,
loadNewJobDefaults,
loadMlServerInfo,
}
});

Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

import { ReactElement } from 'react';
import { basicJobValidation, basicDatafeedValidation } from '../../../../../common/util/job_utils';
import { newJobLimits } from '../../../new_job_new/utils/new_job_defaults';
import { getNewJobLimits } from '../../../../services/ml_server_info';
import { JobCreatorType } from '../job_creator';
import { populateValidationMessages, checkForExistingJobAndGroupIds } from './util';
import { ExistingJobsAndGroups } from '../../../../services/job_service';
@@ -111,7 +111,7 @@ export class JobValidator {

const jobConfig = this._jobCreator.jobConfig;
const datafeedConfig = this._jobCreator.datafeedConfig;
const limits = newJobLimits();
const limits = getNewJobLimits();

// run standard basic validation
const basicJobResults = basicJobValidation(jobConfig, undefined, limits);
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { i18n } from '@kbn/i18n';
import { BasicValidations } from './job_validator';
import { Job, Datafeed } from '../job_creator/configs';
import { ALLOWED_DATA_UNITS, JOB_ID_MAX_LENGTH } from '../../../../../common/constants/validation';
import { newJobLimits } from '../../../new_job_new/utils/new_job_defaults';
import { getNewJobLimits } from '../../../../services/ml_server_info';
import { ValidationResults, ValidationMessage } from '../../../../../common/util/job_utils';
import { ExistingJobsAndGroups } from '../../../../services/job_service';

@@ -18,7 +18,7 @@ export function populateValidationMessages(
jobConfig: Job,
datafeedConfig: Datafeed
) {
const limits = newJobLimits();
const limits = getNewJobLimits();

if (validationResults.contains('job_id_empty')) {
basicValidations.jobId.valid = false;
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

import React, { FC, useState, useContext, useEffect } from 'react';
import { EuiFieldText } from '@elastic/eui';
import { newJobDefaults } from '../../../../../new_job_new/utils/new_job_defaults';
import { getNewJobDefaults } from '../../../../../../services/ml_server_info';
import { JobCreatorContext } from '../../job_creator_context';
import { Description } from './description';

@@ -23,7 +23,7 @@ export const ModelMemoryLimitInput: FC = () => {
jobCreator.modelMemoryLimit === null ? '' : jobCreator.modelMemoryLimit
);

const { anomaly_detectors: anomalyDetectors } = newJobDefaults();
const { anomaly_detectors: anomalyDetectors } = getNewJobDefaults();
const { model_memory_limit: modelMemoryLimitDefault } = anomalyDetectors;

useEffect(() => {
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

import React, { FC, useState, useContext, useEffect } from 'react';
import { EuiFieldNumber } from '@elastic/eui';
import { newJobDefaults } from '../../../../../utils/new_job_defaults';
import { getNewJobDefaults } from '../../../../../../../services/ml_server_info';
import { JobCreatorContext } from '../../../job_creator_context';
import { Description } from './description';

@@ -19,7 +19,7 @@ export const ScrollSizeInput: FC = () => {
jobCreator.scrollSize === null ? '' : `${jobCreator.scrollSize}`
);

const { datafeeds } = newJobDefaults();
const { datafeeds } = getNewJobDefaults();
const scrollSizeDefault = datafeeds.scroll_size !== undefined ? `${datafeeds.scroll_size}` : '';

useEffect(() => {
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@ import { JobCreatorContext } from '../../../job_creator_context';
import { MLJobEditor } from '../../../../../../jobs_list/components/ml_job_editor';
import { calculateDatafeedFrequencyDefaultSeconds } from '../../../../../../../../common/util/job_utils';
import { DEFAULT_QUERY_DELAY } from '../../../../../common/job_creator/util/constants';
import { newJobDefaults } from '../../../../../utils/new_job_defaults';
import { getNewJobDefaults } from '../../../../../../../services/ml_server_info';
import { ListItems, defaultLabel, Italic } from '../common';

const EDITOR_HEIGHT = '200px';

export const DatafeedDetails: FC = () => {
const { jobCreator } = useContext(JobCreatorContext);
const { datafeeds } = newJobDefaults();
const { datafeeds } = getNewJobDefaults();

const queryString = JSON.stringify(jobCreator.query, null, 2);
const defaultFrequency = calculateDatafeedFrequencyDefaultSeconds(jobCreator.bucketSpanMs / 1000);
Original file line number Diff line number Diff line change
@@ -15,15 +15,15 @@ import {
isPopulationJobCreator,
isAdvancedJobCreator,
} from '../../../../../common/job_creator';
import { newJobDefaults } from '../../../../../utils/new_job_defaults';
import { getNewJobDefaults } from '../../../../../../../services/ml_server_info';
import { ListItems, falseLabel, trueLabel, defaultLabel, Italic } from '../common';
import { useKibanaContext } from '../../../../../../../contexts/kibana';

export const JobDetails: FC = () => {
const { jobCreator } = useContext(JobCreatorContext);
const kibanaContext = useKibanaContext();
const dateFormat: string = kibanaContext.kibanaConfig.get('dateFormat');
const { anomaly_detectors: anomalyDetectors } = newJobDefaults();
const { anomaly_detectors: anomalyDetectors } = getNewJobDefaults();

const isAdvanced = isAdvancedJobCreator(jobCreator);

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ import { Route } from '../../../../../common/types/kibana';

import { loadNewJobCapabilities } from '../../../../services/new_job_capabilities_service';

import { loadNewJobDefaults } from '../../utils/new_job_defaults';
import { loadMlServerInfo } from '../../../../services/ml_server_info';

import { mlJobService } from '../../../../services/job_service';
import { JOB_TYPE } from '../../common/job_creator/util/constants';
@@ -58,7 +58,7 @@ routes.forEach((route: Route) => {
indexPattern: loadCurrentIndexPattern,
savedSearch: loadCurrentSavedSearch,
loadNewJobCapabilities,
loadNewJobDefaults,
loadMlServerInfo,
existingJobsAndGroups: mlJobService.getJobAndGroupIds,
jobType: () => route.id,
},
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"defaults": {
"anomaly_detectors": {
"model_memory_limit": "128mb",
"categorization_examples_limit": 4,
"model_snapshot_retention_days": 1
},
"datafeeds": {
"scroll_size": 1000
}
},
"upgrade_mode": false,
"native_code": {
"version": "8.0.0-SNAPSHOT",
"build_hash": "4cde1d7c50fc28"
},
"limits": {
"max_model_memory_limit": "128mb"
},
"cloudId": "cloud_message_test:ZXUtd2VzdC0yLmF3cy5jbG91ZC5lcy5pbyQ4NWQ2NjZmMzM1MGM0NjllOGMzMjQyZDc2YTdmNDU5YyQxNmI1ZDM2ZGE1Mzk0YjlkYjIyZWJlNDk1OWY1OGQzMg=="
}
30 changes: 0 additions & 30 deletions x-pack/legacy/plugins/ml/public/services/cloud_service.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { AggFieldNamePair } from '../../../common/types/fields';
import { ExistingJobsAndGroups } from '../job_service';
import { PrivilegesResponse } from '../../../common/types/privileges';
import { MlSummaryJobs } from '../../../common/types/jobs';
import { MlServerDefaults, MlServerLimits } from '../../jobs/new_job_new/utils/new_job_defaults';
import { MlServerDefaults, MlServerLimits } from '../../services/ml_server_info';
import { ES_AGGREGATION } from '../../../common/constants/aggregation_types';
import { DataFrameAnalyticsStats } from '../../data_frame_analytics/pages/analytics_management/components/analytics_list/common';

Loading