Search in sources :

Example 41 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyWorkflowsIT method testGetWorkflowStatusError.

/**
 * Tests executing a single workflow in Galaxy and getting an error status after completion.
 * @throws ExecutionManagerException
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test
public void testGetWorkflowStatusError() throws ExecutionManagerException, TimeoutException, InterruptedException {
    History history = galaxyHistory.newHistoryForWorkflow();
    // no column c2 for this input file, so should give an error
    WorkflowOutputs workflowOutput = runSingleFileTabularWorkflowFilterTool(history, dataFile1, INVALID_FILTER_PARAMETER);
    Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
    // test get workflow status
    GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    assertEquals("final workflow state is invalid", GalaxyWorkflowState.ERROR, workflowStatus.getState());
    assertTrue("final workflow state is invalid", workflowStatus.errorOccurred());
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) History(com.github.jmchilton.blend4j.galaxy.beans.History) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Example 42 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyWorkflowsIT method runSingleFileWorkflow.

/**
 * Starts the execution of a workflow with a single fastq file and the given workflow id.
 * @param inputFile  An input file to start the workflow.
 * @param inputFileType The file type of the input file.
 * @param workflowId  The id of the workflow to start.
 * @param workflowInputLabel The label of a workflow input in Galaxy.
 * @param toolParameters  A map of tool parameters to set.
 * @throws ExecutionManagerException If there was an error executing the workflow.
 */
private WorkflowOutputs runSingleFileWorkflow(Path inputFile, InputFileType inputFileType, String workflowId, String workflowInputLabel, Map<String, ToolParameter> toolParameters) throws ExecutionManagerException {
    checkNotNull(inputFile, "file is null");
    checkNotNull(inputFileType, "inputFileType is null");
    checkNotNull(workflowInputLabel, "workflowInputLabel is null");
    checkArgument(Files.exists(inputFile), "inputFile " + inputFile + " does not exist");
    History workflowHistory = galaxyHistory.newHistoryForWorkflow();
    WorkflowDetails workflowDetails = workflowsClient.showWorkflow(workflowId);
    // upload dataset to history
    Dataset inputDataset = galaxyHistory.fileToHistory(inputFile, inputFileType, workflowHistory);
    assertNotNull(inputDataset);
    String workflowInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, workflowInputLabel);
    WorkflowInputs inputs = new WorkflowInputs();
    inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
    inputs.setWorkflowId(workflowDetails.getId());
    inputs.setInput(workflowInputId, new WorkflowInputs.WorkflowInput(inputDataset.getId(), WorkflowInputs.InputSourceType.HDA));
    if (toolParameters != null) {
        for (String toolId : toolParameters.keySet()) {
            ToolParameter toolParameter = toolParameters.get(toolId);
            inputs.setToolParameter(toolId, toolParameter);
        }
    }
    // execute workflow
    WorkflowOutputs output = workflowsClient.runWorkflow(inputs);
    logger.debug("Running workflow in history " + output.getHistoryId());
    return output;
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) ToolParameter(com.github.jmchilton.blend4j.galaxy.beans.ToolParameter) History(com.github.jmchilton.blend4j.galaxy.beans.History)

Example 43 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyWorkflowsIT method testGetWorkflowStatusErrorWhileRunning.

/**
 * Tests executing a single workflow in Galaxy and getting an error status if one of the tools is in error even while running.
 * @throws ExecutionManagerException
 * @throws InterruptedException
 * @throws TimeoutException
 */
@Test
public void testGetWorkflowStatusErrorWhileRunning() throws ExecutionManagerException, TimeoutException, InterruptedException {
    final String SLEEP_TIME_SECONDS = "30";
    History history = galaxyHistory.newHistoryForWorkflow();
    WorkflowOutputs workflowOutput = runSingleFileTabularWorkflowFilterTool(history, dataFile1, INVALID_FILTER_PARAMETER);
    Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
    // test get workflow status, should be in error
    GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    assertEquals("final workflow state is invalid", GalaxyWorkflowState.ERROR, workflowStatus.getState());
    // run a sleep workflow to keep busy
    runSingleFileTabularWorkflowSleepTool(history, dataFile2, SLEEP_TIME_SECONDS);
    // check status.  I'm assuming the tasks launched above are not complete.
    workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    assertTrue("workflow should still be running", workflowStatus.isRunning());
    assertTrue("an error should have occured even while running", workflowStatus.errorOccurred());
    Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
    workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    assertEquals("workflow state should be in error after completion", GalaxyWorkflowState.ERROR, workflowStatus.getState());
    assertTrue("workflow is not in error state", workflowStatus.errorOccurred());
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) History(com.github.jmchilton.blend4j.galaxy.beans.History) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Example 44 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyHistoriesServiceTest method testFileToHistoryFailUpload.

/**
 * Tests failing to upload a file to a history.
 * @throws UploadException
 * @throws GalaxyDatasetException
 */
@Test(expected = UploadException.class)
public void testFileToHistoryFailUpload() throws UploadException, GalaxyDatasetException {
    History createdHistory = new History();
    createdHistory.setId(HISTORY_ID);
    when(toolsClient.uploadRequest(any(FileUploadRequest.class))).thenReturn(invalidResponse);
    galaxyHistory.fileToHistory(dataFile, FILE_TYPE, createdHistory);
}
Also used : FileUploadRequest(com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Example 45 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyHistoriesServiceTest method testConstructCollectionFail.

/**
 * Tests failing to construct a dataset collection.
 * @throws ExecutionManagerException
 */
@Test(expected = ExecutionManagerException.class)
public void testConstructCollectionFail() throws ExecutionManagerException {
    History history = new History();
    history.setId(HISTORY_ID);
    HistoryDatasetElement datasetElement = new HistoryDatasetElement();
    datasetElement.setId(DATA_ID);
    CollectionDescription description = new CollectionDescription();
    description.addDatasetElement(datasetElement);
    when(historiesClient.createDatasetCollection(eq(HISTORY_ID), any(CollectionDescription.class))).thenThrow(new RuntimeException());
    galaxyHistory.constructCollection(description, history);
}
Also used : CollectionDescription(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) HistoryDatasetElement(com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Aggregations

History (com.github.jmchilton.blend4j.galaxy.beans.History)61 Test (org.junit.Test)54 Path (java.nio.file.Path)25 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)24 WithMockUser (org.springframework.security.test.context.support.WithMockUser)22 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)19 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)19 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)17 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)11 Library (com.github.jmchilton.blend4j.galaxy.beans.Library)10 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)9 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)8 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)8 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)7 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)7 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)7 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)6 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)6