[Core] Add provision.conda_auto_activate config option#9944
[Core] Add provision.conda_auto_activate config option#9944lloyd-brown wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new configuration option, provision.conda_auto_activate, allowing users to disable the automatic activation of the conda base environment on remote clusters. This is particularly useful for workflows that manage their own environments (e.g., uv-first projects). The changes include documentation updates, schema validation, backend logic to parse the config, and updates to the conda installation commands to deactivate the base environment when requested. Additionally, unit tests were added to verify this behavior. Feedback was provided to simplify the logic for determining the conda_auto_activate value in sky/backends/backend_utils.py to improve readability.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
kevinmingtarja
left a comment
There was a problem hiding this comment.
One question, otherwise LGTM.
| 'if [ "{is_custom_docker}" = "true" ] || ' | ||
| '[ "{conda_auto_activate}" = "false" ]; then ' |
There was a problem hiding this comment.
Should conda_auto_activate: false also take effect on images that already have conda on PATH?
This whole block — including conda config --set auto_activate_base false — only runs in the which conda short-circuit:
skypilot/sky/skylet/constants.py
Line 253 in 0d69dc3
So on an image where conda is already initialized and on PATH (e.g. the AWS DLAMI), which conda succeeds, the block is skipped, and auto_activate_base is never set to false. New interactive/SSH shells would then still auto-activate base, so the option silently has no effect there. (The in-shell→Ray leak isn't hit in that case, since we also never run our own conda activate base — it's the SSH/interactive path that's left exposed.) Worth handling that path, or at least noting the limitation in the docs?
There was a problem hiding this comment.
Good catch, fixed in c79ce49. I moved the auto_activate_base setting out of the which conda short-circuit into a stanza that runs whenever conda is available (command -v conda), gated on the user having explicitly set provision.conda_auto_activate so we don't override conda config baked into custom images.
Validated live on a conda-already-on-PATH image (so the install block is skipped): the stanza fires and conda config --show auto_activate_base ends up false. Re-verified the default-image path for no regression.
One caveat I hit while testing, now noted in the docs: images that bake CONDA_PREFIX into the container ENV itself (e.g. continuumio/miniconda3) keep base as the implicit target regardless, since that's the image's environment rather than conda auto-activation. The DLAMI case you named activates base via conda init/auto_activate_base, which this handles.
SkyPilot auto-activates the conda `base` environment on clusters that do not use a custom Docker image. This is convenient for conda-based workflows, but it makes `base` the implicit target of `uv`/`pip` run in setup/run scripts and interactive shells, which is undesirable for workflows that manage their own environments (e.g. uv-first projects). Add a `provision.conda_auto_activate` config option (default unchanged) so users can keep conda installed but not auto-activated. When set to false, the conda installation commands both set `auto_activate_base false` and deactivate `base` after setup, so it does not stay active in the chained provisioning shell and leak into the Ray runtime / user jobs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address review: resolve the boolean once (config value, falling back to the no-docker-image default) and stringify a single time, instead of duplicating the 'true'/'false' conversion across branches. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0d69dc3 to
76f518b
Compare
Address review: `conda config --set auto_activate_base` previously ran only inside the `which conda` short-circuit, so on images that already have conda on PATH (e.g. the AWS DLAMI) the block is skipped and `provision.conda_auto_activate: false` had no effect on interactive/SSH shells. Apply the preference outside the install block too (guarded by `command -v conda`), but only when the user explicitly set the option, so we don't override conda config baked into custom images. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Images that set CONDA_PREFIX in the container environment itself (rather than activating base via conda init) keep base as the implicit target regardless of the option, since that is not conda auto-activation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary
SkyPilot auto-activates the conda
baseenvironment on clusters that do not use a custom Docker image. This is convenient for conda-based workflows, but it makesbasethe implicit target ofuv/pipcommands run insetup/runscripts and interactive shells. For users who manage their own environments (e.g. uv-first projects), this is surprising: auv pip installfrom a directory without a.venvsilently installs into condabaseinstead of erroring or using the intended environment.This PR adds a
provision.conda_auto_activateconfig option so users can keep conda installed but not auto-activated.sky/backends/backend_utils.py:conda_auto_activatenow honorsprovision.conda_auto_activatewhen set, falling back to the existing default (true, exceptfalsefor custom Docker images).sky/skylet/constants.py: the post-installconda deactivateguard now also fires whenconda_auto_activateisfalse. This is required because the install commands explicitly runconda activate base; without deactivating,basestays active in the chained provisioning shell and leaks into the Ray runtime (and therefore into usersetup/runjobs), even thoughauto_activate_baseis set to false for new shells.sky/utils/schemas.py: schema entry for the new option.config.rst) + a unit test.Default behavior is unchanged.
Test plan
tests/unit_tests/test_backend_utils.py::test_conda_installation_deactivates_base_when_auto_activate_disabled: asserts the rendered conda commands setauto_activate_base falseand deactivatebasewhen the option isfalse, while preserving the existing custom-Docker deactivate behavior.provision.conda_auto_activate: false. VerifiedCONDA_PREFIXis unset anduvresolves cleanly (no longer binds to condabase) in bothruncommands and interactive SSH, and that a user-created.venvis used correctly. Verified that with the option unset, behavior is unchanged (basestill auto-activated).🤖 Generated with Claude Code