Search in sources :

Example 16 with HistoryDetails

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);
}
Also used : Path(java.nio.file.Path) 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) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 17 with HistoryDetails

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

Example 18 with HistoryDetails

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));
}
Also used : HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoryDataset(com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset) Test(org.junit.Test)

Example 19 with HistoryDetails

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;
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) Map(java.util.Map) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) GalaxyWorkflowState(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) JobsClient(com.github.jmchilton.blend4j.galaxy.JobsClient) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) ArrayList(java.util.ArrayList) JobError(ca.corefacility.bioinformatics.irida.model.workflow.analysis.JobError) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) JobDetails(com.github.jmchilton.blend4j.galaxy.beans.JobDetails) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool)

Example 20 with HistoryDetails

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);
    }
}
Also used : ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) WorkflowException(ca.corefacility.bioinformatics.irida.exceptions.WorkflowException)

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