Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor for libmamba v2 (WIP) #457

Draft
wants to merge 76 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
f027cab
Commit progress so far
jaimergp Mar 26, 2024
65c6ae1
Better DX :)
jaimergp Mar 28, 2024
01430b9
Try alpha4
jaimergp Mar 28, 2024
3882971
Bare minimum to make 'conda create -dnx python' work
jaimergp Mar 28, 2024
228578c
Basic install and remove too
jaimergp Mar 28, 2024
d07514c
migrate conflict reporting
jaimergp Mar 28, 2024
ccf16e3
enable tests
jaimergp Mar 28, 2024
0285923
Merge branch 'main' into try-libmamba-2a3
jaimergp Mar 28, 2024
de2b1b0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 28, 2024
39ef557
pre-commit
jaimergp Mar 28, 2024
a9c4506
fix import
jaimergp Mar 28, 2024
f47040a
from solver2
jaimergp Mar 29, 2024
b817de1
no reruns
jaimergp Mar 29, 2024
0a11633
index._channels is now index.channels
jaimergp Mar 29, 2024
0d6fbb5
set flags explicitly
jaimergp Mar 29, 2024
f825677
force bool
jaimergp Mar 29, 2024
13d47ea
These are part of conda/conda, no need to run them here
jaimergp Mar 29, 2024
00f27ef
just use the regular module paths
jaimergp Mar 29, 2024
a749ef4
update ignores
jaimergp Mar 29, 2024
42b7b23
force list
jaimergp Mar 29, 2024
8e74d12
provide more default values
jaimergp Mar 29, 2024
46dec1b
set logger
jaimergp Mar 29, 2024
33af056
Fix SOLV loading
jaimergp Mar 29, 2024
505be03
Fix performance test collection
jaimergp Mar 29, 2024
0b224b3
Parse PackageNotFoundErrors from explained problems, add custom_chann…
jaimergp Apr 1, 2024
ef95ef8
fix typo
jaimergp Apr 1, 2024
07a06c0
fix typeerror
jaimergp Apr 1, 2024
f0e4a93
raise on bad pins
jaimergp Apr 1, 2024
3f5cc5e
fix problem parsing and matchspec roundtrips
jaimergp Apr 1, 2024
a66bc7f
this is part of "Collecting metadata"
jaimergp Apr 1, 2024
af2b49b
channels -> _channels
jaimergp Apr 1, 2024
893348c
require beta
jaimergp Apr 8, 2024
1066bea
do not load tar.bz2 if conda available; enable logging
jaimergp Apr 8, 2024
c9d3868
do not enable debug logging during testing for performance
jaimergp Apr 8, 2024
052f0e8
re-enable this assertion
jaimergp Apr 8, 2024
31fbefe
pre-commit
jaimergp Apr 8, 2024
cc1565b
set more logging
jaimergp Apr 8, 2024
80fc7f8
readd pytest workaround
jaimergp Apr 8, 2024
38c7f70
Allow repodata loading errors in offline mode
jaimergp Apr 8, 2024
e2a3fb6
ensure we pass back the url with credentials
jaimergp Apr 8, 2024
3febd99
clarify why test_python_downgrade_with_pins_removes_truststore curren…
jaimergp Apr 8, 2024
a71a98f
pass subdirs
jaimergp Apr 8, 2024
2089b8b
do not really set libsolv loggers for now
jaimergp Apr 8, 2024
64f71fd
global allow_uninstall = True
jaimergp Apr 8, 2024
d92ee47
more types
jaimergp Apr 8, 2024
9070026
keep updates
jaimergp Apr 9, 2024
a845aa8
point to PR with upstream changes
jaimergp Apr 9, 2024
6dd3666
warn about pins in conflicts
jaimergp Apr 9, 2024
dcac75b
fix tests/core/test_solve.py::test_freeze_deps_1
jaimergp Apr 9, 2024
d3308b0
fix tests/test_create.py::test_neutering_of_historic_specs
jaimergp Apr 9, 2024
8e6cb62
fix tests/models/test_prefix_graph.py::test_sort_without_prep[libmamba]
jaimergp Apr 10, 2024
9773ffb
implement reload_channel()
jaimergp Apr 10, 2024
428aa29
bring _fix_version_field_for_conda_build
jaimergp Apr 10, 2024
e1f2326
pre-commit
jaimergp Apr 10, 2024
736db03
unfreeze dataclass
jaimergp Apr 10, 2024
b201f0e
oops :)
jaimergp Apr 10, 2024
ccf73a5
do not inject pip in installed
jaimergp Apr 10, 2024
c921bc5
adjust subdirs for conda-build
jaimergp Apr 10, 2024
b46adc0
pre-commit
jaimergp Apr 10, 2024
bb83f33
test channel reload
jaimergp Apr 10, 2024
940809c
add Index.n_packages() helper
jaimergp Apr 10, 2024
ed709a0
Merge branch 'main' into try-libmamba-2a3
jaimergp Apr 10, 2024
70b403c
commit v2 changes markdown
jaimergp Apr 10, 2024
828273c
use default traceback in pytest
jaimergp Apr 10, 2024
f1228bb
Merge branch 'try-libmamba-2a3' of github.com:conda/conda-libmamba-so…
jaimergp Apr 10, 2024
ae6071e
use smaller packages
jaimergp Apr 10, 2024
f57ef62
no defaults needed here
jaimergp Apr 10, 2024
c903007
use_default_signal_handler = False
jaimergp Apr 12, 2024
649a718
Merge branch 'main' into try-libmamba-2a3
jaimergp Apr 22, 2024
8c0812c
explicitly choose macos-13
jaimergp Apr 24, 2024
8b21a73
Merge branch 'try-libmamba-2a3' of github.com:conda/conda-libmamba-so…
jaimergp Apr 24, 2024
0809915
Merge branch 'main' of github.com:conda/conda-libmamba-solver into tr…
jaimergp May 7, 2024
15a488f
bump to beta1
jaimergp May 7, 2024
bbf659c
fix problems formatting
jaimergp May 7, 2024
bea1a8a
adopt FORCE_COLOR, NO_COLOR
jaimergp May 7, 2024
d4ffb51
adjust pin detection in problems
jaimergp May 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/conda-forge/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"extensions": [
"charliermarsh.ruff",
"eamodio.gitlens",
"ms-toolsai.jupyter"
"ms-toolsai.jupyter",
"be5invis.toml"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/defaults/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"extensions": [
"charliermarsh.ruff",
"eamodio.gitlens",
"ms-toolsai.jupyter"
"ms-toolsai.jupyter",
"be5invis.toml"
]
}
}
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ echo "Installing dev & test dependencies..."
--file="$SRC_CONDA/tests/requirements-Linux.txt" \
--file="$SRC_CONDA/tests/requirements-s3.txt" \
--file="$SRC_CONDA_LIBMAMBA_SOLVER/dev/requirements.txt" \
--file="$SRC_CONDA_LIBMAMBA_SOLVER/tests/requirements.txt"
--file="$SRC_CONDA_LIBMAMBA_SOLVER/tests/requirements.txt"\
pre-commit
25 changes: 19 additions & 6 deletions .devcontainer/post_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,28 @@ function develop-mamba() (
echo "Miniconda not compatible with develop-mamba"
exit 1
fi
if [ ! -f "$SRC_MAMBA/mamba/setup.py" ]; then
echo "Mamba 1.x not found at $SRC_MAMBA"
if [ ! -f "$SRC_MAMBA/libmamba/CMakeLists.txt" ]; then
echo "Could not find mamba-org/mamba at $SRC_MAMBA"
exit 1
fi
if [ -f "$SRC_MAMBA/mamba/setup.py" ]; then
echo "Mamba 1.x found at $SRC_MAMBA"
mamba_version=1
environment_yaml="$SRC_MAMBA/mamba/environment-dev.yml"
else
echo "Mamba 2.x found at $SRC_MAMBA"
environment_yaml="$SRC_MAMBA/dev/environment-dev.yml"
mamba_version=2
fi
# Install mamba dev dependencies only once:
if [ ! -f ~/.mamba-develop-installed ]; then
# remove "sel(win)" in environment yaml hack since conda does not understand
# libmamba specific specs
echo "Installing mamba 1.x in dev mode..."
sed '/sel(.*)/d' "$SRC_MAMBA/mamba/environment-dev.yml" > /tmp/mamba-environment-dev.yml
sed '/sel(.*)/d' "\$environment_yaml" > /tmp/mamba-environment-dev.yml
# Environment.yml is missing make
echo " - make" >> /tmp/mamba-environment-dev.yml
CONDA_QUIET=1 "$BASE_CONDA/condabin/conda" env update -p "$BASE_CONDA" \
--file /tmp/mamba-environment-dev.yml
"$BASE_CONDA/condabin/conda" install make -yq # missing in mamba's dev env
# Clean build directory to avoid issues with stale build files
test -f "$SRC_MAMBA/build/CMakeCache.txt" && rm -rf "$SRC_MAMBA/build"
fi
Expand All @@ -54,7 +63,11 @@ function develop-mamba() (
make install -C build/
cd -
"$BASE_CONDA/bin/pip" install -e "$SRC_MAMBA/libmambapy/" --no-deps
test -f "$BASE_CONDA/conda-meta/mamba-"*".json" && "$BASE_CONDA/bin/pip" install -e "$SRC_MAMBA/mamba/" --no-deps
if [ "\$mamba_version" == "1" ]; then
test -f "$BASE_CONDA/conda-meta/mamba-"*".json" && "$BASE_CONDA/bin/pip" install -e "$SRC_MAMBA/mamba/" --no-deps
else
echo "Mamba binary installation not supported yet"
fi
touch ~/.mamba-develop-installed || true
)
EOF
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ concurrency:
env:
# https://conda.github.io/conda-libmamba-solver/user-guide/configuration/#advanced-options
CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED: true
PYTEST_RERUN_FAILURES: 3
PYTEST_RERUN_FAILURES: 0
# See https://github.com/conda/conda/pull/13694
# we can't break classic from here; no need to test it
# those tests will still be available for local debugging if necessary
Expand Down Expand Up @@ -108,7 +108,9 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
# repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
repository: jaimergp/conda # TEMPORARY
ref: libmamba-v2-fixes # TEMPORARY
path: conda # CONDA-LIBMAMBA-SOLVER CHANGE

# CONDA-LIBMAMBA-SOLVER CHANGE
Expand Down Expand Up @@ -256,7 +258,9 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
# repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
repository: jaimergp/conda # TEMPORARY
ref: libmamba-v2-fixes # TEMPORARY
path: conda # CONDA-LIBMAMBA-SOLVER CHANGE

# CONDA-LIBMAMBA-SOLVER CHANGE
Expand Down Expand Up @@ -533,7 +537,9 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
# repository: conda/conda # CONDA-LIBMAMBA-SOLVER CHANGE
repository: jaimergp/conda # TEMPORARY
ref: libmamba-v2-fixes # TEMPORARY
path: conda # CONDA-LIBMAMBA-SOLVER CHANGE

# CONDA-LIBMAMBA-SOLVER CHANGE
Expand Down Expand Up @@ -709,7 +715,7 @@ jobs:
include:
- runner: ubuntu-latest
subdir: linux-64
- runner: macos-latest
- runner: macos-13
subdir: osx-64
- runner: macos-14
subdir: osx-arm64
Expand Down
77 changes: 33 additions & 44 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
ci:
autofix_prs: false
# generally speaking we ignore all vendored code as well as tests data
# TODO: Restore index and solver exclude lines before merge
exclude: |
(?x)^(
tests/data/ |
tests/data/.* |
conda_libmamba_solver/_index_v1\.py |
conda_libmamba_solver/_solver_v1\.py |
conda_libmamba_solver/mamba_utils\.py
)/
)$
repos:
# generic verification and formatting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -18,50 +22,35 @@ repos:
# ensure syntaxes are valid
- id: check-toml
- id: check-yaml
exclude: ^(recipe/meta.yaml|tests/data/)
exclude: |
(?x)^(
(conda\.)?recipe/meta.yaml
)
# catch git merge/rebase problems
- id: check-merge-conflict
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: ["--py38-plus"]
exclude: ^conda/exports.py
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
exclude: tests/_reposerver\.py
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
exclude: tests/_reposerver\.py
- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
# auto format Python codes within docstrings
- id: blacken-docs
additional_dependencies: [black]
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pylint
rev: v3.1.0
hooks:
- id: pylint
args: [--exit-zero]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args: [--exit-zero]
# ignore all tests, not just tests data
exclude: ^tests/
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: insert-license
files: \.py$
args: [--license-filepath, .github/disclaimer.txt, --no-extra-eol]
exclude: ^(tests/repodata_time_machine.py|mamba_utils\.py|tests/channel_testing/helpers\.py|tests/channel_testing/reposerver\.py) # extend global exclude
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
# lint & attempt to correct failures (e.g. pyupgrade)
- id: ruff
args: [--fix]
# compatible replacement for black
- id: ruff-format
- repo: meta
# see https://pre-commit.com/#meta-hooks
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
- repo: local
hooks:
- id: git-diff
name: git diff
entry: git diff --exit-code
language: system
pass_filenames: false
always_run: true
12 changes: 12 additions & 0 deletions _v2_changes_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Libmamba v2 integration changes

- Deprecate CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED. No longer needed with v2.
- Typing in all methods
- time_recorder for metadata collection and solving loop
- removed state.BaseIndexHelper
- The libmamba v1 "pool" (collection of "repos"; repo = loaded repodata.json) is now a "database" of "RepoInfo" objects.
- Do use current_repodata.json if explicitly set in CLI
- Move to Ruff for pre-commit linting & formatting
- Logging from libsolv has a big overhead now because it goes from C to C++ to Python to logging to stdout instead of C -> stdout.
- Allow uninstall was previously set to false (only true for conda remove), and we set it up for individual solver jobs involving updates or conflicts. With v2, we have individual control over what to "Keep" instead of drop. This required marking important updates as keepers instead. Otherwise they would be uninstalled.
- Other changes in the test suite discussed in https://github.com/conda/conda/pull/13784
14 changes: 2 additions & 12 deletions conda_libmamba_solver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@
except ImportError:
__version__ = "0.0.0.unknown"

from warnings import warn as _warn

from .solver import LibMambaSolver


def get_solver_class(key="libmamba"):
if key == "libmamba":
return LibMambaSolver
if key == "libmamba-draft":
_warn(
"The 'libmamba-draft' solver has been deprecated. "
"The 'libmamba' solver will be used instead. "
"Please consider updating your code to remove this warning. "
"Using 'libmamba-draft' will result in an error in a future release.",
)
from .solver import LibMambaSolver

return LibMambaSolver
raise ValueError("Key must be 'libmamba'")