Skip to content

Commit

Permalink
Add ability to override failOnError setting default via env variable (#…
Browse files Browse the repository at this point in the history
…5117) [ci fast]




Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Jul 8, 2024
1 parent 44d1d39 commit 72d7842
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,11 @@ The following environment variables control the configuration of the Nextflow ru
:::
: Defines a custom plugin registry or plugin release URL for testing plugins outside of the main registry. See {ref}`testing-plugins` for more information.

`NXF_PUBLISH_FAIL_ON_ERROR`
: :::{versionadded} 24.04.3
:::
: Defines the default behavior of `publishDir.failOnError` setting. See {ref}`publishDir<process-publishdir>` directive for more information.

`NXF_SCM_FILE`
: :::{versionadded} 20.10.0
:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package nextflow.processor

import static nextflow.util.CacheHelper.*

import java.nio.file.FileAlreadyExistsException
import java.nio.file.FileSystem
import java.nio.file.FileSystems
Expand All @@ -40,15 +42,12 @@ import groovy.util.logging.Slf4j
import nextflow.Global
import nextflow.NF
import nextflow.Session
import nextflow.SysEnv
import nextflow.extension.FilesEx
import nextflow.file.FileHelper
import nextflow.file.TagAwareFile
import nextflow.fusion.FusionHelper
import nextflow.util.HashBuilder
import nextflow.util.PathTrie

import static nextflow.util.CacheHelper.HashMode

/**
* Implements the {@code publishDir} directory. It create links or copies the output
* files of a given task to a user specified directory.
Expand Down Expand Up @@ -98,9 +97,9 @@ class PublishDir {
boolean enabled = true

/**
* Trow an exception in case publish fails
* Throw an exception in case publish fails
*/
boolean failOnError = true
boolean failOnError = SysEnv.getBool('NXF_PUBLISH_FAIL_ON_ERROR', true)

/**
* Tags to be associated to the target file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.nio.file.Paths

import nextflow.Global
import nextflow.Session
import nextflow.SysEnv
import spock.lang.Specification
import test.TestHelper
/**
Expand Down Expand Up @@ -398,4 +399,22 @@ class PublishDirTest extends Specification {
cleanup:
folder?.deleteDir()
}

def 'should set failOnError via env variable' () {
given:
SysEnv.push(ENV)

when:
def publish = new PublishDir()
then:
publish.failOnError == EXPECTED
cleanup:
SysEnv.pop()

where:
ENV | EXPECTED
[:] | true
[NXF_PUBLISH_FAIL_ON_ERROR: 'true'] | true
[NXF_PUBLISH_FAIL_ON_ERROR: 'false'] | false
}
}

0 comments on commit 72d7842

Please sign in to comment.