-
Notifications
You must be signed in to change notification settings - Fork 25k
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] Allow datafeed and job configs for datafeed preview API #70836
[ML] Allow datafeed and job configs for datafeed preview API #70836
Conversation
…gs in datafeed preview
Pinging @elastic/ml-core (Team:ML) |
docs/reference/ml/anomaly-detection/apis/preview-datafeed.asciidoc
Outdated
Show resolved
Hide resolved
….com:benwtrent/elasticsearch into feature/ml-allow-configs-in-datafeed-preview
…idoc Co-authored-by: Lisa Cawley <[email protected]>
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.
LGTM
Nice, I thought this would be a lot more complicated
@@ -27,6 +30,6 @@ protected PreviewDatafeedRequest doParseInstance(XContentParser parser) throws I | |||
|
|||
@Override | |||
protected boolean supportsUnknownFields() { | |||
return true; | |||
return 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.
++ requests parsering shouldn't be lenient. Can you also change the parser in PreviewDatafeedRequest
to have ignoreUnknownFields = 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.
100%
datafeedBuilder.setJobId("preview_job_id"); | ||
} | ||
} | ||
if (jobBuilder != 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.
Is it valid to have a jobBuilder but no datafeedBuilder a null datafeedId? i.e. just the job config
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.
Is it valid to have a jobBuilder but no datafeedBuilder a null datafeedId?
no, it isn't. The API MUST have either a datafeedBuilder or a datafeedId. The restrictive ctors ensure this (with null checks).
listener::onFailure | ||
); | ||
if (request.getDatafeedConfig() != null) { | ||
datafeedConfigActionListener.onResponse(request.getDatafeedConfig()); |
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.
Well if I'd known it was that simple...
@@ -35,8 +39,10 @@ public String getName() { | |||
|
|||
@Override | |||
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { | |||
String datafeedId = restRequest.param(DatafeedConfig.ID.getPreferredName()); | |||
PreviewDatafeedAction.Request request = new PreviewDatafeedAction.Request(datafeedId); | |||
String datafeedId = restRequest.param(DatafeedConfig.ID.getPreferredName(), 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.
The defaultValue
of null
is unnecessary but I prefer this usage it makes the intent more explicit
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.
Gotcha, I will only grab this param if hasContent
is false. Also, I won't provide a default value that way it blows up expecting it.
run elasticsearch-ci/bwc |
run elasticsearch-ci/2 |
@elasticmachine update branch |
…#70836) Previously, a datafeed and job must already exist for the `_preview` API to work. With this change, users can get an accurate preview of the data that will be sent to the anomaly detection job without creating either of them. closes elastic#70264
Previously, a datafeed and job must already exist for the
_preview
API to work.With this change, users can get an accurate preview of the data that will be sent to the anomaly detection job
without creating either of them.
Example:
closes #70264