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

auto-determine publish mode #23

Open
riederd opened this issue Dec 14, 2021 · 2 comments
Open

auto-determine publish mode #23

riederd opened this issue Dec 14, 2021 · 2 comments

Comments

@riederd
Copy link
Member

riederd commented Dec 14, 2021

publishDir = [path: 'results/dummy_check_input', mode: params.publish_dir_mode]

Here is an idea how we could auto determine the publish mode:

import java.nio.file.Files;

def get_publishMode(d) {

    def mode = "copy"

    file(d).mkdirs()

    testFile = file(workflow.workDir + "/.test")
    testFile.write("test")

    testLink = file(d + "/.test")

    try {
        Files.createLink(testLink, testFile);
        mode = "link"
    } catch (IOException e) {
       System.err.println("WARNING: using copy as publish mode, reason: " + e)
    }

    testLink.delete()
    testFile.delete()
    return mode
 }


process test {
       publishDir "/tmp/testDR",
           mode: get_publishMode("/tmp/testDR")

    output:
    file("test_out.txt")

    script:
    """
    echo "TEST" > test_out.txt
    """

}
@grst
Copy link
Member

grst commented Dec 14, 2021

That's cool!

Two comments:

  • we should test creating the link in the res_dir, as that might be on a different file system
  • I think it would be best to set params.publish_dir_mode = "auto" per default and then use the function to figure out the mode. That would still allow to manually override it to something else if necessary.

@riederd
Copy link
Member Author

riederd commented Dec 14, 2021

  • To your first point, this is done with that code. It tries to create a link from the workDir to the publishDir, which is what happens when nextflow publishes results. When workDir and publishDir are on different filesystems, then an error is thrown and copy is used to publish
  • params.publish_dir_mode = "auto" is a nice idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants