-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[ML] Adding file upload tools to package #221034
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
base: main
Are you sure you want to change the base?
Conversation
/ci |
/ci |
/ci |
Pinging @elastic/ml-ui (:ml) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and LGTM. Didn't find any regressions either in the dedicated page, or in the flyout version used in Search.
this.infer() | ||
.then(() => { | ||
this.inferFinished = true; | ||
}) | ||
.catch((e) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as it is an async function, shall we stick to the await
syntax?
private settings; | ||
private mappings: MappingTypeMapping | null = null; | ||
private pipelines: Array<IngestPipeline | undefined> = []; | ||
public readonly settings$ = new BehaviorSubject<Config<IndicesIndexSettings>>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly settings$ = new BehaviorSubject<Config<IndicesIndexSettings>>({ | |
private readonly settings$ = new BehaviorSubject<Config<IndicesIndexSettings>>({ |
valid: false, | ||
count: 0, | ||
}); | ||
public readonly existingIndexName$ = new BehaviorSubject<string | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly existingIndexName$ = new BehaviorSubject<string | null>(null); | |
private readonly existingIndexName$ = new BehaviorSubject<string | null>(null); |
valid: false, | ||
count: 0, | ||
}); | ||
public readonly mappings$ = new BehaviorSubject<Config<MappingTypeMapping>>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly mappings$ = new BehaviorSubject<Config<MappingTypeMapping>>({ | |
private readonly mappings$ = new BehaviorSubject<Config<MappingTypeMapping>>({ |
count: 0, | ||
}); | ||
public readonly existingIndexName$ = new BehaviorSubject<string | null>(null); | ||
|
||
private inferenceId: string | null = null; | ||
private importer: IImporter | null = null; | ||
private timeFieldName: string | undefined | null = null; | ||
private commonFileFormat: string | null = null; | ||
|
||
public readonly uploadStatus$ = new BehaviorSubject<UploadStatus>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public readonly uploadStatus$ = new BehaviorSubject<UploadStatus>({ | |
private readonly uploadStatus$ = new BehaviorSubject<UploadStatus>({ |
} | ||
|
||
http.get<Index[]>('/api/index_management/indices').then((indx) => { | ||
setIndices(indx.filter((i) => i.hidden === false && i.isFrozen === false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I believe we should only fetch once on mount. We should not re-fetch all indices on
fileUploaderManger
reference change. - We need to check the component is still mounted before setting the state
|
||
useEffect(() => { | ||
dataViews.getTitles().then((titles) => { | ||
setExistingDataViewNames(titles); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to check if it's mounted
uploadStatus.overallImportStatus === STATUS.COMPLETED || | ||
uploadStatus.overallImportStatus === STATUS.FAILED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it confusing that completed and failed considered as in progress. Is it correct?
fileUploadManager.import(index, dv).then((res) => { | ||
if (onUploadComplete && res) { | ||
onUploadComplete(res); | ||
} | ||
setImportResults(res); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- can by async...await
- is it missing error handling?
- need to check the component is till mounted
async function updateMappings(index: string, mappings: MappingTypeMapping) { | ||
const resp = await asCurrentUser.indices.getMapping({ index }); | ||
const existingMappings = resp[index]?.mappings; | ||
if (JSON.stringify(existingMappings.properties) !== JSON.stringify(mappings.properties)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key order matters with JSON.stringify, so I assume a deep equality check is safer
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
History
|
Moves the core file upload classes to a package called
@kbn/file-upload
Moves a lot of shared and duplicated constants to the package
@kbn/file-upload-common
Adds a new context called
FileUploadContext
and related hookuseFileUploadContext
to manage all aspects of the file upload process.Updates the file upload lite flyout used by the Search solution to use this new context.