Search in sources :

Example 1 with WorkflowUploadException

use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.WorkflowUploadException in project irida by phac-nml.

the class GalaxyWorkflowService method uploadGalaxyWorkflow.

/**
 * Uploads a workflow definined in the given file to Galaxy.
 * @param workflowFile  The file to upload.
 * @return  The id of the workflow in Galaxy.
 * @throws IOException If there was an issue reading the file.
 * @throws WorkflowUploadException If there was an issue uploading the workflow to Galaxy.
 */
public String uploadGalaxyWorkflow(Path workflowFile) throws IOException, WorkflowUploadException {
    checkNotNull(workflowFile, "workflowFile is null");
    byte[] fileBytes = Files.readAllBytes(workflowFile);
    String workflowString = new String(fileBytes, workflowCharset);
    try {
        Workflow workflow = workflowsClient.importWorkflow(workflowString);
        return workflow.getId();
    } catch (RuntimeException e) {
        throw new WorkflowUploadException("Could not upload workflow from " + workflowFile, e);
    }
}
Also used : Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) WorkflowUploadException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.WorkflowUploadException)

Example 2 with WorkflowUploadException

use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.WorkflowUploadException in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyTest method testPrepareSubmissionFailInvalidWorkflow.

/**
 * Tests failing to prepare an analysis due to an issue when uploading the
 * workflow.
 *
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws ExecutionException
 */
@Test(expected = WorkflowUploadException.class)
public void testPrepareSubmissionFailInvalidWorkflow() throws InterruptedException, IOException, IridaWorkflowNotFoundException, ExecutionManagerException, ExecutionException {
    when(galaxyWorkflowService.uploadGalaxyWorkflow(workflowFile)).thenThrow(new WorkflowUploadException(null, null));
    when(analysisSubmissionService.update(analysisSubmission)).thenReturn(analysisPreparing);
    analysisSubmission.setAnalysisState(AnalysisState.NEW);
    Future<AnalysisSubmission> preparedAnalysisFuture = workflowManagement.prepareSubmission(analysisSubmission);
    ArgumentCaptor<AnalysisSubmission> captor = ArgumentCaptor.forClass(AnalysisSubmission.class);
    verify(analysisSubmissionService).update(captor.capture());
    AnalysisSubmission value = captor.getValue();
    assertEquals(INTERNAL_ANALYSIS_ID, value.getId());
    assertEquals(AnalysisState.ERROR, value.getAnalysisState());
    assertTrue(preparedAnalysisFuture.isDone());
    preparedAnalysisFuture.get();
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) WorkflowUploadException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.WorkflowUploadException) Test(org.junit.Test)

Aggregations

WorkflowUploadException (ca.corefacility.bioinformatics.irida.exceptions.galaxy.WorkflowUploadException)2 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)1 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)1 Test (org.junit.Test)1