Skip to content

Use conda-lock to generate environment.lock (closes #975)#1063

Open
munishchouhan wants to merge 2 commits into
masterfrom
975-conda-lock-pip-deps
Open

Use conda-lock to generate environment.lock (closes #975)#1063
munishchouhan wants to merge 2 commits into
masterfrom
975-conda-lock-pip-deps

Conversation

@munishchouhan

Copy link
Copy Markdown
Member

Summary

  • Switch the conda-file build templates (v1 and v2, dockerfile and singularity) from micromamba env export --name base --explicit to conda-lock for generating environment.lock.
  • micromamba env export --explicit silently omits any pip: entries from environment.yml, leaving users with mixed conda+pip environments holding an incomplete lock file. conda-lock understands pip sections and includes them in the lockfile.
  • The actual micromamba install step that materializes the base env is left untouched, so image contents are produced exactly as before — conda-lock is used only to render the lockfile (so this is a minimal-risk change to image behavior).

What changed

  • src/main/resources/templates/conda-micromamba-v1/dockerfile-conda-file.txt
  • src/main/resources/templates/conda-micromamba-v1/singularityfile-conda-file.txt
  • src/main/resources/templates/conda-micromamba-v2/dockerfile-conda-file.txt
  • src/main/resources/templates/conda-micromamba-v2/singularityfile-conda-file.txt
  • Test fixtures in TemplateUtilsTest and ContainerHelperTest updated for the new template output.

The conda-packages variants (inline package lists / lock-URL flow) are not changed: they don't accept a conda.yml and inline CLI args can't carry pip: deps, so conda-lock offers no benefit there.

Test plan

  • TemplateUtilsTest passes (34 tests)
  • ContainerHelperTest passes (107 tests)
  • Verify a real build with a mixed conda+pip environment.yml produces a lockfile containing the pip packages
  • Confirm CONDA_LOCK_START / CONDA_LOCK_END extraction in BuildLogServiceImpl still works with the conda-lock unified lockfile format

Closes #975

🤖 Generated with Claude Code

The current templates run `micromamba env export --name base --explicit`
which silently omits any `pip:` entries from environment.yml, so users
with mixed conda+pip environments get incomplete lock files.

Switch the lockfile generation step in the conda-file templates (v1 and
v2, dockerfile and singularity) to install `conda-lock` and invoke it
against the user's conda.yml. The actual `micromamba install` step that
builds the image is left unchanged, so image contents are produced
exactly as before — conda-lock is used only to render the lockfile.

Closes #975

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@munishchouhan munishchouhan self-assigned this Jun 25, 2026
The conda-lock binary lives at /opt/conda/bin/conda-lock after the
`micromamba install conda-forge::conda-lock` step, but /opt/conda/bin is
not on PATH inside the mambaorg/micromamba build stage. The previous
template invoked `conda-lock ...` directly and failed with
`bash: line 1: conda-lock: command not found` (exit 127).

Run it via `micromamba run -n base` instead so the base env's PATH is
resolved correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@pditommaso pditommaso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This may go into into a new template version

@pditommaso

Copy link
Copy Markdown
Collaborator

Related #1064

@munishchouhan

Copy link
Copy Markdown
Member Author

This may go into into a new template version

ok sure i will create v3

@pditommaso

Copy link
Copy Markdown
Collaborator

Let's discuss first what's the best approach for this

@munishchouhan

Copy link
Copy Markdown
Member Author

Let's discuss first what's the best approach for this

I think we have three options:

  1. Changing the current templates - This will affect the current user experience
  2. Creating new template version like V3- In this case maintainace will increase because if there is any change in v2 we have to do the same change in v3
  3. Add new place holder {{lockfile_command}}- we will make the current conda lock export command as default

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.

Add conda-lock library to generate full conda-lock files for default template

3 participants