use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyHistoriesService method filesToLibraryToHistory.
/**
* Uploads a set of files to a given history through the given library.
*
* @param paths
* The set of paths to upload.
* @param fileType
* The file type of the file to upload.
* @param history
* The history to upload the file into.
* @param library
* The library to initially upload the file into.
* @param dataStorage
* The type of DataStorage strategy to use.
* @return An {@link Map} of paths and ids for each dataset object in this
* history.
* @throws UploadException
* If there was an issue uploading the file to Galaxy.
*/
public Map<Path, String> filesToLibraryToHistory(Set<Path> paths, InputFileType fileType, History history, Library library, DataStorage dataStorage) throws UploadException {
checkNotNull(paths, "paths is null");
Map<Path, String> datasetIdsMap = new HashMap<>();
Map<Path, String> datasetLibraryIdsMap = librariesService.filesToLibraryWait(paths, fileType, library, dataStorage);
if (datasetLibraryIdsMap.size() != paths.size()) {
throw new UploadException("Error: datasets uploaded to a Galaxy library are not the same size (" + datasetLibraryIdsMap.size() + ") as the paths to upload (" + paths.size() + ")");
}
try {
for (Path path : datasetLibraryIdsMap.keySet()) {
String datasetLibraryId = datasetLibraryIdsMap.get(path);
HistoryDetails historyDetails = libraryDatasetToHistory(datasetLibraryId, history);
logger.debug("Transfered library dataset " + datasetLibraryId + " to history " + history.getId() + " dataset id " + historyDetails.getId());
datasetIdsMap.put(path, historyDetails.getId());
}
} catch (RuntimeException e) {
throw new UploadException(e);
}
return datasetIdsMap;
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails 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.HistoryDetails in project irida by phac-nml.
the class GalaxyWorkflowStatusTest method testBuildWorkflowStatusFromHistoryDetailsSuccessComplete.
/**
* Tests successfully building a workflow status from history details
* (everything complete).
*/
@Test
public void testBuildWorkflowStatusFromHistoryDetailsSuccessComplete() {
HistoryDetails historyDetails = new HistoryDetails();
historyDetails.setState("ok");
historyDetails.setStateIds(Util.buildStateIdsWithStateFilled("ok", Lists.newArrayList(DATASET_ID)));
GalaxyWorkflowStatus workflowStatus = GalaxyWorkflowStatus.builder(historyDetails).build();
assertEquals("workflow status not in correct state", GalaxyWorkflowState.OK, workflowStatus.getState());
assertEquals("percentage complete not correct", 1.0f, workflowStatus.getProportionComplete(), DELTA);
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyWorkflowStatusTest method testErrorOccuredDiscarded.
/**
* Tests whether or not this workflow is in an error state when it is discarded.
*/
@Test
public void testErrorOccuredDiscarded() {
HistoryDetails historyDetails = new HistoryDetails();
historyDetails.setState("discarded");
historyDetails.setStateIds(Util.buildStateIdsWithStateFilled("discarded", Lists.newArrayList(DATASET_ID)));
GalaxyWorkflowStatus workflowStatus = GalaxyWorkflowStatus.builder(historyDetails).build();
assertTrue("Workflow is not in an error state", workflowStatus.errorOccurred());
}
use of com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails in project irida by phac-nml.
the class GalaxyWorkflowStatusTest method testBuildWorkflowStatusFromHistoryDetailsSuccessQueued.
/**
* Tests successfully building a workflow status from history details (still
* queued).
*/
@Test
public void testBuildWorkflowStatusFromHistoryDetailsSuccessQueued() {
HistoryDetails historyDetails = new HistoryDetails();
historyDetails.setState("queued");
historyDetails.setStateIds(Util.buildStateIdsWithStateFilled("queued", Lists.newArrayList(DATASET_ID)));
GalaxyWorkflowStatus workflowStatus = GalaxyWorkflowStatus.builder(historyDetails).build();
assertEquals("workflow status not in correct state", GalaxyWorkflowState.QUEUED, workflowStatus.getState());
assertEquals("percentage complete not correct", 0.0f, workflowStatus.getProportionComplete(), DELTA);
}
Aggregations