From 936d668496a6cf61ce951f38b13b867f86f481c0 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 2 Oct 2019 15:15:25 +0100 Subject: [PATCH] JAL-3070 detect failed/broken annotation web service jobs using generic JWS2 job state flag processing logic --- .../ws/jws2/SeqAnnotationServiceCalcWorker.java | 147 +++++++++++--------- 1 file changed, 80 insertions(+), 67 deletions(-) diff --git a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java index 6279ccd..df3a311 100644 --- a/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java +++ b/src/jalview/ws/jws2/SeqAnnotationServiceCalcWorker.java @@ -40,11 +40,13 @@ import jalview.gui.Desktop; import jalview.gui.IProgressIndicator; import jalview.gui.IProgressIndicatorHandler; import jalview.gui.JvOptionPane; +import jalview.gui.WebserviceInfo; import jalview.schemes.FeatureSettingsAdapter; import jalview.schemes.ResidueProperties; import jalview.util.MapList; import jalview.util.MessageManager; import jalview.workers.AlignCalcWorker; +import jalview.ws.JobStateSummary; import jalview.ws.api.CancellableI; import jalview.ws.api.JalviewServiceEndpointProviderI; import jalview.ws.api.JobId; @@ -238,6 +240,8 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker final boolean cancellable = CancellableI.class .isAssignableFrom(annotService.getClass()); StringBuffer msg = new StringBuffer(); + JobStateSummary job = new JobStateSummary(); + WebserviceInfo info = new WebserviceInfo("foo", "bar", false); try { if (checkDone()) @@ -279,7 +283,7 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker running.setSeqNames(seqNames); running.setStartPos(start); running.setSeqs(seqs); - + job.updateJobPanelState(info, "", running); if (guiProgress != null) { guiProgress.registerHandler(progressId, @@ -309,10 +313,12 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker { Cache.log.debug("Updating status for annotation service."); annotService.updateStatus(running); - - if (running.isFinished()) + job.updateJobPanelState(info, "", running); + if (running.isSubjobComplete()) { - Cache.log.debug("Analysis service job reported finished."); + Cache.log.debug( + "Finished polling analysis service job: status reported is " + + running.getState()); finished = true; } else @@ -376,6 +382,7 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker } } while (!finished); + Cache.log.debug("Job poll loop exited. Job is " + running.getState()); // TODO: need to poll/retry if (serverErrorsLeft > 0) { @@ -386,79 +393,85 @@ public class SeqAnnotationServiceCalcWorker extends AlignCalcWorker { } } - // configure job with the associated view's feature renderer, if one - // exists. - // TODO: here one would also grab the 'master feature renderer' in order - // to enable/disable - // features automatically according to user preferences - running.setFeatureRenderer( - ((jalview.gui.AlignmentPanel) ap).cloneFeatureRenderer()); - Cache.log.debug("retrieving job results."); - final Map featureColours = new HashMap<>(); - final Map featureFilters = new HashMap<>(); - List returnedAnnot = annotService - .getAnnotationResult(running.getJobHandle(), seqs, - featureColours, featureFilters); - - Cache.log.debug("Obtained " + (returnedAnnot == null ? "no rows" - : ("" + returnedAnnot.size()))); - Cache.log.debug("There were " + featureColours.size() - + " feature colours and " + featureFilters.size() - + " filters defined."); - - // TODO - // copy over each annotation row reurned and also defined on each - // sequence, excluding regions not annotated due to gapMap/column - // visibility - - running.setAnnotation(returnedAnnot); - - if (running.hasResults()) + if (running.isFinished()) { - jalview.bin.Cache.log.debug("Updating result annotation from Job " - + rslt + " at " + service.getUri()); - updateResultAnnotation(true); - if (running.isTransferSequenceFeatures()) + // expect there to be results to collect + // configure job with the associated view's feature renderer, if one + // exists. + // TODO: here one would also grab the 'master feature renderer' in order + // to enable/disable + // features automatically according to user preferences + running.setFeatureRenderer( + ((jalview.gui.AlignmentPanel) ap).cloneFeatureRenderer()); + Cache.log.debug("retrieving job results."); + final Map featureColours = new HashMap<>(); + final Map featureFilters = new HashMap<>(); + List returnedAnnot = annotService + .getAnnotationResult(running.getJobHandle(), seqs, + featureColours, featureFilters); + + Cache.log.debug("Obtained " + (returnedAnnot == null ? "no rows" + : ("" + returnedAnnot.size()))); + Cache.log.debug("There were " + featureColours.size() + + " feature colours and " + featureFilters.size() + + " filters defined."); + + // TODO + // copy over each annotation row reurned and also defined on each + // sequence, excluding regions not annotated due to gapMap/column + // visibility + + running.setAnnotation(returnedAnnot); + + if (running.hasResults()) { - // TODO - // look at each sequence and lift over any features, excluding regions - // not annotated due to gapMap/column visibility - - jalview.bin.Cache.log.debug( - "Updating feature display settings and transferring features from Job " - + rslt + " at " + service.getUri()); - // TODO: consider merge rather than apply here - alignViewport.applyFeaturesStyle(new FeatureSettingsAdapter() + jalview.bin.Cache.log.debug("Updating result annotation from Job " + + rslt + " at " + service.getUri()); + updateResultAnnotation(true); + if (running.isTransferSequenceFeatures()) { - @Override - public FeatureColourI getFeatureColour(String type) + // TODO + // look at each sequence and lift over any features, excluding + // regions + // not annotated due to gapMap/column visibility + + jalview.bin.Cache.log.debug( + "Updating feature display settings and transferring features from Job " + + rslt + " at " + service.getUri()); + // TODO: consider merge rather than apply here + alignViewport.applyFeaturesStyle(new FeatureSettingsAdapter() { - return featureColours.get(type); - } + @Override + public FeatureColourI getFeatureColour(String type) + { + return featureColours.get(type); + } - @Override - public FeatureMatcherSetI getFeatureFilters(String type) - { - return featureFilters.get(type); - } + @Override + public FeatureMatcherSetI getFeatureFilters(String type) + { + return featureFilters.get(type); + } - @Override - public boolean isFeatureDisplayed(String type) - { - return featureColours.containsKey(type); - } + @Override + public boolean isFeatureDisplayed(String type) + { + return featureColours.containsKey(type); + } - }); - // TODO: JAL-1150 - create sequence feature settings API for defining - // styles and enabling/disabling feature overlay on alignment panel + }); + // TODO: JAL-1150 - create sequence feature settings API for + // defining + // styles and enabling/disabling feature overlay on alignment panel - if (alignFrame.alignPanel == ap) - { - alignViewport.setShowSequenceFeatures(true); - alignFrame.setMenusForViewport(); + if (alignFrame.alignPanel == ap) + { + alignViewport.setShowSequenceFeatures(true); + alignFrame.setMenusForViewport(); + } } + ap.adjustAnnotationHeight(); } - ap.adjustAnnotationHeight(); } Cache.log.debug("Annotation Service Worker thread finished."); } -- 1.7.10.2