Search in sources :

Example 1 with JobError

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError in project irida by phac-nml.

the class AnalysesListingService method createDataTablesAnalysis.

/**
 * Convert a {@link AnalysisSubmission} to a {@link DTAnalysis} to be used by DataTables on the client.
 *
 * @param submission {@link AnalysisSubmission}
 * @param locale     {@link Locale}
 * @return {@link DTAnalysis}
 * @throws IridaWorkflowNotFoundException If the requested workflow doesn't exist
 * @throws ExecutionManagerException      If the submission cannot be read properly
 */
private DTAnalysis createDataTablesAnalysis(AnalysisSubmission submission, Locale locale) throws IridaWorkflowNotFoundException, ExecutionManagerException {
    Long id = submission.getId();
    String name = submission.getName();
    String submitter = submission.getSubmitter().getLabel();
    Date createdDate = submission.getCreatedDate();
    float percentComplete = 0;
    AnalysisState analysisState = submission.getAnalysisState();
    JobError error = null;
    if (analysisState.equals(AnalysisState.ERROR)) {
        error = getFirstJobError(submission);
    } else {
        percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(submission.getId());
    }
    String workflowType = iridaWorkflowsService.getIridaWorkflow(submission.getWorkflowId()).getWorkflowDescription().getAnalysisType().toString();
    String workflow = messageSource.getMessage("workflow." + workflowType + ".title", null, locale);
    String state = messageSource.getMessage("analysis.state." + analysisState.toString(), null, locale);
    Long duration = 0L;
    if (analysisState.equals(AnalysisState.COMPLETED)) {
        duration = getDurationInMilliseconds(submission.getCreatedDate(), submission.getAnalysis().getCreatedDate());
    }
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    boolean updatePermission = updateAnalysisPermission.isAllowed(authentication, submission);
    return new DTAnalysis(id, name, submitter, percentComplete, createdDate, workflow, state, error, duration, updatePermission);
}
Also used : AnalysisState(ca.corefacility.bioinformatics.irida.model.enums.AnalysisState) Authentication(org.springframework.security.core.Authentication) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) DTAnalysis(ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis)

Example 2 with JobError

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError in project irida by phac-nml.

the class GalaxyJobErrorsServiceIT method testSuccessfulAnalysisReturnsNoJobErrors.

/**
 * Test that a successfully completed Galaxy workflow analysis does not return any {@link JobError}s
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testSuccessfulAnalysisReturnsNoJobErrors() throws Exception {
    databaseSetupGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, validIridaWorkflowId, false);
    AnalysisSubmission submission = runAnalysis();
    List<JobError> errors = galaxyJobErrorsService.createNewJobErrors(submission);
    assertTrue(errors.isEmpty());
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 3 with JobError

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImplIT method testFullAnalysisRunFailErrorWithJob.

/**
 * Tests out failing to complete execution of a workflow due to an error
 * with the workflow causing a job to fail.
 *
 * @throws Throwable
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testFullAnalysisRunFailErrorWithJob() throws Throwable {
    analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, iridaWorkflowIdWithError, false);
    // PREPARE SUBMISSION
    Set<Future<AnalysisSubmission>> submissionsFutureSet = analysisExecutionScheduledTask.prepareAnalyses();
    assertEquals(1, submissionsFutureSet.size());
    // wait until finished
    for (Future<AnalysisSubmission> submissionFuture : submissionsFutureSet) {
        AnalysisSubmission returnedSubmission = submissionFuture.get();
        assertEquals(AnalysisState.PREPARED, returnedSubmission.getAnalysisState());
    }
    // EXECUTE SUBMISSION
    submissionsFutureSet = analysisExecutionScheduledTask.executeAnalyses();
    assertEquals(1, submissionsFutureSet.size());
    AnalysisSubmission executedSubmission = submissionsFutureSet.iterator().next().get();
    assertEquals(AnalysisState.RUNNING, executedSubmission.getAnalysisState());
    // wait until Galaxy finished
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(executedSubmission);
    // CHECK STATUS, should be in ERROR state.
    submissionsFutureSet = analysisExecutionScheduledTask.monitorRunningAnalyses();
    assertEquals(1, submissionsFutureSet.size());
    AnalysisSubmission returnedSubmission = submissionsFutureSet.iterator().next().get();
    assertEquals(AnalysisState.ERROR, returnedSubmission.getAnalysisState());
    List<JobError> jobErrors = jobErrorRepository.findAllByAnalysisSubmission(returnedSubmission);
    assertTrue("There should only be one JobError", jobErrors.size() == 1);
    JobError jobError = jobErrors.get(0);
    assertTrue("JobError should have some stderr message", jobError.getStandardError() != null && !jobError.getStandardError().equals(""));
    assertTrue("JobError should be triggered by 'IndexError: list index out of range'", jobError.getStandardError().contains("IndexError: list index out of range"));
    assertTrue("JobError tool ID should be 'Filter1'", jobError.getToolId().equals("Filter1"));
    assertTrue("JobError exit code should be '1'", jobError.getExitCode() == 1);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Future(java.util.concurrent.Future) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 4 with JobError

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError in project irida by phac-nml.

the class AnalysisExecutionScheduledTaskImpl method handleJobErrors.

/**
 * Handle async saving of {@link JobError} objects for a {@link AnalysisSubmission}
 * to database through {@link JobErrorRepository} if there are any
 *
 * @param analysisSubmission {@link AnalysisSubmission} object to get and save {@link JobError}s for
 */
