Skip to content

Conversation

soapy1
Copy link
Contributor

@soapy1 soapy1 commented Jun 5, 2025

Description

This PR refactors the CLI layer to:

  • merge all environment specification coming from cli args and environemt specs into a common model.environment.Environment object
  • creates a transaction object from the final Environment

This refactor is a big change to how conda's cli layer. In order to ensure that we are not changing functionality in unexpected ways. I've outlined all the ways conda package installing related commands work, including noting some bugs (this includes conda install, conda env create, conda remove, etc.).

Some important changes in this PR:

  • conda install/update commands can now read environment.yaml files: Previsouly, only conda env commands could read environment.yaml files. This PR introduces using the plugin system to detect the type of the provided --file source. So, any plugin installed can be used.

Things not included in this PR (can be included in follow up PRs):

  • being able to select which environment spec plugin to use by a cli flag
  • updating all install paths to use handle_txn to execute the installing transaction

Checklist - did you ...

@github-project-automation github-project-automation bot moved this to 🆕 New in 🔎 Review Jun 5, 2025
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Jun 5, 2025
Copy link

codspeed-hq bot commented Jun 5, 2025

CodSpeed Instrumentation Performance Report

Merging #14911 will not alter performance

Comparing soapy1:refactor-cli-layer (0ca78d8) with main (e7da0f9)

Summary

✅ 21 untouched benchmarks

Copy link
Contributor

@jaimergp jaimergp left a comment

Choose a reason for hiding this comment

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

Loving how this is starting to look!

@soapy1 soapy1 force-pushed the refactor-cli-layer branch 10 times, most recently from b47ebdc to 5560011 Compare July 10, 2025 01:08
@soapy1
Copy link
Contributor Author

soapy1 commented Jul 10, 2025

pre-commit.ci autofix

@soapy1 soapy1 force-pushed the refactor-cli-layer branch 2 times, most recently from 37a8173 to 971526d Compare July 23, 2025 19:58
Comment on lines +339 to +343
names = {MatchSpec(pkg).name for pkg in specs}
for pkg in context.create_default_packages:
pkg_name = MatchSpec(pkg).name
if pkg_name not in names:
specs.append(pkg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the type annotation specs may not necessarily be a list

So what if we do this instead (since the ultimate goal is to add missing default packages):

Suggested change
names = {MatchSpec(pkg).name for pkg in specs}
for pkg in context.create_default_packages:
pkg_name = MatchSpec(pkg).name
if pkg_name not in names:
specs.append(pkg)
# include default packages but override with specs of the same name
specs = {
MatchSpec(pkg).name: pkg
for pkg in (*context.create_default_packages, *specs)
}.values()

@soapy1 soapy1 marked this pull request as draft July 24, 2025 17:45
@soapy1 soapy1 changed the title Refactor cli layer part 1: build environment object Refactor cli layer: use the plugin system to read input files Jul 24, 2025
@soapy1 soapy1 force-pushed the refactor-cli-layer branch from 8ac31ec to 2fc85f9 Compare July 24, 2025 19:58
@soapy1
Copy link
Contributor Author

soapy1 commented Jul 24, 2025

pre-commit.ci autofix

@soapy1
Copy link
Contributor Author

soapy1 commented Jul 24, 2025

This PR is getting a little bit confusing to manage with the refactor to use the environment model + the reconciling of the --file backends. Going to break this up some.

@soapy1 soapy1 force-pushed the refactor-cli-layer branch from 02ed39a to 2fc85f9 Compare July 24, 2025 21:12
soapy1 and others added 20 commits July 30, 2025 12:06
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
Co-authored-by: jaimergp <jaimergp@users.noreply.github.com>
Validate that specifications and conda package filenames are not
both specified in install/update/create commands before creating
an Environment object. This is consistent with the behaviour of
the currently released conda.
@soapy1 soapy1 force-pushed the refactor-cli-layer branch from 2fc85f9 to 0ca78d8 Compare July 30, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA cli pertains to the CLI interface tag::ux related to user experience
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

Use new Environment dataclass to refactor conda.cli.install sources
4 participants