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] Transforms: Use data views service for loading data views #131819

Merged

Conversation

peteharverson
Copy link
Contributor

Summary

Replaces all uses of the saved object client for loading and deleting data views with the data views service from the data-views-plugin.

Part of #91715

Closes #124381

@peteharverson peteharverson added review :ml release_note:skip Skip the PR/issue when compiling release notes Feature:Transforms ML transforms v8.3.0 labels May 9, 2022
@peteharverson peteharverson self-assigned this May 9, 2022
@peteharverson peteharverson requested a review from a team as a code owner May 9, 2022 16:18
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some small comments, but generally LGTM

@@ -27,8 +27,7 @@ export type DiscoverAction = ReturnType<typeof useDiscoverAction>;
export const useDiscoverAction = (forceDisable: boolean) => {
const appDeps = useAppDependencies();
const { share } = appDeps;
const savedObjectsClient = appDeps.savedObjects.client;
const dataViews = appDeps.data.dataViews;
const dataViewsContract = appDeps.data.dataViews;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, data and application could be added to the line above along with share, to clean this code up a bit.
In fact they could all be added to line 28 and appDeps removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

getStartServices: CoreSetup<PluginStartContract>['getStartServices'];
}

export interface PluginStartContract {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be renamed PluginStartDependencies and Dependencies on line 15 should be renamed PluginSetuptDependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! just a couple of minor suggestions

@@ -6,68 +6,31 @@
*/

import { buildEsQuery } from '@kbn/es-query';
import { SavedObjectsClientContract, SimpleSavedObject, IUiSettingsClient } from '@kbn/core/public';
import { IUiSettingsClient } from '@kbn/core/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
import { IUiSettingsClient } from '@kbn/core/public';
import type { IUiSettingsClient } from '@kbn/core/public';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

import { getEsQueryConfig } from '@kbn/data-plugin/public';
import { DataView, DataViewAttributes, DataViewsContract } from '@kbn/data-views-plugin/public';
import { DataView, DataViewsContract } from '@kbn/data-views-plugin/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { DataView, DataViewsContract } from '@kbn/data-views-plugin/public';
import type { DataView, DataViewsContract } from '@kbn/data-views-plugin/public';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

@@ -5,8 +5,8 @@
* 2.0.
*/

import { HttpSetup, SavedObjectsClientContract } from '@kbn/core/public';
import { DataView } from '@kbn/data-views-plugin/public';
import { HttpSetup } from '@kbn/core/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { HttpSetup } from '@kbn/core/public';
import type { HttpSetup } from '@kbn/core/public';

import { HttpSetup, SavedObjectsClientContract } from '@kbn/core/public';
import { DataView } from '@kbn/data-views-plugin/public';
import { HttpSetup } from '@kbn/core/public';
import { DataViewsContract } from '@kbn/data-views-plugin/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { DataViewsContract } from '@kbn/data-views-plugin/public';
import type { DataViewsContract } from '@kbn/data-views-plugin/public';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

Comment on lines 22 to 23
const dv = (await dataViewsContract.find(indexName)).find(({ title }) => title === indexName);
return dv !== undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const dv = (await dataViewsContract.find(indexName)).find(({ title }) => title === indexName);
return dv !== undefined;
return (await dataViewsContract.find(indexName)).some(({ title }) => title === indexName);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

@@ -9,6 +9,7 @@ import { i18n as kbnI18n } from '@kbn/i18n';

import type { CoreSetup } from '@kbn/core/public';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 36d6398

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
transform 371.2KB 370.7KB -508.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @peteharverson

@peteharverson peteharverson merged commit 69efa44 into elastic:main May 10, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 10, 2022
@peteharverson peteharverson deleted the transforms-data-view-loading branch May 10, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Transforms ML transforms :ml release_note:skip Skip the PR/issue when compiling release notes review v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Transforms: Use data views service for loading data views
6 participants