gemini-code-assist[bot] commented on code in PR #39067:
URL: https://github.com/apache/beam/pull/39067#discussion_r3456557075
##########
sdks/java/ml/inference/remote/src/test/java/org/apache/beam/sdk/ml/inference/remote/RemoteInferenceTest.java:
##########
@@ -530,24 +528,31 @@ public void testMultipleInputsProduceSeparateBatches() {
pipeline.apply(
"CreateInputs",
Create.of(inputs).withCoder(SerializableCoder.of(TestInput.class)));
+ // Configure BatchElements to force a batch of exactly 2
+ org.apache.beam.sdk.transforms.BatchElements.BatchConfig batchConfig =
+ org.apache.beam.sdk.transforms.BatchElements.BatchConfig.builder()
+ .withMinBatchSize(2)
+ .withMaxBatchSize(2)
+ .build();
+
PCollection<Iterable<PredictionResult<TestInput, TestOutput>>> results =
inputCollection.apply(
"RemoteInference",
RemoteInference.<TestInput, TestOutput>invoke()
.handler(MockSuccessHandler.class)
+ .withBatchConfig(batchConfig)
.withParameters(params));
PAssert.that(results)
.satisfies(
batches -> {
int batchCount = 0;
+ int totalElements = 0;
for (Iterable<PredictionResult<TestInput, TestOutput>> batch :
batches) {
batchCount++;
- int elementCount = (int)
StreamSupport.stream(batch.spliterator(), false).count();
- // Each batch should contain exactly 1 element
- assertEquals("Each batch should contain 1 element", 1,
elementCount);
+ totalElements += (int)
StreamSupport.stream(batch.spliterator(), false).count();
}
- assertEquals("Expected 2 batches", 2, batchCount);
+ assertEquals("Total output elements should be 2", 2,
totalElements);
Review Comment:

The test is named `testBatchingProducesCombinedBatches`, but it currently
only asserts the total number of elements, not that they were actually combined
into a single batch. To ensure that batching is working as expected, we should
also assert that `batchCount` is 1.
```suggestion
assertEquals("Expected 1 batch", 1, batchCount);
assertEquals("Total output elements should be 2", 2,
totalElements);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]