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