Search in sources :

Example 21 with HistoryDetails

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;
}
Also used : Path(java.nio.file.Path) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) HashMap(java.util.HashMap) UploadException(ca.corefacility.bioinformatics.irida.exceptions.UploadException)

Example 22 with HistoryDetails

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);
}
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 23 with HistoryDetails

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);
}
Also used : HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Example 24 with HistoryDetails

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());
}
Also used : HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Example 25 with HistoryDetails

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);
}
Also used : HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) Test(org.junit.Test)

Aggregations

HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)28 Test (org.junit.Test)25 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)18 List (java.util.List)5 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)3 WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)3 History (com.github.jmchilton.blend4j.galaxy.beans.History)2 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)2 Path (java.nio.file.Path)2 UploadException (ca.corefacility.bioinformatics.irida.exceptions.UploadException)1 WorkflowException (ca.corefacility.bioinformatics.irida.exceptions.WorkflowException)1 JobError (ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError)1 GalaxyWorkflowState (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState)1 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)1 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)1 JobsClient (com.github.jmchilton.blend4j.galaxy.JobsClient)1 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)1 HistoryDataset (com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset)1 JobDetails (com.github.jmchilton.blend4j.galaxy.beans.JobDetails)1 Library (com.github.jmchilton.blend4j.galaxy.beans.Library)1