Search in sources :

Example 21 with GalaxyWorkflowStatus

use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus 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 22 with GalaxyWorkflowStatus

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

Example 23 with GalaxyWorkflowStatus

use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.

the class Util method waitUntilHistoryComplete.

/**
 * Waits for the given history to complete or until a timeout occurs.
 * @param historyId  The id of the history to wait for.
 * @param historyService  The history service to get the status of the history.
 * @param timeout  The timeout, in seconds.
 * @throws TimeoutException  If a timeout occurs
 * @throws ExecutionManagerException
 * @throws InterruptedException
 */
public static void waitUntilHistoryComplete(String historyId, GalaxyHistoriesService historyService, int timeout) throws TimeoutException, ExecutionManagerException, InterruptedException {
    GalaxyWorkflowStatus workflowStatus;
    long timeBefore = System.currentTimeMillis();
    do {
        workflowStatus = historyService.getStatusForHistory(historyId);
        long timeAfter = System.currentTimeMillis();
        double deltaSeconds = (timeAfter - timeBefore) / 1000.0;
        if (deltaSeconds <= timeout) {
            Thread.sleep(2000);
        } else {
            throw new TimeoutException("Timeout for history " + historyId + " " + deltaSeconds + "s > " + timeout + "s");
        }
    } while (!(GalaxyWorkflowState.OK.equals(workflowStatus.getState()) || GalaxyWorkflowState.ERROR.equals(workflowStatus.getState())));
}
Also used : GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) TimeoutException(java.util.concurrent.TimeoutException)

Example 24 with GalaxyWorkflowStatus

use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus 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 25 with GalaxyWorkflowStatus

use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus 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)

Aggregations

GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)36 Test (org.junit.Test)32 HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)18 WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)6 GalaxyWorkflowState (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowState)5 List (java.util.List)5 Set (java.util.Set)5 History (com.github.jmchilton.blend4j.galaxy.beans.History)4 LinkedList (java.util.LinkedList)4 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)3 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)3 ArrayList (java.util.ArrayList)3 TimeoutException (java.util.concurrent.TimeoutException)2 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)1 NoPercentageCompleteException (ca.corefacility.bioinformatics.irida.exceptions.NoPercentageCompleteException)1 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)1 ToolParameter (com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)1 Path (java.nio.file.Path)1 Future (java.util.concurrent.Future)1