Search in sources :

Example 11 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class TaskRunningServiceImpl method submitLocalTask.

@Override
public <T extends Task> String submitLocalTask(T task) {
    this.checkTask(task);
    TaskCommand taskCommand = task.getTaskCommand();
    this.checkTaskCommand(taskCommand);
    final String taskId = task.getTaskCommand().getTaskId();
    if (TaskRunningServiceImpl.log.isDebugEnabled()) {
        TaskRunningServiceImpl.log.debug("Submitting local task with id: " + taskId);
    }
    final SubmittedTaskLocal submittedTask = new SubmittedTaskLocal(task.getTaskCommand(), taskPostProcessing);
    final ExecutingTask<TaskResult> executingTask = new ExecutingTask<TaskResult>(task, taskCommand);
    executingTask.setStatusCallback(new ExecutingTask.TaskLifecycleHandler() {

        @Override
        public void onFailure(Throwable e) {
            TaskRunningServiceImpl.log.error(e, e);
            submittedTask.updateStatus(SubmittedTask.Status.FAILED, new Date());
        }

        @Override
        public void onFinish() {
            submittedTask.updateStatus(SubmittedTask.Status.COMPLETED, new Date());
        }

        @Override
        public void onStart() {
            submittedTask.updateStatus(SubmittedTask.Status.RUNNING, new Date());
        }
    });
    executingTask.setProgressAppender(new LogBasedProgressAppender(taskId, new ProgressUpdateCallback() {

        private final Queue<String> progressUpdates = submittedTask.getProgressUpdates();

        @Override
        public void addProgressUpdate(String message) {
            progressUpdates.add(message);
        }
    }));
    ListenableFuture<TaskResult> future = executorService.submit(executingTask);
    submittedTask.setFuture(future);
    // Currently we have only email notification.
    if (taskCommand.isEmailAlert()) {
        submittedTask.addEmailAlert();
    }
    submittedTasks.put(taskId, submittedTask);
    return taskId;
}
Also used : Date(java.util.Date) TaskResult(ubic.gemma.core.job.TaskResult) Queue(java.util.Queue) TaskCommand(ubic.gemma.core.job.TaskCommand)

Example 12 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class BioAssayOutlierProcessingTaskImpl method execute.

@Override
public TaskResult execute() {
    Collection<BioAssay> bioAssays = bioAssayService.load(taskCommand.getBioAssayIds());
    if (bioAssays.isEmpty()) {
        throw new RuntimeException("Could not locate the bioassays");
    }
    if (taskCommand.isRevert()) {
        sampleRemoveService.unmarkAsMissing(bioAssays);
    } else {
        sampleRemoveService.markAsMissing(bioAssays);
    }
    bioAssays = bioAssayService.thaw(bioAssays);
    Collection<BioAssayValueObject> flagged = new HashSet<>();
    for (BioAssay ba : bioAssays) {
        flagged.add(new BioAssayValueObject(ba, false));
    }
    return new TaskResult(taskCommand, flagged);
}
Also used : BioAssayValueObject(ubic.gemma.model.expression.bioAssay.BioAssayValueObject) TaskResult(ubic.gemma.core.job.TaskResult) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) HashSet(java.util.HashSet)

Example 13 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class ArrayDesignRepeatScanTaskImpl method execute.

@Override
public TaskResult execute() {
    ArrayDesign ad = taskCommand.getArrayDesign();
    ad = arrayDesignService.thaw(ad);
    Collection<BioSequence> sequences = ArrayDesignSequenceAlignmentServiceImpl.getSequences(ad);
    RepeatScan scanner = new RepeatScan();
    scanner.repeatScan(sequences);
    return new TaskResult(taskCommand, new ModelAndView(new RedirectView("/", true)));
}
Also used : BioSequence(ubic.gemma.model.genome.biosequence.BioSequence) ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) RepeatScan(ubic.gemma.core.analysis.sequence.RepeatScan) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) TaskResult(ubic.gemma.core.job.TaskResult)

Example 14 with TaskResult

use of ubic.gemma.core.job.TaskResult in project Gemma by PavlidisLab.

the class DifferentialExpressionAnalysisTaskImpl method execute.

@Override
public TaskResult execute() {
    if (taskCommand instanceof DifferentialExpressionAnalysisRemoveTaskCommand) {
        DifferentialExpressionAnalysis toRemove = ((DifferentialExpressionAnalysisRemoveTaskCommand) taskCommand).getToRemove();
        if (toRemove == null) {
            throw new IllegalArgumentException("Analysis to remove must not be null");
        }
        log.info("Removing analysis ...");
        this.differentialExpressionAnalysisService.remove(toRemove);
        return new TaskResult(taskCommand, true);
    }
    Collection<DifferentialExpressionAnalysis> results = doAnalysis();
    Collection<DifferentialExpressionAnalysis> minimalResults = new HashSet<>();
    for (DifferentialExpressionAnalysis r : results) {
        /* Don't send the full analysis to the space. Instead, create a minimal result. */
        DifferentialExpressionAnalysis minimalResult = DifferentialExpressionAnalysis.Factory.newInstance();
        minimalResult.setName(r.getName());
        minimalResult.setDescription(r.getDescription());
        minimalResult.setAuditTrail(r.getAuditTrail());
        minimalResults.add(minimalResult);
    }
    return new TaskResult(taskCommand, minimalResults);
}
Also used : DifferentialExpressionAnalysis(ubic.gemma.model.analysis.expression.diff.DifferentialExpressionAnalysis) TaskResult(ubic.gemma.core.job.TaskResult) HashSet(java.util.HashSet)

Aggregations

TaskResult (ubic.gemma.core.job.TaskResult)14 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)3 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)3 Date (java.util.Date)2 HashSet (java.util.HashSet)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 RedirectView (org.springframework.web.servlet.view.RedirectView)2 AnnotationValueObject (ubic.gemma.model.common.description.AnnotationValueObject)2 Characteristic (ubic.gemma.model.common.description.Characteristic)2 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Queue (java.util.Queue)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 View (org.springframework.web.servlet.View)1 RepeatScan (ubic.gemma.core.analysis.sequence.RepeatScan)1 EmailNotificationContext (ubic.gemma.core.job.EmailNotificationContext)1 SubmittedTask (ubic.gemma.core.job.SubmittedTask)1