Skip to content

Conversation

@ewels
Copy link
Member

@ewels ewels commented Dec 16, 2025

From #5583 (comment):

@pinin4fjords: Conda lock files DO work, but they can't currently have the '.lock' extension. They must be .txt, and can't be remote files.

PR Goals:

  • Support remote URIs for conda lock files
  • Detect conda lock files by looking at file content, instead of relying on file extension
Details This change allows conda lock files to be used with any file extension (e.g., .lock, .txt, or no extension) as long as they contain the `@EXPLICIT` marker in the first 20 lines. Additionally, remote conda lock files can now be specified using http/https URLs.

Changes:

  • Add isLockFile() method to detect lock files by @EXPLICIT marker
  • Add isRemoteFile() method to check for http/https URLs
  • Add stageRemoteFile() method to download remote files locally
  • Modify condaPrefixPath() to handle remote files and lock files with any extension
  • Modify createLocalCondaEnv0() to detect and handle lock files properly
  • Add tests for new functionality
  • Update documentation to reflect new behavior

Fixes #5583

This change allows conda lock files to be used with any file extension
(e.g., .lock, .txt, or no extension) as long as they contain the @explicit
marker in the first 20 lines. Additionally, remote conda lock files can now
be specified using http/https URLs.

Changes:
- Add isLockFile() method to detect lock files by @explicit marker
- Add isRemoteFile() method to check for http/https URLs
- Add stageRemoteFile() method to download remote files locally
- Modify condaPrefixPath() to handle remote files and lock files with
  any extension
- Modify createLocalCondaEnv0() to detect and handle lock files properly
- Add tests for new functionality
- Update documentation to reflect new behavior

Fixes #5583

Signed-off-by: Claude <[email protected]>
@ewels ewels requested a review from a team as a code owner December 16, 2025 18:10
@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for nextflow-docs-staging ready!

Name Link
🔨 Latest commit 55ab7d9
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/694264892bb4f000081e3867
😎 Deploy Preview https://deploy-preview-6665--nextflow-docs-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Document that the conda lock file detection behavior changed in
26.01.0-edge to support any file extension and remote URLs.

Signed-off-by: Claude <[email protected]>
Refactor isRemoteFile() to use the existing FileHelper.getUrlProtocol()
method instead of hardcoded http/https checks. This adds support for
all remote protocols including S3, Google Cloud Storage, Azure Blob
Storage, and FTP.

Update tests and documentation to reflect the expanded protocol support.

Signed-off-by: Claude <[email protected]>
Remove the isYamlUriPath method which is now redundant since isRemoteFile
uses FileHelper.getUrlProtocol() to detect all remote protocols.

Update tests to reflect the new behavior where remote files are staged
locally before being passed to conda/mamba/micromamba.

Add tests for remote lock files with mamba and micromamba.

Signed-off-by: Claude <[email protected]>
Fix Spock interaction expectations in tests for remote YAML/lock files:
- Remove redundant isRemoteFile stub when getLocalFilePath is stubbed
  (isRemoteFile is called internally by getLocalFilePath)
- YAML files ending in .yml enter the YAML branch via isYamlFilePath,
  not the remote file branch
- Add clarifying comments about test behavior

Signed-off-by: Claude <[email protected]>
Copy link
Collaborator

@christopher-hakkaart christopher-hakkaart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look good. One minor suggestion. Someone else will need to check the code.

Co-authored-by: Chris Hakkaart <[email protected]>
Signed-off-by: Phil Ewels <[email protected]>
Signed-off-by: Phil Ewels <[email protected]>
@pditommaso
Copy link
Member

It looks like this PR tries to do too many things (parsing content, formatting env (?), supporting remote uris, etc), please scope clearly the goals.

@ewels
Copy link
Member Author

ewels commented Dec 17, 2025

Tested successfully in GitHub codespaces, working as expected:

main.nf
#!/usr/bin/env nextflow

params.input = "data/*.fq.gz"

workflow {
    channel.fromPath(params.input)
        .set { reads }

    FASTQC(reads)
}

process FASTQC {
    conda "https://wave.seqera.io/v1alpha1/builds/bd-af7a5314d5015c29_1/condalock"

    input:
    path reads

    output:
    path "*.html"
    path "*.zip"

    script:
    """
    fastqc ${reads}
    """
}

With a nextflow.config with conda.enabled = true

I tried locally at first but it failed, because the lockfile was for a linux/arch64 Docker build so didn't work on my apple silicon ARM processor.

@ewels
Copy link
Member Author

ewels commented Dec 17, 2025

It looks like this PR tries to do too many things (parsing content, formatting env (?), supporting remote uris, etc), please scope clearly the goals.

You basically described the goals 😅 - though I don't think it does any formatting?

Goals:

  • Support remote URIs for conda lock files
  • Detect conda lock files by looking at file content, instead of relying on file extension

@ewels
Copy link
Member Author

ewels commented Dec 17, 2025

I updated the PR description to try to make this clearer @pditommaso. I'm not really sure how I can reduce the scope of the code changes without missing the goals. Suggestions welcome!

@pinin4fjords
Copy link
Contributor

I think the scope here is appropriate. The two goals are inherently linked - remote conda lock files (like Wave's condalock endpoint) don't have .txt extensions, so content-based detection (@EXPLICIT marker) is required to make remote URLs work at all.

The implementation is clean: three small helper methods (isLockFile, isRemoteFile, stageRemoteFile) plus integration into the existing flow. The test coverage is thorough.

This unblocks a real user pain point from #5583 - conda lock files are increasingly common in nf-core and other pipelines, and the current .txt extension requirement is confusing and limiting.

Copy link
Member

@pditommaso pditommaso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A part the comment on performance, not quite convinced nextflow should download remote lock files on-the-file. Lock files should be considered an assert of the module bundle (and eventually downloaded with the bundle itself)

Comment on lines +182 to +188
final lines = content.readLines()
final limit = Math.min(20, lines.size())
for( int i = 0; i < limit; i++ ) {
if( lines[i].trim() == '@EXPLICIT' )
return true
}
return false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use a reader (ie. read line by line) to avoid loading all file in memory to parse the header

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conda: Support .lock file extensions.

7 participants