Skip to content

Commit b0fe0a9

Browse files
authored
Include eval commands in the task hash (#5517)
Signed-off-by: jorgee <[email protected]> Signed-off-by: Ben Sherman <[email protected]>
1 parent c3f397e commit b0fe0a9

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,13 @@ class TaskProcessor {
22112211
keys.add( it.value )
22122212
}
22132213

2214+
// add all eval commands (they are part of the script)
2215+
for( Map.Entry<OutParam,Object> it : task.outputs ) {
2216+
if( it.key instanceof CmdEvalParam ) {
2217+
keys.add(((CmdEvalParam) it.key).getTarget(task.context))
2218+
}
2219+
}
2220+
22142221
// add all variable references in the task script but not declared as input/output
22152222
def vars = getTaskGlobalVars(task)
22162223
if( vars ) {
@@ -2245,6 +2252,7 @@ class TaskProcessor {
22452252
}
22462253
}
22472254

2255+
// add stub-run flag
22482256
if( session.stubRun && task.config.getStubBlock() ) {
22492257
keys.add('stub-run')
22502258
}

modules/nextflow/src/test/groovy/nextflow/processor/TaskProcessorTest.groovy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import nextflow.script.BodyDef
4141
import nextflow.script.ProcessConfig
4242
import nextflow.script.ScriptType
4343
import nextflow.script.bundle.ResourcesBundle
44+
import nextflow.script.params.CmdEvalParam
4445
import nextflow.script.params.FileInParam
4546
import nextflow.script.params.FileOutParam
4647
import nextflow.util.ArrayBag
@@ -1218,4 +1219,52 @@ class TaskProcessorTest extends Specification {
12181219
0 * collector.collect(task)
12191220
1 * exec.submit(task)
12201221
}
1222+
1223+
def 'should use eval outputs in hash' () {
1224+
given:
1225+
def session = Mock(Session) {
1226+
getDumpHashes() >> 'json'
1227+
getUniqueId() >> UUID.fromString('b69b6eeb-b332-4d2c-9957-c291b15f498c')
1228+
getBinEntries() >> ['foo.sh': Paths.get('/some/path/foo.sh'), 'bar.sh': Paths.get('/some/path/bar.sh')]
1229+
}
1230+
def outParam = Mock(CmdEvalParam) {
1231+
getTarget( _ as Map) >> 'foo --version'
1232+
}
1233+
def task1 = Spy(TaskRun) {
1234+
getSource() >> 'hello world'
1235+
lazyName() >> 'hello'
1236+
isContainerEnabled() >> false
1237+
getContainer() >> null
1238+
getSpackEnv() >> null
1239+
getCondaEnv() >> null
1240+
getConfig() >> Mock(TaskConfig)
1241+
getContext() >> [:]
1242+
}
1243+
def task2 = Spy(TaskRun) {
1244+
getSource() >> 'hello world'
1245+
lazyName() >> 'hello'
1246+
isContainerEnabled() >> false
1247+
getContainer() >> null
1248+
getSpackEnv() >> null
1249+
getCondaEnv() >> null
1250+
getConfig() >> Mock(TaskConfig)
1251+
getContext() >> [:]
1252+
}
1253+
task2.setOutput(outParam)
1254+
1255+
def processor = Spy(TaskProcessor){
1256+
getTaskGlobalVars( _ as TaskRun) >> [foo:'a', bar:'b']
1257+
}
1258+
processor.@session = session
1259+
processor.@config = Mock(ProcessConfig)
1260+
1261+
when:
1262+
def uuid1 = processor.createTaskHashKey(task1)
1263+
def uuid2 = processor.createTaskHashKey(task2)
1264+
1265+
then:
1266+
uuid1 != uuid2
1267+
1268+
}
1269+
12211270
}

0 commit comments

Comments
 (0)