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

publishDir enabled: false creates empty directory #1381

Closed
gsainsbury86 opened this issue Nov 18, 2019 · 2 comments
Closed

publishDir enabled: false creates empty directory #1381

gsainsbury86 opened this issue Nov 18, 2019 · 2 comments
Milestone

Comments

@gsainsbury86
Copy link

gsainsbury86 commented Nov 18, 2019

Bug report

Creating a process with a publishDir enabled set to false will create the output directory anyway.

Expected behavior and actual behavior

  • Expected behaviour would be that enabled: false would not create any files or directories.
  • Actual behaviour is that an empty directory of that name is created.

Steps to reproduce the problem

process publishDirBug {
	publishDir 'out', enabled: false
	
	output:
	file("a.txt")
	
	script:
	"""
	touch a.txt
	"""

}

Program output

Execution does not fail.

Environment

  • Nextflow version: nextflow version 19.10.0.5170
  • Java version: java version "10.0.2" 2018-07-17
  • Operating system: macOS 10.15.1 (19B88)

Additional context

It's possible this is a design choice, rather than a bug. My use case is in image processing. I have an optional output of intermediary images that I sometimes would like to produce. If I have one directory per image, there are potentially thousands of empty directories created.

@haqle314
Copy link

From what I can gather, the enabled param is checked too late. Simply checking
enabled earlier like this should do the trick. Is there anything that I
missed, @pditommaso?

// PublishDir.groovy:181
void apply( List<Path> files, Path sourceDir ) {
    // Check here instead of inside void apply(Path source, boolean inProcess)
    if( !files || !enabled )
        return
    this.sourceDir = sourceDir
    this.sourceFileSystem = sourceDir ? sourceDir.fileSystem : null
    apply0(files)
}

@pditommaso
Copy link
Member

Well spotted, yes the patch suggested should do the trick.

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

3 participants