Skip to content

Commit

Permalink
Add setting to enable the use of sync command
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Sep 28, 2023
1 parent 2b9ae6a commit f0d5cc5
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,11 @@ The following environment variables control the configuration of the Nextflow ru
:::
: Disables the requirement for Wave service when enabling the Fusion file system.

`NXF_ENABLE_FS_SYNC`
: :::{versionadded} 23.10.0
:::
: When enabled the job script will execute Linux `sync` command on job completion. This may be useful to synchronize the job state over shared file systems (default: `false`)

`NXF_ENABLE_SECRETS`
: :::{versionadded} 21.09.0-edge
:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ class BashWrapperBuilder {
}

String getSyncCmd() {
if ( SysEnv.get( 'NXF_DISABLE_FS_SYNC' ) != "true" ) {
if ( SysEnv.get( 'NXF_ENABLE_FS_SYNC' ) == "true" ) {
return 'sync || true'
}
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,19 @@ class BashWrapperBuilderTest extends Specification {
folder?.deleteDir()
}

def 'should include sync command' () {
given:
SysEnv.push([NXF_ENABLE_FS_SYNC: 'true'])

when:
def binding = newBashWrapperBuilder().makeBinding()
then:
binding.sync_cmd == 'sync || true'

cleanup:
SysEnv.pop()
}

def 'should unstage outputs' () {

given:
Expand Down Expand Up @@ -486,6 +499,7 @@ class BashWrapperBuilderTest extends Specification {
binding.containsKey('container_env')
binding.task_env == null
binding.container_env == null
binding.sync_cmd == null

when:
binding = newBashWrapperBuilder(environment: [FOO:'aa', BAR:'bb']).makeBinding()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ on_exit() {
exit_status=${nxf_main_ret:=$?}
printf -- $exit_status > {{folder}}/.exitcode
set +u
sync || true
exit $exit_status
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ on_exit() {
exit_status=${nxf_main_ret:=$?}
printf -- $exit_status > {{folder}}/.exitcode
set +u
sync || true
exit $exit_status
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GoogleLifeSciencesScriptLauncherTest extends GoogleSpecification {
def wrapper = builder.buildNew0()

then:
wrapper == load('bash-wrapper-gcp.txt', [folder: WORK_DIR.toString(), sync_cmd: 'sync || true' ])
wrapper == load('bash-wrapper-gcp.txt', [folder: WORK_DIR.toString()])

cleanup:
folder?.deleteDir()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ on_exit() {
exit_status=${nxf_main_ret:=$?}
printf -- $exit_status > {{folder}}/.exitcode
set +u
{{sync_cmd}}
exit $exit_status
}

Expand Down

0 comments on commit f0d5cc5

Please sign in to comment.