Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hash when CmdEvalParam as output #5517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,13 @@ class TaskProcessor {
keys.add( it.value )
}

// add all eval statements in outputs
for( Map.Entry<OutParam,Object> it : task.outputs ) {
if( it.key instanceof CmdEvalParam ) {
keys.add(((CmdEvalParam) it.key).getTarget(task.context))
}
}

// add all variable references in the task script but not declared as input/output
def vars = getTaskGlobalVars(task)
if( vars ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package nextflow.processor

import nextflow.script.params.CmdEvalParam

import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
Expand Down Expand Up @@ -1172,4 +1174,51 @@ class TaskProcessorTest extends Specification {

}

def 'should use eval outputs in hash' () {
given:
def session = Mock(Session) {
getDumpHashes() >> 'json'
getUniqueId() >> UUID.fromString('b69b6eeb-b332-4d2c-9957-c291b15f498c')
getBinEntries() >> ['foo.sh': Paths.get('/some/path/foo.sh'), 'bar.sh': Paths.get('/some/path/bar.sh')]
}
def outParam = Mock(CmdEvalParam) {
getTarget( _ as Map) >> 'foo --version'
}
def task1 = Spy(TaskRun) {
getSource() >> 'hello world'
lazyName() >> 'hello'
isContainerEnabled() >> false
getContainer() >> null
getSpackEnv() >> null
getCondaEnv() >> null
getConfig() >> Mock(TaskConfig)
getContext() >> [:]
}
def task2 = Spy(TaskRun) {
getSource() >> 'hello world'
lazyName() >> 'hello'
isContainerEnabled() >> false
getContainer() >> null
getSpackEnv() >> null
getCondaEnv() >> null
getConfig() >> Mock(TaskConfig)
getContext() >> [:]
}
task2.setOutput(outParam)

def processor = Spy(TaskProcessor){
getTaskGlobalVars( _ as TaskRun) >> [foo:'a', bar:'b']
}
processor.@session = session
processor.@config = Mock(ProcessConfig)

when:
def uuid1 = processor.createTaskHashKey(task1)
def uuid2 = processor.createTaskHashKey(task2)

then:
uuid1 != uuid2

}

}