Skip to content

Commit 8875cfa

Browse files
committed
improving mml warning
1 parent e9848af commit 8875cfa

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

x-pack/plugins/ml/common/util/errors/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface EsErrorRootCause {
1515
export interface EsErrorBody {
1616
error: {
1717
root_cause?: EsErrorRootCause[];
18+
caused_by?: EsErrorRootCause;
1819
type: string;
1920
reason: string;
2021
};

x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/util/model_memory_estimator.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { useEffect, useMemo } from 'react';
2323
import { DEFAULT_MODEL_MEMORY_LIMIT } from '../../../../../../../common/constants/new_job';
2424
import { ml } from '../../../../../services/ml_api_service';
2525
import { JobValidator, VALIDATION_DELAY_MS } from '../../job_validator/job_validator';
26-
import { ErrorResponse } from '../../../../../../../common/types/errors';
26+
import { MLHttpFetchError, MLResponseError } from '../../../../../../../common/util/errors';
2727
import { useMlKibana } from '../../../../../contexts/kibana';
2828
import { JobCreator } from '../job_creator';
2929

@@ -36,10 +36,10 @@ export const modelMemoryEstimatorProvider = (
3636
jobValidator: JobValidator
3737
) => {
3838
const modelMemoryCheck$ = new Subject<CalculatePayload>();
39-
const error$ = new Subject<ErrorResponse['body']>();
39+
const error$ = new Subject<MLHttpFetchError<MLResponseError>>();
4040

4141
return {
42-
get error$(): Observable<ErrorResponse['body']> {
42+
get error$(): Observable<MLHttpFetchError<MLResponseError>> {
4343
return error$.asObservable();
4444
},
4545
get updates$(): Observable<string> {
@@ -64,7 +64,7 @@ export const modelMemoryEstimatorProvider = (
6464
catchError((error) => {
6565
// eslint-disable-next-line no-console
6666
console.error('Model memory limit could not be calculated', error.body);
67-
error$.next(error.body);
67+
error$.next(error);
6868
// fallback to the default in case estimation failed
6969
return of(DEFAULT_MODEL_MEMORY_LIMIT);
7070
})
@@ -120,7 +120,8 @@ export const useModelMemoryEstimator = (
120120
title: i18n.translate('xpack.ml.newJob.wizard.estimateModelMemoryError', {
121121
defaultMessage: 'Model memory limit could not be calculated',
122122
}),
123-
text: error.message,
123+
text:
124+
error.body.attributes?.body.error.caused_by?.reason || error.body.message || undefined,
124125
});
125126
})
126127
);

x-pack/plugins/ml/public/application/services/toast_notification_service/toast_notification_service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export function toastNotificationServiceProvider(toastNotifications: ToastsStart
2222
toastNotifications.addDanger(toastOrTitle, options);
2323
}
2424

25+
function displayWarningToast(toastOrTitle: ToastInput, options?: ToastOptions) {
26+
toastNotifications.addWarning(toastOrTitle, options);
27+
}
28+
2529
function displaySuccessToast(toastOrTitle: ToastInput, options?: ToastOptions) {
2630
toastNotifications.addSuccess(toastOrTitle, options);
2731
}
@@ -37,7 +41,7 @@ export function toastNotificationServiceProvider(toastNotifications: ToastsStart
3741
});
3842
}
3943

40-
return { displayDangerToast, displaySuccessToast, displayErrorToast };
44+
return { displayDangerToast, displayWarningToast, displaySuccessToast, displayErrorToast };
4145
}
4246

4347
export function getToastNotificationService() {

0 commit comments

Comments
 (0)