use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyWorkflowsIT method testExecuteCollectionsPairedList.
/**
* Tests executing a collections paired list workflow.
* @throws ExecutionManagerException
*/
@Test
public void testExecuteCollectionsPairedList() throws ExecutionManagerException {
String workflowId = localGalaxy.getWorklowCollectionListId();
String workflowInputLabel = localGalaxy.getWorkflowCollectionListLabel();
List<Path> dataFilesForward = new LinkedList<Path>();
dataFilesForward.add(dataFile1);
dataFilesForward.add(dataFile2);
List<Path> dataFilesReverse = new LinkedList<Path>();
dataFilesReverse.add(dataFile3);
dataFilesReverse.add(dataFile4);
WorkflowOutputs workflowOutput = runSingleCollectionWorkflow(dataFilesForward, dataFilesReverse, 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());
assertEquals(1, workflowOutput.getOutputIds().size());
String outputId = workflowOutput.getOutputIds().get(0);
// output dataset should exist
Dataset outputDataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
assertNotNull(outputDataset);
// 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.HistoryDetails in project irida by phac-nml.
the class GalaxyWorkflowsIT method testExecuteWorkflowChangeToolParameter.
/**
* Tests executing a single workflow in Galaxy and changing a single tool
* parameter.
*
* @throws ExecutionManagerException
*/
@Test
public void testExecuteWorkflowChangeToolParameter() throws ExecutionManagerException {
String toolId = "Grep1";
String workflowId = localGalaxy.getSingleInputWorkflowId();
String workflowInputLabel = localGalaxy.getSingleInputWorkflowLabel();
Map<String, ToolParameter> toolParameters = ImmutableMap.of(toolId, new ToolParameter("pattern", "^#"));
WorkflowOutputs workflowOutput = runSingleFileWorkflow(dataFile1, FILE_TYPE, workflowId, workflowInputLabel, toolParameters);
assertNotNull("workflowOutput should not be null", workflowOutput);
assertNotNull("workflowOutput history id should not be null", workflowOutput.getHistoryId());
// history should exist
HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
assertNotNull("historyDetails for the history for the workflow should not be null", historyDetails);
// outputs should exist
assertNotNull("outputIds for the workflow should not be null", workflowOutput.getOutputIds());
assertTrue("there should exist output dataset ids for the workflow", workflowOutput.getOutputIds().size() > 0);
// each output dataset should exist
for (String outputId : workflowOutput.getOutputIds()) {
Dataset dataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
assertNotNull("the output dataset should exist", dataset);
HistoryContentsProvenance provenance = historiesClient.showProvenance(workflowOutput.getHistoryId(), dataset.getId());
if (toolId.equals(provenance.getToolId())) {
Map<String, Object> parametersMap = provenance.getParameters();
assertEquals("pattern parameter is correct", "\"^#\"", parametersMap.get("pattern"));
}
}
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
float proportionComplete = workflowStatus.getProportionComplete();
assertTrue("the workflow proportion complete should be between 0 and 1", 0.0f <= proportionComplete && proportionComplete <= 1.0f);
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyHistoriesServiceTest method testLibraryDatasetToHistory.
/**
* Tests moving a library dataset to a history.
*/
@Test
public void testLibraryDatasetToHistory() {
HistoryDetails historyDetails = new HistoryDetails();
History createdHistory = new History();
createdHistory.setId(HISTORY_ID);
when(historiesClient.createHistoryDataset(any(String.class), any(HistoryDataset.class))).thenReturn(historyDetails);
assertNotNull(galaxyHistory.libraryDatasetToHistory(libraryFileId, createdHistory));
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyJobErrorsService method createNewJobErrors.
/**
* Get any {@link JobError} associated with an {@link AnalysisSubmission}
*
* @param analysisSubmission {@link AnalysisSubmission} to search for job failures
* @return List of {@link JobError} objects associated with {@link AnalysisSubmission}
*/
public List<JobError> createNewJobErrors(AnalysisSubmission analysisSubmission) {
String historyId = analysisSubmission.getRemoteAnalysisId();
HistoryDetails historyDetails = historiesClient.showHistory(historyId);
List<String> erroredDatasetIds = historyDetails.getStateIds().get(GalaxyWorkflowState.ERROR.toString());
List<HistoryContentsProvenance> provenances = erroredDatasetIds.stream().map((x) -> historiesClient.showProvenance(historyId, x)).collect(Collectors.toList());
Map<String, List<HistoryContentsProvenance>> jobIdProvenancesMap = provenances.stream().collect(Collectors.groupingBy(HistoryContentsProvenance::getJobId));
List<JobError> jobErrors = new ArrayList<>();
for (Map.Entry<String, List<HistoryContentsProvenance>> entry : jobIdProvenancesMap.entrySet()) {
String jobId = entry.getKey();
JobDetails jobDetails = jobsClient.showJob(jobId);
HistoryContentsProvenance p = entry.getValue().iterator().next();
Tool tool = toolsClient.showTool(p.getToolId());
jobErrors.add(new JobError(analysisSubmission, jobDetails, p, tool));
}
return jobErrors;
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyHistoriesService method getStatusForHistory.
/**
* Given a history id returns the status for the given workflow.
*
* @param historyId
* The history id to use to find a workflow.
* @return The WorkflowStatus for the given workflow.
* @throws ExecutionManagerException
* If there was an exception when attempting to get the status
* for a history.
*/
public GalaxyWorkflowStatus getStatusForHistory(String historyId) throws ExecutionManagerException {
checkNotNull(historyId, "historyId is null");
try {
HistoryDetails details = historiesClient.showHistory(historyId);
logger.trace("Details for history " + details.getId() + ": state=" + details.getState());
return GalaxyWorkflowStatus.builder(details).build();
} catch (ClientHandlerException | UniformInterfaceException e) {
throw new WorkflowException(e);
}
}
Aggregations