Search in sources :

Example 6 with WorkflowOutputs

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

the class GalaxyWorkflowsIT method testExecuteWorkflow.

/**
 * Tests executing a single workflow in Galaxy.
 * @throws ExecutionManagerException
 */
@Test
public void testExecuteWorkflow() throws ExecutionManagerException {
    String workflowId = localGalaxy.getSingleInputWorkflowId();
    String workflowInputLabel = localGalaxy.getSingleInputWorkflowLabel();
    WorkflowOutputs workflowOutput = runSingleFileWorkflow(dataFile1, FILE_TYPE, workflowId, workflowInputLabel);
    assertNotNull(workflowOutput);
    assertNotNull(workflowOutput.getHistoryId());
    // history should exist
    HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
    assertNotNull(historyDetails);
    // outputs should exist
    assertNotNull(workflowOutput.getOutputIds());
    assertTrue(workflowOutput.getOutputIds().size() > 0);
    // each output dataset should exist
    for (String outputId : workflowOutput.getOutputIds()) {
        Dataset dataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
        assertNotNull(dataset);
    }
    // test get workflow status
    GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    float percentComplete = workflowStatus.getProportionComplete();
    assertTrue(0.0f <= percentComplete && percentComplete <= 1.0f);
}
Also used : WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Example 7 with WorkflowOutputs

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

the class GalaxyWorkflowsIT method runSingleFileTabularWorkflow.

/**
 * Runs a test workflow with the given parameters and input file.
 *
 * @param workflowId
 *            The id of the workflow to run.
 * @param workflowInputLabel
 *            The lable of the input for the workflow.
 * @param history
 *            The history to run the workflow in.
 * @param inputFile
 *            The file to run the workflow on.
 * @param toolName
 *            The toolName of a parameter to override.
 * @param toolParameter
 *            The overridden tool parameter.
 * @return A {@link WorkflowOutputs} for this workflow.
 * @throws ExecutionManagerException
 */
private WorkflowOutputs runSingleFileTabularWorkflow(String workflowId, String workflowInputLabel, History history, Path inputFile, String toolName, ToolParameter toolParameter) throws ExecutionManagerException {
    checkArgument(Files.exists(inputFile), "inputFile " + inputFile + " does not exist");
    WorkflowDetails workflowDetails = workflowsClient.showWorkflow(workflowId);
    // upload dataset to history
    Dataset inputDataset = fileToHistory(inputFile, "tabular", history.getId());
    assertNotNull(inputDataset);
    String workflowInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, workflowInputLabel);
    WorkflowInputs inputs = new WorkflowInputs();
    inputs.setDestination(new WorkflowInputs.ExistingHistory(history.getId()));
    inputs.setWorkflowId(workflowDetails.getId());
    inputs.setInput(workflowInputId, new WorkflowInputs.WorkflowInput(inputDataset.getId(), WorkflowInputs.InputSourceType.HDA));
    inputs.setToolParameter(toolName, 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)

Example 8 with WorkflowOutputs

use of com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs 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 9 with WorkflowOutputs

use of com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs 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)

Aggregations

WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)9 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)6 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)6 Test (org.junit.Test)6 History (com.github.jmchilton.blend4j.galaxy.beans.History)5 HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)3 WorkflowDetails (com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails)3 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)3 ToolParameter (com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)2 Path (java.nio.file.Path)2 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)1 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)1 LinkedList (java.util.LinkedList)1