Skip to content

Commit 4df3ee8

Browse files
[ML] Adding better error reporting for reading and importing data (#24269)
* [ML] Adding better error reporting for reading and importing data * changes to endpoint errors * displaying errors * step logic refactor * removing log statements
1 parent 890608d commit 4df3ee8

File tree

9 files changed

+389
-129
lines changed

9 files changed

+389
-129
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
8+
import React from 'react';
9+
10+
import {
11+
EuiCallOut,
12+
} from '@elastic/eui';
13+
14+
import { IMPORT_STATUS } from './import_progress';
15+
16+
export function Errors({ errors, statuses }) {
17+
return (
18+
<EuiCallOut
19+
title={title(statuses)}
20+
color="danger"
21+
iconType="cross"
22+
>
23+
{
24+
errors.map((e, i) => (
25+
<p key={i}>
26+
{ toString(e) }
27+
</p>
28+
))
29+
}
30+
31+
</EuiCallOut>
32+
);
33+
}
34+
35+
function title(statuses) {
36+
switch (IMPORT_STATUS.FAILED) {
37+
case statuses.readStatus:
38+
return 'Error reading file';
39+
case statuses.indexCreatedStatus:
40+
return 'Error creating index';
41+
case statuses.ingestPipelineCreatedStatus:
42+
return 'Error creating ingest pipeline';
43+
case statuses.uploadStatus:
44+
return 'Error uploading data';
45+
case statuses.indexPatternCreatedStatus:
46+
return 'Error creating index pattern';
47+
default:
48+
return 'Error';
49+
}
50+
}
51+
52+
function toString(error) {
53+
if (typeof error === 'object') {
54+
if (error.msg !== undefined) {
55+
return error.msg;
56+
} else if (error.error !== undefined) {
57+
return error.error;
58+
} else {
59+
return error.toString();
60+
}
61+
}
62+
return error;
63+
}

x-pack/plugins/ml/public/file_datavisualizer/components/import_view/import_progress.js

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,70 @@ export function ImportProgress({ statuses }) {
3434

3535
let statusInfo = null;
3636

37-
let processFileTitle = 'Process file';
37+
let completedStep = 0;
38+
3839
if (reading === true && readStatus === IMPORT_STATUS.INCOMPLETE) {
39-
processFileTitle = 'Processing file';
40-
statusInfo = (<p>Converting file for import</p>);
41-
} else if (reading === false && readStatus === IMPORT_STATUS.COMPLETE) {
42-
processFileTitle = 'File processed';
40+
completedStep = 0;
41+
}
42+
if (
43+
readStatus === IMPORT_STATUS.COMPLETE &&
44+
indexCreatedStatus === IMPORT_STATUS.INCOMPLETE &&
45+
ingestPipelineCreatedStatus === IMPORT_STATUS.INCOMPLETE
46+
) {
47+
completedStep = 1;
4348
}
44-
45-
let createIndexTitle = 'Create index';
4649
if (indexCreatedStatus === IMPORT_STATUS.COMPLETE) {
47-
createIndexTitle = 'Index created';
50+
completedStep = 2;
4851
}
49-
50-
let createIngestPipelineTitle = 'Create ingest pipeline';
5152
if (ingestPipelineCreatedStatus === IMPORT_STATUS.COMPLETE) {
52-
createIngestPipelineTitle = 'Ingest pipeline created';
53+
completedStep = 3;
54+
}
55+
if (uploadStatus === IMPORT_STATUS.COMPLETE) {
56+
completedStep = 4;
5357
}
58+
if (indexPatternCreatedStatus === IMPORT_STATUS.COMPLETE) {
59+
completedStep = 5;
60+
}
61+
5462

63+
let processFileTitle = 'Process file';
64+
let createIndexTitle = 'Create index';
65+
let createIngestPipelineTitle = 'Create ingest pipeline';
5566
let uploadingDataTitle = 'Upload data';
56-
if (uploadProgress > 0 && uploadStatus === IMPORT_STATUS.INCOMPLETE) {
57-
uploadingDataTitle = 'Uploading data';
67+
let createIndexPatternTitle = 'Create index pattern';
5868

69+
if (completedStep >= 0) {
70+
processFileTitle = 'Processing file';
71+
statusInfo = (<p>Converting file for import</p>);
72+
}
73+
if (completedStep >= 1) {
74+
processFileTitle = 'File processed';
75+
createIndexTitle = 'Creating index';
76+
statusInfo = (<p>Creating index and ingest pipeline</p>);
77+
}
78+
if (completedStep >= 2) {
79+
createIndexTitle = 'Index created';
80+
createIngestPipelineTitle = 'Creating ingest pipeline';
81+
statusInfo = (<p>Creating index and ingest pipeline</p>);
82+
}
83+
if (completedStep >= 3) {
84+
createIngestPipelineTitle = 'Ingest pipeline created';
85+
uploadingDataTitle = 'Uploading data';
5986
statusInfo = (<UploadFunctionProgress progress={uploadProgress} />);
60-
} else if (uploadStatus === IMPORT_STATUS.COMPLETE) {
87+
}
88+
if (completedStep >= 4) {
6189
uploadingDataTitle = 'Data uploaded';
90+
if (createIndexPattern === true) {
91+
createIndexPatternTitle = 'Creating index pattern';
92+
statusInfo = (<p>Creating index pattern</p>);
93+
}
6294
}
63-
64-
let createIndexPatternTitle = 'Create index pattern';
65-
if (indexPatternCreatedStatus === IMPORT_STATUS.FAILED) {
95+
if (completedStep >= 5) {
6696
createIndexPatternTitle = 'Index pattern created';
6797
statusInfo = null;
6898
}
6999

70-
const firstSetOfSteps = [
100+
const steps = [
71101
{
72102
title: processFileTitle,
73103
isSelected: true,
@@ -91,15 +121,15 @@ export function ImportProgress({ statuses }) {
91121
},
92122
{
93123
title: uploadingDataTitle,
94-
isSelected: (indexCreatedStatus === IMPORT_STATUS.COMPLETE),
124+
isSelected: (indexCreatedStatus === IMPORT_STATUS.COMPLETE && ingestPipelineCreatedStatus === IMPORT_STATUS.COMPLETE),
95125
isComplete: (uploadStatus === IMPORT_STATUS.COMPLETE),
96126
status: uploadStatus,
97127
onClick: () => {},
98128
}
99129
];
100130

101131
if (createIndexPattern === true) {
102-
firstSetOfSteps.push({
132+
steps.push({
103133
title: createIndexPatternTitle,
104134
isSelected: (uploadStatus === IMPORT_STATUS.COMPLETE),
105135
isComplete: (indexPatternCreatedStatus === IMPORT_STATUS.COMPLETE),
@@ -111,9 +141,14 @@ export function ImportProgress({ statuses }) {
111141
return (
112142
<React.Fragment>
113143
<EuiStepsHorizontal
114-
steps={firstSetOfSteps}
144+
steps={steps}
115145
/>
116-
{ statusInfo }
146+
{ statusInfo &&
147+
<React.Fragment>
148+
<EuiSpacer size="m" />
149+
{ statusInfo }
150+
</React.Fragment>
151+
}
117152
</React.Fragment>
118153
);
119154
}

0 commit comments

Comments
 (0)