Skip to content

Commit

Permalink
Add retry-failed option for the POST request
Browse files Browse the repository at this point in the history
  • Loading branch information
ozguzMete committed Aug 6, 2022
1 parent 2c29017 commit 41e99ad
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ public static void main(String[] args) throws Exception
String retryCount = commandLine.getOptionValue("retry-failed","0");
try {
retryFailed = Long.parseLong(retryCount);
if(retryFailed < 1) {
retryFailed = 0;
}
} catch (NumberFormatException e) {
System.out.println("Fix the value of tha option named retry-failed");
System.out.println("Fix the value of the option named retry-failed");
System.exit(0);
}
launchJob(args, commandLine.getOptionValue("filename"), commandLine.getOptionValue("output-filename"),commandLine.getOptionValue("isoform-override"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void open(ExecutionContext ec) throws ItemStreamException {
List<MutationRecord> mutationRecords = loadMutationRecordsFromMaf();
if (!mutationRecords.isEmpty()) {
if (postIntervalSize > 0) {
this.allAnnotatedRecords = annotator.getAnnotatedRecordsUsingPOST(summaryStatistics, mutationRecords, isoformOverride, replace, postIntervalSize, true);
this.allAnnotatedRecords = annotator.getAnnotatedRecordsUsingPOST(summaryStatistics, mutationRecords, isoformOverride, replace, postIntervalSize, true, retryFailed);
} else {
this.allAnnotatedRecords = annotator.annotateRecordsUsingGET(summaryStatistics, mutationRecords, isoformOverride, replace, true, retryFailed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ List<AnnotatedRecord> annotateRecordsUsingGET(AnnotationSummaryStatistics summar
boolean isHgvspNullClassifications(String variantClassification);
String getUrlForRecord(MutationRecord record, String isoformOverridesSource);
String getVersion();
List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, boolean reannotate);
List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, Integer postIntervalSize, boolean reannotate);
List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, boolean reannotate, Long retryFailed);
List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, Integer postIntervalSize, boolean reannotate,
Long retryFailed);
}
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,14 @@ private static List<String> initNullClassifications() {
}

@Override
public List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, boolean reannotate) {
public List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, boolean reannotate, Long retryFailed) {
// this will send everything at once
return getAnnotatedRecordsUsingPOST(summaryStatistics, mutationRecords, isoformOverridesSource, replace, mutationRecords.size(), reannotate);
return getAnnotatedRecordsUsingPOST(summaryStatistics, mutationRecords, isoformOverridesSource, replace, mutationRecords.size(), reannotate, retryFailed);
}

@Override
public List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, Integer postIntervalSize, boolean reannotate) {
public List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStatistics summaryStatistics, List<MutationRecord> mutationRecords, String isoformOverridesSource, Boolean replace, Integer postIntervalSize, boolean reannotate,
Long retryFailed) {
// construct list of genomic location objects to pass to api client
// TODO use SortedSet (or at least Set) instead? Do we anticipate a lot of redundancy? Probably quite a bit.
// Maybe test which is faster with a large study
Expand All @@ -452,13 +453,18 @@ public List<AnnotatedRecord> getAnnotatedRecordsUsingPOST(AnnotationSummaryStati
for (List<GenomicLocation> partitionedList : partitionedGenomicLocationList) {
List<VariantAnnotation> gnResponseList = null;
// Get annotations from Genome Nexus and log if server error (e.g VEP is down)
try {
gnResponseList = apiClient.fetchVariantAnnotationByGenomicLocationPOST(partitionedList,
isoformOverridesSource, "", Arrays.asList(this.enrichmentFields.split(",")));
} catch (Exception e) {
LOG.error("Annotation failed for ALL variants in this partition. " + e.getMessage());
for(int i = 0; i <= retryFailed; i++) {
try {
gnResponseList = apiClient.fetchVariantAnnotationByGenomicLocationPOST(partitionedList,
isoformOverridesSource, "", Arrays.asList(this.enrichmentFields.split(",")));
break;
} catch (Exception e) {
LOG.error("Annotation failed for ALL variants in this partition. " + e.getMessage());
if(i != retryFailed) {
LOG.warn("Retrying " + (i+1) + "/" + retryFailed);
}
}
}

// Verify annotations coming back from Genome Nexus and log annotation failures (e.g used to be 404s)
if (gnResponseList != null) {
for (VariantAnnotation gnResponse : gnResponseList) {
Expand Down

0 comments on commit 41e99ad

Please sign in to comment.