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);
}
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());
}
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);
}
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);
}
}
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;
}
Aggregations