Skip to content

Commit

Permalink
Fix partition size
Browse files Browse the repository at this point in the history
  • Loading branch information
kathy-t committed Jan 23, 2024
1 parent d938175 commit b13c1b2
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static java.util.stream.Collectors.groupingBy;

import com.google.common.collect.Lists;
import com.google.common.math.IntMath;
import io.dockstore.common.Partner;
import io.dockstore.metricsaggregator.MetricsAggregatorConfig;
import io.dockstore.metricsaggregator.client.cli.CommandLineArgs.SubmitTerraMetrics;
Expand All @@ -23,6 +24,7 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -200,8 +202,9 @@ private void executionMetricsPost(List<RunExecution> workflowExecutionsToSubmit,
numberOfExecutionsSubmitted.addAndGet(workflowMetricRecords.size());
} catch (ApiException e) {
if (e.getCode() == HttpStatus.SC_REQUEST_TOO_LONG) {
List<List<RunExecution>> workflowExecutionsToSubmitPartitions = Lists.partition(workflowExecutionsToSubmit, 2);
LOG.info("Request body too large, dividing list of {} workflow executions in half and re-attempting", workflowExecutionsToSubmit.size());
int partitionSize = IntMath.divide(workflowExecutionsToSubmit.size(), 2, RoundingMode.UP);
List<List<RunExecution>> workflowExecutionsToSubmitPartitions = Lists.partition(workflowExecutionsToSubmit, partitionSize);
LOG.info("Request body too large, dividing list of {} workflow executions in half with partition size {} and re-attempting", workflowExecutionsToSubmit.size(), partitionSize);

Check warning on line 207 in metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/TerraMetricsSubmitter.java

View check run for this annotation

Codecov / codecov/patch

metricsaggregator/src/main/java/io/dockstore/metricsaggregator/client/cli/TerraMetricsSubmitter.java#L205-L207

Added lines #L205 - L207 were not covered by tests
for (List<RunExecution> partition: workflowExecutionsToSubmitPartitions) {
LOG.info("Re-attempting with {} workflow executions", partition.size());
executionMetricsPost(partition, sourceUrlTrsInfo, description, extendedGa4GhApi, workflowMetricRecords, skippedExecutionsCsvPrinter);
Expand Down

0 comments on commit b13c1b2

Please sign in to comment.