private void handleJobErrors(AnalysisSubmission analysisSubmission) {
    List<JobError> jobErrors = galaxyJobErrorsService.createNewJobErrors(analysisSubmission);
    for (JobError jobError : jobErrors) {
        logger.warn("AnalysisSubmission [id=" + analysisSubmission.getId() + "] had a JobError [jobId=" + jobError.getJobId() + ", toolId=" + jobError.getToolId() + ", exitCode=" + jobError.getExitCode() + "]");
        jobErrorRepository.save(jobError);
    }
}
Also used : JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError)

Example 5 with JobError

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError in project irida by phac-nml.

the class GalaxyJobErrorsService method createNewJobErrors.

/**
 * Get any {@link JobError} associated with an {@link AnalysisSubmission}
 *
 * @param analysisSubmission {@link AnalysisSubmission} to search for job failures
 * @return List of {@link JobError} objects associated with {@link AnalysisSubmission}
 */
public List<JobError> createNewJobErrors(AnalysisSubmission analysisSubmission) {
    String historyId = analysisSubmission.getRemoteAnalysisId();
    HistoryDetails historyDetails = historiesClient.showHistory(historyId);
    List<String> erroredDatasetIds = historyDetails.getStateIds().get(GalaxyWorkflowState.ERROR.toString());
    List<HistoryContentsProvenance> provenances = erroredDatasetIds.stream().map((x) -> historiesClient.showProvenance(historyId, x)).collect(Collectors.toList());
    Map<String, List<HistoryContentsProvenance>> jobIdProvenancesMap = provenances.stream().collect(Collectors.groupingBy(HistoryContentsProvenance::getJobId));
    List<JobError> jobErrors = new ArrayList<>();
    for (Map.Entry<String, List<HistoryContentsProvenance>> entry : jobIdProvenancesMap.entrySet()) {
        String jobId = entry.getKey();
        JobDetails jobDetails = jobsClient.showJob(jobId);
        HistoryContentsProvenance p = entry.getValue().iterator().next();
        Tool tool = toolsClient.showTool(p.getToolId());
        jobErrors.add(new JobError(analysisSubmission, jobDetails, p, tool));
    }
    return jobErrors;
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) Map(java.util.Map) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowState(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) JobsClient(com.github.jmchilton.blend4j.galaxy.JobsClient) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) ArrayList(java.util.ArrayList) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool)

Aggregations

JobError (ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError)6 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)4 Test (org.junit.Test)3 WithMockUser (org.springframework.security.test.context.support.WithMockUser)3 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 GalaxyWorkflowState (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState)1 DTAnalysis (ca.corefacility.bioinformatics.irida.ria.web.models.datatables.DTAnalysis)1 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)1 JobsClient (com.github.jmchilton.blend4j.galaxy.JobsClient)1 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)1 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)1 HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)1 JobDetails (com.github.jmchilton.blend4j.galaxy.beans.JobDetails)1 Tool (com.github.jmchilton.blend4j.galaxy.beans.Tool)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1 Authentication (org.springframework.security.core.Authentication)1