Skip to content

Commit a5756da

Browse files
jorgeepditommaso
andauthored
Fix unstage controls in command.run when using storeDir (#6364)
Signed-off-by: jorgee <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
1 parent fa52fe6 commit a5756da

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

modules/nextflow/src/main/groovy/nextflow/executor/BashWrapperBuilder.groovy

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ class BashWrapperBuilder {
160160
return targetDir && workDir!=targetDir
161161
}
162162

163+
/**
164+
* Template method that allows controlling if it's required to unstage
165+
* task control files (.command.out, .command.err, .command.trace, .command.env)
166+
*
167+
* See also https://github.com/nextflow-io/nextflow/pull/6364
168+
*
169+
* @return false by default; executors may override to implement their own logic
170+
*/
171+
protected boolean shouldUnstageControls() {
172+
return false
173+
}
174+
163175
protected boolean fixOwnership() {
164176
// note: only for docker (other container runtimes are not affected)
165177
ContainerHelper.fixOwnership(containerConfig) && isLinuxOS() && runWithContainer
@@ -379,7 +391,7 @@ class BashWrapperBuilder {
379391
binding.launch_cmd = getLaunchCommand(interpreter,env)
380392
binding.stage_cmd = getStageCommand()
381393
binding.unstage_cmd = getUnstageCommand()
382-
binding.unstage_controls = changeDir || shouldUnstageOutputs() ? getUnstageControls() : null
394+
binding.unstage_controls = changeDir || shouldUnstageControls() ? getUnstageControls() : null
383395

384396
if( changeDir || shouldUnstageOutputs() ) {
385397
binding.unstage_outputs = copyStrategy.getUnstageOutputFilesScript(outputFiles,targetDir)

plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchScriptLauncher.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,9 @@ class AzBatchScriptLauncher extends BashWrapperBuilder {
3333
protected boolean shouldUnstageOutputs() {
3434
return true
3535
}
36+
37+
@Override
38+
protected boolean shouldUnstageControls() {
39+
return true
40+
}
3641
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set -e
2+
3+
#
4+
# run normal mode and check if execution has unnecesary trying to copy .command.out and .command.err in the same directory.
5+
# https://github.com/nextflow-io/nextflow/issues/6311
6+
#
7+
echo ''
8+
rm -rf work/* || true
9+
NXF_WORK=work $NXF_RUN
10+
11+
if grep -qR "are the same file" work/ ; then
12+
echo "ERROR: Unnecessary copy of controls"
13+
exit 1
14+
fi

tests/unstage-controls-storedir.nf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Test to validate unstage controls copy error is not printed whe using storeDir. https://github.com/nextflow-io/nextflow/issues/6311
2+
3+
workflow {
4+
test()
5+
}
6+
7+
process test {
8+
storeDir "test"
9+
10+
output:
11+
path "test.txt"
12+
13+
script:
14+
"""
15+
ls > test.txt
16+
"""
17+
}

0 commit comments

Comments
 (0)