nextflow icon indicating copy to clipboard operation
nextflow copied to clipboard

Fix workflow onComplete and onError in the entry workflow

Open bentsherman opened this issue 1 year ago • 3 comments

Close #5261

Tested with this script:

workflow {
    params.outdir = 'results'

    def local = 'local'

    workflow.onComplete {
        if( workflow.success )
            log.info "Success! View results: $params.outdir"
        else
            log.info "Failure!"

        log.info "local variable: ${local}"
    }
}

The problem is that this change breaks the WorkflowMetadata unit tests. But these unit tests do not accurately represent how the onComplete/onError is defined

I could rewrite the unit tests to print to stdout and try to capture the stdout. But these tests probably just need to be e2e tests in order to test the actual script context

bentsherman avatar Oct 04 '24 15:10 bentsherman

Deploy Preview for nextflow-docs-staging ready!

Name Link
Latest commit cfffeb349d02fa067345cdee36869e916c55ff44
Latest deploy log https://app.netlify.com/sites/nextflow-docs-staging/deploys/673f514ab0ab0000083b3bd3
Deploy Preview https://deploy-preview-5366--nextflow-docs-staging.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Oct 04 '24 15:10 netlify[bot]

@jorgee can you help me move this PR forward when you have some time? I'm hoping to get it into a 24.10.x patch release

We need to fix these failing tests:

WorkflowMetadataTest > should populate workflow object FAILED
    org.spockframework.runtime.SpockComparisonFailure at WorkflowMetadataTest.groovy:112

WorkflowMetadataTest > should access workflow script variables onComplete FAILED
    org.spockframework.runtime.SpockComparisonFailure at WorkflowMetadataTest.groovy:174

WorkflowMetadataTest > should access workflow script variables onError FAILED
    org.spockframework.runtime.SpockComparisonFailure at WorkflowMetadataTest.groovy:244

Currently these tests are trying to capture the stdout, and they are setting up the onComplete handler in a different way than it is actually used. I think they just need to be rewritten as e2e tests that check the console output for the printed lines, as other e2e tests do.

bentsherman avatar Nov 19 '24 16:11 bentsherman

The changes were also breaking the integration_test workflow-oncomplete.nf. In the case, that the closure comes from the configuration, we need to change the closure delegate. Two new functions added to manage when onComplete and onError are called from the configuration. Two integration tests ('script-vars-oncomplete.nf' and 'script-vars-onerror.nf') have been added to check the case where callbacks are defined in the workflow.

jorgee avatar Nov 21 '24 15:11 jorgee