nextflow

Nextflow unique dir for publish dir on resume


In nextflow I have processes that accept a number of files from a channel one at a time.

In my settings I set the publish dir to be based on the hash or task.inputs which works fine for the first run of the workflow. However it seems these vars evaluate to null when using the resume option and so I only get one dir in my published dir rather than the multiple ones expected.

    publishDir = [
    path: { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}/${task.hash}" },
    mode: params.publish_dir_mode,
    saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]

Output on first run:

  drwxrwxr-x    3 sruv domain_users  25K Feb 19 10:14 00173ae51b98f95373c353c17ee00ecc
  drwxrwxr-x    3 sruv domain_users  25K Feb 19 10:08 001c4bfe7782888fca798a1dadcbe73f
  drwxrwxr-x    3 sruv domain_users  25K Feb 19 10:03 001f1c9805ca32094c58ef7cb6e4a911
  drwxrwxr-x    3 sruv domain_users  25K Feb 19 10:03 
...

On second run with resume:

  drwxrwxr-x  3 sruv domain_users 512 Feb 19 10:39 null

How can I set these to stay unique even on resume?


Solution

  • You can use task.index instead of task.hash.