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

Add support for custom custom root directory to resolve relative paths #3942

Merged
merged 8 commits into from
May 14, 2023

Conversation

pditommaso
Copy link
Member

Nextflow resolves relative paths against the current working directory following the usual Linux and Java conventions.

For example, if the workflow is execution is launched in the path /home/yo/workflow and the workflow reference a file foo.txt using the function file('foo.txt'), the resulting file path will be /home/yo/workflow/foo.txt.

This makes sense when working in a local or share file system, howeber it results into counter-intuitive behaviour when using a cloud-containerised execution environment.

In this scenario, Nextflow runs into a container ephemeral file system and relative paths are resolved as local container files that are lost after the job completion.

To solve this problem, this PR introduces the environment variable NXF_FILE_ROOT that can be used to define the root path against which relative path needs to be resolved.

For example having define the following variable NXF_FILE_ROOT=s3://my-bucket/data, the use of file('foo.txt') will result in the path s3://my-bucket/data/foo.txt/

This behaviour applies to file path resolved via the Nextflow built-in functions file, files, channel.fromPath, channel.fromFilePairs and the publishDir operator.

@pditommaso
Copy link
Member Author

Solves #2661

@pditommaso pditommaso marked this pull request as draft May 14, 2023 16:39
Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
@pditommaso
Copy link
Member Author

Look @drpatelh! is happening! 😆

@pditommaso pditommaso marked this pull request as ready for review May 14, 2023 22:36
@pditommaso pditommaso merged commit f06bb1f into master May 14, 2023
@pditommaso pditommaso deleted the fix-file-relpath branch May 14, 2023 23:11
@drpatelh
Copy link
Contributor

abhi18av pushed a commit to abhi18av/nextflow that referenced this pull request Oct 28, 2023
nextflow-io#3942)

this PR introduces the environment variable `NXF_FILE_ROOT` which can be used 
to define the root path against which relative paths need to be resolved.

For example, having defined the following variable `NXF_FILE_ROOT=s3://my-bucket/data`, 
the use of `file('foo.txt')` will result in the path `s3://my-bucket/data/foo.txt/`

This behaviour applies to file path resolved via the Nextflow built-in functions `file`, `files`,
`channel.fromPath`, `channel.fromFilePairs` and the `publishDir` operator.
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

Successfully merging this pull request may close these issues.

2 participants