-
Notifications
You must be signed in to change notification settings - Fork 220
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
add ml_inference processor for offline batch inference #5507
base: main
Are you sure you want to change the base?
Conversation
86e4f34
to
a59fb6a
Compare
.../ml-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessor.java
Outdated
Show resolved
Hide resolved
...ns/s3-source/src/main/java/org/opensearch/dataprepper/plugins/source/s3/S3ObjectHandler.java
Outdated
Show resolved
Hide resolved
.../ml-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessor.java
Outdated
Show resolved
Hide resolved
...in/java/org/opensearch/dataprepper/plugins/ml/processor/common/SageMakerBatchJobCreator.java
Outdated
Show resolved
Hide resolved
...in/java/org/opensearch/dataprepper/plugins/ml/processor/common/SageMakerBatchJobCreator.java
Outdated
Show resolved
Hide resolved
...in/java/org/opensearch/dataprepper/plugins/ml/processor/common/SageMakerBatchJobCreator.java
Outdated
Show resolved
Hide resolved
private String findCommonPrefix(Collection<Record<Event>> records) { | ||
List<String> keys = new ArrayList<>(); | ||
for (Record<Event> record : records) { | ||
keys.add(record.getData().getJsonNode().get("key").asText()); |
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.
This seems to have a very rigid expectation on having a key named key
. If you need this, it should be configurable by users.
Also, prefer:
record.getData().get(eventKey, String.class)
You can get an EventKey
in the constructor. See #4636 for an example of how you can use this.
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.
added the "input_key" to allow CX to configure the key.
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.
Thanks for using the EventKey
. I'm still unsure what input_key
is doing though. What does this represent exactly? Are these the keys for obtaining the bucket name and the S3 key?
We should have more concrete names for the configuration. For example: bucket_key
makes sense. But, that would also tend toward key_key
which is confusing!
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 input_key here represents the S3 file uri. Currently the S3 scan in meta data mode sends data like this
{"bucket":"offlinebatch","length":158893,"time":1736279088.000000000,"key":"bedrock-multisource/my_batch.jsonl"}
So the input_key would be "key" in this S3 Scan mode, and that's why it's listed as "input_key: key" in the pipeline yaml file. I think it makes sense to change to "object_key"? Basically that defines the key name in the json record which has the S3 uri to be processed.
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.
Given that the S3 Scan uses the "key" as the name of the S3Uri from the metadata scan, I use "key" as the default field to read S3Uris if this input_key is not provided in the pipeline. Otherwise, it uses the EventKey to read it from the input_key. Please let me know if you'd want a different name instead of input_key
.
@Zhangxunmt , Thank you for this great processor! We will also need some unit tests. I'm ok accepting this PR without them as long as we have the |
dlvenable Thanks David for the comments. Looks like there're no major concerns. I will add the remaining UTs soon and the @experimental annotation. |
0b384c9
to
9ce8a77
Compare
5ae7861
to
c670ca5
Compare
d0aa269
to
0108602
Compare
...-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/util/RetryUtil.java
Outdated
Show resolved
Hide resolved
...nce-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessor.java
Outdated
Show resolved
Hide resolved
...ocessor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessorConfig.java
Outdated
Show resolved
Hide resolved
...nce-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessor.java
Outdated
Show resolved
Hide resolved
mlBatchJobCreator.createMLBatchJob(recordsToMlCommons); | ||
numberOfMLProcessorSuccessCounter.increment(); | ||
} catch (Exception e) { | ||
LOG.error(NOISY, e.getMessage(), 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.
This is still unresolved.
try { | ||
mlBatchJobCreator.createMLBatchJob(recordsToMlCommons); | ||
numberOfMLProcessorSuccessCounter.increment(); | ||
} catch (Exception 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.
This is still unresolved.
...nce-processor/src/main/java/org/opensearch/dataprepper/plugins/ml/processor/MLProcessor.java
Outdated
Show resolved
Hide resolved
private String findCommonPrefix(Collection<Record<Event>> records) { | ||
List<String> keys = new ArrayList<>(); | ||
for (Record<Event> record : records) { | ||
keys.add(record.getData().getJsonNode().get("key").asText()); |
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.
Thanks for using the EventKey
. I'm still unsure what input_key
is doing though. What does this represent exactly? Are these the keys for obtaining the bucket name and the S3 key?
We should have more concrete names for the configuration. For example: bucket_key
makes sense. But, that would also tend toward key_key
which is confusing!
Signed-off-by: Xun Zhang <[email protected]>
Signed-off-by: Xun Zhang <[email protected]>
Signed-off-by: Xun Zhang <[email protected]>
Signed-off-by: Xun Zhang <[email protected]>
…uation Signed-off-by: Xun Zhang <[email protected]>
…put_key is null Signed-off-by: Xun Zhang <[email protected]>
@dlvenable Please review the latest commit for the updates to requested changes, after a rebase to the main. The Gradle Builds somehow fail due to unrelated tests. |
Description
Adding a new ml_inference processor to interact with ml-commons plugin in OpenSearch for ML related applications.
Some examples that work well:
Issues Resolved
#5470
#5433
#5509
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.