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] New Platform server shim: update data visualizer routes to use new platform router #56739

Merged
merged 8 commits into from
Feb 5, 2020

Conversation

darnautov
Copy link
Contributor

@darnautov darnautov commented Feb 4, 2020

Summary

Part of #49743. Updates data visualizer routes to use the new platform router.

Checklist

@darnautov darnautov added :ml v8.0.0 release_note:skip Skip the PR/issue when compiling release notes Feature:NP Migration v7.7.0 labels Feb 4, 2020
@darnautov darnautov requested a review from a team as a code owner February 4, 2020 12:09
@darnautov darnautov self-assigned this Feb 4, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@peteharverson peteharverson mentioned this pull request Feb 4, 2020
78 tasks
count: number;
trueCount: number;
falseCount: number;
[key: string]: number | string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? Don't we just use falseCount and trueCount ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -277,7 +367,7 @@ export class DataVisualizer {
aggs: buildSamplerAggregation(aggs, samplerShardSize),
};

const resp = await this.callWithRequest('search', {
const resp = await this.context.core.elasticsearch.dataClient.callAsCurrentUser('search', {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be using the same approach that @alvarezmelissa87 used in the calendars route and calendar_manager.ts?

const actualClient = isLegacy === true ? client : client.ml!.mlClient.callAsCurrentUser;

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think we should be using the mlClient.
The mlClient is set up in plugin.ts with the plugins option to extend the elasticsearch client.

    const mlClient = core.elasticsearch.createClient('ml', { plugins: [elasticsearchJsPlugin] });
    http.registerRouteHandlerContext('ml', (context, request) => {
      return {
        mlClient: mlClient.asScoped(request),
      };
    });

That's the difference between context.core.elasticsearch.dataClient.callAsCurrentUser and using .ml!.mlClient.callAsCurrentUser. We should always use the mlClient to make sure it's consistent and so we don't have to worry about changing things later if we add more extensions to the elasticsearch client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to mlClient

? SAMPLER_TOP_TERMS_SHARD_SIZE
: samplerShardSize,
};

stats.topValues = _.get(aggregations, [...topAggsPath, 'buckets'], []);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these lines still needed with the lines you've added above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, deleted

@alvarezmelissa87
Copy link
Contributor

alvarezmelissa87 commented Feb 4, 2020

Seeing these error toasts pop up when I try to use the data visualizer with an index not based on time series:

image

The user shouldn't need to see those schema-related errors. In data_visualizer_schema.ts the timeFieldName schema definition should be wrapped in a schema.maybe() to make sure those errors don't seep through.

Everything else works as expected. Apart from that mentioned above, the code LGTM.

@darnautov
Copy link
Contributor Author

Seeing these error toasts pop up when I try to use the data visualizer with an index not based on time series:

image

The user shouldn't need to see those schema-related errors. In data_visualizer_schema.ts the timeFieldName schema definition should be wrapped in a schema.maybe() to make sure those errors don't seep through.

Everything else works as expected. Apart from that mentioned above, the code LGTM.

thanks @alvarezmelissa87, pushed a fix for schema validation 6c3510a

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

Tested latest edits and LGTM

Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

Latest LGTM ⚡️

@darnautov darnautov merged commit 625b93a into elastic:master Feb 5, 2020
@darnautov darnautov deleted the ML-49743-dataVisualizerRoutes branch February 5, 2020 15:14
darnautov added a commit to darnautov/kibana that referenced this pull request Feb 5, 2020
…ew platform router (elastic#56739)

* [ML] data_visualizer TS refactor, NP router

* [ML] fix schema, add apiDoc

* [ML] update apiDoc order

* [ML] validate_cardinality with NP router

* [ML] use mlClient

* [ML] remove redundant code

* [ML] support legacy callWithRequest for job validation

* [ML] fix schema validation

# Conflicts:
#	x-pack/legacy/plugins/ml/server/routes/apidoc.json
darnautov added a commit that referenced this pull request Feb 6, 2020
…ew platform router (#56739) (#56873)

* [ML] data_visualizer TS refactor, NP router

* [ML] fix schema, add apiDoc

* [ML] update apiDoc order

* [ML] validate_cardinality with NP router

* [ML] use mlClient

* [ML] remove redundant code

* [ML] support legacy callWithRequest for job validation

* [ML] fix schema validation

# Conflicts:
#	x-pack/legacy/plugins/ml/server/routes/apidoc.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:NP Migration :ml release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants