Search in sources :

Example 6 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisSubmissionServiceImpl method delete.

/**
 * {@inheritDoc}
 */
@Override
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#id, 'canUpdateAnalysisSubmission')")
@Transactional
public void delete(Long id) throws EntityNotFoundException {
    final AnalysisSubmission submission = read(id);
    if (AnalysisCleanedState.NOT_CLEANED.equals(submission.getAnalysisCleanedState())) {
        // We're "CLEANING" it right now!
        submission.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
        try {
            analysisExecutionService.cleanupSubmission(submission).get();
        } catch (final ExecutionManagerException e) {
            logger.error("Failed to cleanup analysis submission before deletion," + " but proceeding with deletion anyway.", e);
        } catch (final Throwable e) {
            logger.error("An unexpected exception happened when cleaning the analysis submission," + " but proceeding with deletion anyway.", e);
        }
    } else {
        logger.debug("Not cleaning submission [" + id + "] when deleting, it's already cleaned.");
    }
    super.delete(id);
}
Also used : AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(javax.transaction.Transactional)

Example 7 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class GalaxyHistoriesService method constructCollection.

/**
 * Builds a new Dataset Collection given the description of this collection.
 * @param collectionDescription  A description of the collection to build.
 * @param history  The history to build the collection within.
 * @return  A CollectionResponse describing the constructed collection.
 * @throws ExecutionManagerException  If there was an issue constructing the collection.
 */
public CollectionResponse constructCollection(CollectionDescription collectionDescription, History history) throws ExecutionManagerException {
    checkNotNull(collectionDescription, "collectionDescription is null");
    checkNotNull(history, "history is null");
    try {
        return historiesClient.createDatasetCollection(history.getId(), collectionDescription);
    } catch (RuntimeException e) {
        throw new ExecutionManagerException("Could not construct dataset collection", e);
    }
}
Also used : ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)

Example 8 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class GalaxyWorkflowsIT method constructPairedFileCollection.

/**
 * Constructs a collection containing a list of files from the given datasets.
 * @param inputDatasetsForward  The forward datasets to construct a collection from.
 * @param inputDatasetsReverse  The reverse datasets to construct a collection from.
 * @param history  The history to construct the collection within.
 * @return  A CollectionResponse describing the dataset collection.
 * @throws ExecutionManagerException  If an exception occured constructing the collection.
 */
public CollectionResponse constructPairedFileCollection(List<Dataset> inputDatasetsForward, List<Dataset> inputDatasetsReverse, History history) throws ExecutionManagerException {
    checkNotNull(inputDatasetsForward, "inputDatasetsForward is null");
    checkNotNull(inputDatasetsReverse, "inputDatasetsReverse is null");
    checkNotNull(history, "history is null");
    checkNotNull(history.getId(), "history does not have an associated id");
    checkArgument(inputDatasetsForward.size() == inputDatasetsReverse.size(), "inputDatasets do not have equal sizes");
    CollectionDescription collectionDescription = new CollectionDescription();
    collectionDescription.setCollectionType(DatasetCollectionType.LIST_PAIRED.toString());
    collectionDescription.setName(COLLECTION_NAME);
    for (int i = 0; i < inputDatasetsForward.size(); i++) {
        Dataset datasetForward = inputDatasetsForward.get(i);
        Dataset datasetReverse = inputDatasetsReverse.get(i);
        HistoryDatasetElement elementForward = new HistoryDatasetElement();
        elementForward.setId(datasetForward.getId());
        elementForward.setName(FORWARD_PAIR_NAME);
        HistoryDatasetElement elementReverse = new HistoryDatasetElement();
        elementReverse.setId(datasetReverse.getId());
        elementReverse.setName(REVERSE_PAIR_NAME);
        // Create an object to link together the forward and reverse reads for file2
        CollectionElement element = new CollectionElement();
        element.setName(BASE_NAME + i);
        element.setCollectionType(DatasetCollectionType.PAIRED.toString());
        element.addCollectionElement(elementForward);
        element.addCollectionElement(elementReverse);
        collectionDescription.addDatasetElement(element);
    }
    try {
        return historiesClient.createDatasetCollection(history.getId(), collectionDescription);
    } catch (RuntimeException e) {
        throw new ExecutionManagerException("Could not construct dataset collection", e);
    }
}
Also used : Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) CollectionDescription(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) HistoryDatasetElement(com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement) CollectionElement(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionElement) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)

Example 9 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisProvenanceServiceGalaxyTest method testShowProvenanceFailureNoFiles.

@Test(expected = ExecutionManagerException.class)
public void testShowProvenanceFailureNoFiles() throws ExecutionManagerException {
    when(galaxyHistoriesService.showHistoryContents(any(String.class))).thenReturn(Lists.newArrayList());
    when(galaxyHistoriesService.showProvenance(any(String.class), any(String.class))).thenThrow(new ExecutionManagerException());
    provenanceService.buildToolExecutionForOutputFile(analysisSubmission(), analysisOutputFile());
}
Also used : ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Test(org.junit.Test)

Example 10 with ExecutionManagerException

use of ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException in project irida by phac-nml.

the class AnalysisProvenanceServiceGalaxy method buildToolExecutionForOutputFile.

/**
 * Build up a provenance report for a specific file that's attached to the
 * outputs of an analysis submission.
 *
 * @param remoteAnalysisId
 *            the identifier of the submission history that the output file
 *            is attached to on the execution manager (i.e., Galaxy's
 *            history id).
 * @param analysisOutputFilename
 *            the filename to build the report for. This should be the raw
 *            basename of the file (i.e., only the filename + extension
 *            part).
 * @return the complete report for the file.
 * @throws ExecutionManagerException
 *             if the history contents could not be shown for the specified
 *             file.
 */
public ToolExecution buildToolExecutionForOutputFile(final String remoteAnalysisId, final String analysisOutputFilename) throws ExecutionManagerException {
    final List<HistoryContents> historyContents = galaxyHistoriesService.showHistoryContents(remoteAnalysisId);
    // group the history contents by name. The names that we're interested
    // in starting from should match the filename of the output file.
    final Map<String, List<HistoryContents>> historyContentsByName = historyContents.stream().collect(Collectors.groupingBy(HistoryContents::getName));
    final List<HistoryContents> currentContents = historyContentsByName.get(analysisOutputFilename);
    if (currentContents == null || currentContents.isEmpty() || currentContents.size() > 1) {
        throw new ExecutionManagerException("Could not load a unique history contents for the specified filename [" + analysisOutputFilename + "] in history with id [" + remoteAnalysisId + "]");
    }
    final HistoryContentsProvenance currentProvenance = galaxyHistoriesService.showProvenance(remoteAnalysisId, currentContents.get(0).getId());
    try {
        final Tool toolDetails = toolsClient.showTool(currentProvenance.getToolId());
        return buildToolExecutionForHistoryStep(toolDetails, currentProvenance, remoteAnalysisId);
    } catch (final RuntimeException e) {
        throw new ExecutionManagerException("Failed to build tool execution provenance.", e);
    }
}
Also used : HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) List(java.util.List) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) Tool(com.github.jmchilton.blend4j.galaxy.beans.Tool)

Aggregations

ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)15 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)8 Future (java.util.concurrent.Future)5 IOException (java.io.IOException)3 Test (org.junit.Test)3 IridaWorkflowException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowException)2 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)2 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)2 Tool (com.github.jmchilton.blend4j.galaxy.beans.Tool)2 List (java.util.List)2 AsyncResult (org.springframework.scheduling.annotation.AsyncResult)2 AnalysisAlreadySetException (ca.corefacility.bioinformatics.irida.exceptions.AnalysisAlreadySetException)1 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)1 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)1 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)1 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)1 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)1 IridaToolParameter (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaToolParameter)1 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)1 GalaxyHistoriesService (ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyHistoriesService)1