use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class AnalysisExecutionScheduledTaskImplTest method testMonitorRunningAnalysesSuccessFinished.
/**
* Tests successfully switching analysis state to
* {@link AnalysisState.FINISHED_RUNNING} on success in Galaxy.
*
* @throws ExecutionManagerException
* @throws IridaWorkflowNotFoundException
*/
@Test
public void testMonitorRunningAnalysesSuccessFinished() throws ExecutionManagerException, IridaWorkflowNotFoundException {
analysisSubmission.setAnalysisState(AnalysisState.RUNNING);
Map<GalaxyWorkflowState, Set<String>> stateIds = Util.buildStateIdsWithStateFilled(GalaxyWorkflowState.OK, Sets.newHashSet("1"));
GalaxyWorkflowStatus galaxyWorkflowStatus = new GalaxyWorkflowStatus(GalaxyWorkflowState.OK, stateIds);
when(analysisSubmissionRepository.findByAnalysisState(AnalysisState.RUNNING)).thenReturn(Arrays.asList(analysisSubmission));
when(analysisExecutionService.getWorkflowStatus(analysisSubmission)).thenReturn(galaxyWorkflowStatus);
analysisExecutionScheduledTask.monitorRunningAnalyses();
assertEquals(AnalysisState.FINISHED_RUNNING, analysisSubmission.getAnalysisState());
verify(analysisSubmissionRepository).save(analysisSubmission);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method waitUntilSubmissionComplete.
/**
* Wait for the given analysis submission to be complete.
*
* @param analysisSubmission
* The analysis submission to wait for.
* @throws Exception
*/
public void waitUntilSubmissionComplete(AnalysisSubmission analysisSubmission) throws Exception {
// 3 minutes
final int totalSecondsWait = 3 * 60;
// 2 seconds
final int pollingTime = 2000;
Future<Void> waitForHistory = executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
GalaxyWorkflowStatus workflowStatus;
do {
workflowStatus = analysisExecutionService.getWorkflowStatus(analysisSubmission);
Thread.sleep(pollingTime);
} while (!(GalaxyWorkflowState.OK.equals(workflowStatus.getState()) || GalaxyWorkflowState.ERROR.equals(workflowStatus.getState())));
return null;
}
});
try {
waitForHistory.get(totalSecondsWait, TimeUnit.SECONDS);
} catch (TimeoutException e) {
throw new Exception("Timeout > " + totalSecondsWait + " s when waiting for history for " + analysisSubmission, e);
}
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class AnalysisSubmissionServiceImpl method getPercentCompleteForAnalysisSubmission.
/**
* {@inheritDoc}
*/
@Override
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#id, 'canReadAnalysisSubmission')")
public float getPercentCompleteForAnalysisSubmission(Long id) throws EntityNotFoundException, ExecutionManagerException, NoPercentageCompleteException {
AnalysisSubmission analysisSubmission = read(id);
AnalysisState analysisState = analysisSubmission.getAnalysisState();
switch(analysisState) {
case NEW:
case PREPARING:
case PREPARED:
case SUBMITTING:
return STATE_PERCENTAGE.get(analysisState);
/**
* If the analysis is in a state of {@link AnalysisState.RUNNING}
* then we are able to ask Galaxy for the proportion of jobs that
* are complete. We can scale this value between RUNNING_PERCENT
* (10%) and FINISHED_RUNNING_PERCENT (90%) so that after all jobs
* are complete we are only at 90%. The remaining 10% involves
* transferring files back to Galaxy.
*
* For example, if there are 10 out of 20 jobs finished on Galaxy,
* then the proportion of jobs complete is 10/20 = 0.5. So, the
* percent complete for the overall analysis is: percentComplete =
* 10 + (90 - 10) * 0.5 = 50%.
*
* If there are 20 out of 20 jobs finished in Galaxy, then the
* percent complete is: percentComplete = 10 + (90 - 10) * 1.0 =
* 90%.
*/
case RUNNING:
String workflowHistoryId = analysisSubmission.getRemoteAnalysisId();
GalaxyWorkflowStatus workflowStatus = galaxyHistoriesService.getStatusForHistory(workflowHistoryId);
return RUNNING_PERCENT + (FINISHED_RUNNING_PERCENT - RUNNING_PERCENT) * workflowStatus.getProportionComplete();
case FINISHED_RUNNING:
case COMPLETING:
case TRANSFERRED:
case POST_PROCESSING:
case COMPLETED:
return STATE_PERCENTAGE.get(analysisState);
default:
throw new NoPercentageCompleteException("No valid percent complete for state " + analysisState);
}
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowsIT method testGetWorkflowStatusComplete.
/**
* Tests executing a single workflow in Galaxy and getting the status after completion.
* @throws ExecutionManagerException
* @throws InterruptedException
* @throws TimeoutException
*/
@Test
public void testGetWorkflowStatusComplete() throws ExecutionManagerException, TimeoutException, InterruptedException {
History history = galaxyHistory.newHistoryForWorkflow();
WorkflowOutputs workflowOutput = runSingleFileTabularWorkflowFilterTool(history, dataFile1, VALID_FILTER_PARAMETER);
Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
assertEquals("final workflow state is invalid", GalaxyWorkflowState.OK, workflowStatus.getState());
assertTrue("final workflow state is invalid", workflowStatus.completedSuccessfully());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus in project irida by phac-nml.
the class GalaxyWorkflowsIT method testGetWorkflowStatusError.
/**
* Tests executing a single workflow in Galaxy and getting an error status after completion.
* @throws ExecutionManagerException
* @throws InterruptedException
* @throws TimeoutException
*/
@Test
public void testGetWorkflowStatusError() throws ExecutionManagerException, TimeoutException, InterruptedException {
History history = galaxyHistory.newHistoryForWorkflow();
// no column c2 for this input file, so should give an error
WorkflowOutputs workflowOutput = runSingleFileTabularWorkflowFilterTool(history, dataFile1, INVALID_FILTER_PARAMETER);
Util.waitUntilHistoryComplete(workflowOutput.getHistoryId(), galaxyHistory, 60);
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
assertEquals("final workflow state is invalid", GalaxyWorkflowState.ERROR, workflowStatus.getState());
assertTrue("final workflow state is invalid", workflowStatus.errorOccurred());
}
Aggregations