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