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 canceled.

Name Link
🔨 Latest commit 67bc9fd
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/695d258675adf30008effd55

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)

…bility

Per review feedback, remote Conda lock files should not be supported
because lock files are considered assets of the module bundle and
should be versioned alongside the pipeline code.

Changes:
- Revert remote file staging functionality (stageRemoteFile, getLocalFilePath, isLockFilePath)
- Restore isYamlUriPath for detecting HTTP/HTTPS YAML environment files
- Remote URLs (http/https) are only allowed for YAML environment files (.yml, .yaml)
- Remote non-YAML files (e.g., lock files) throw an error with clear message
- Keep local lock file support with any extension (detected by @explicit marker)
- Update docs with admonition explaining remote file limitations

Signed-off-by: Claude <[email protected]>
@ewels
Copy link
Member Author

ewels commented Jan 6, 2026

Ok, I reverted that part of the PR and added an admonition to the docs explaining that environment.yml files have partial remote support (http) but that's all.

The behavior is now:

  • Remote YAML files (http/https + .yml/.yaml): URL passed directly to conda/mamba
  • Remote lock files: Throws error (not supported)
  • Local lock files: Work with any extension (.lock, .txt, no extension, etc.)

@ewels ewels force-pushed the claude/conda-lock-file-extensions-KTuq0 branch 4 times, most recently from a8f58e4 to 961802c Compare January 6, 2026 13:57
Per review feedback, avoid loading the entire file into memory when
checking for the @explicit marker. The isLockFile method now takes
a Path and uses a BufferedReader to read only the first 20 lines.

Signed-off-by: Claude <[email protected]>
@ewels ewels force-pushed the claude/conda-lock-file-extensions-KTuq0 branch from 961802c to 67bc9fd Compare January 6, 2026 15:08
@ewels
Copy link
Member Author

ewels commented Jan 6, 2026

@pditommaso should be good to go now.

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