Hash of list, map and item the same?

it seems that the following three objects hash to the same thing (in nextflow):

  • a map/hashtable with one value
  • a list with that value
  • value itself.

I tested this hypothesis with the following simple script:


process hello {
    tag "$metaid"

    input:
    val(metaid)

    output:
    path "hello.txt", emit: hello

    script:
    print(metaid)
    """
    echo $metaid > hello.txt
    """
}

workflow{

    meta=[id:"test"]

//     ch = Channel.from([meta]).map{ meta->[meta.id]}
//     ch = Channel.from([meta])
    ch = Channel.from([meta]).map{ meta->meta.id}

    ch.view()
    hello(ch)
}

and running it with -resume and changing which of the three lines in the end are not commented out. The results obtain a cache hit.

Am I missing something?

This could lead to false-positive cache hits, and hard to find bugs… I think it would be good to hash the keys and not only the values (in a map) and to include type information (to differentiate between a list containing one element and that element (behaviour could be different in the code…)

There is a issue on Nextflow related to this: Changes in object input structure use cached values rather than starting new runs for exec · Issue #4916 · nextflow-io/nextflow · GitHub