Register base-protection health check for conda doctor --fix#88
Open
Register base-protection health check for conda doctor --fix#88
conda doctor --fix#88Conversation
…elp text Fix #74. - Introduced `conda migrate base` for base environment migration. - Added `--list` option to display available migration tasks. - Updated documentation and README to reflect new command structure. - Enhanced tests for new functionality and help commands.
- Remove standalone 'conda migrate' subcommand - Expose base environment protection via 'conda fix base' using conda's new fix task plugin framework - Rename main_migrate.py to main_fix_base.py and clean up unused code - Update README to document both 'conda self' and 'conda fix base' - Update tests to use 'conda fix' instead of 'conda migrate' - Improve test coverage and type hints The 'conda self' subcommand for managing base environment packages remains unchanged. The base protection task is now accessed via 'conda fix base' which uses conda's plugin-based fix task system.
- Update plugin.py: CondaFixTask -> CondaHealthFix - Update plugin.py: conda_fix_tasks -> conda_health_fixes - Update main_fix_base.py docstrings - Update README.md terminology - Update tests for new UI text and error handling - Rename news file This aligns with the conda plugin API rename for better symmetry with 'health checks' from conda doctor.
The CondaHealthFix type only exists in conda versions with the fix subcommand. Wrap the import in try/except so conda-self works with older conda versions (just without the fix base feature).
The base environment protection functionality remains available via conda self commands. The conda_health_fixes hook has been removed from conda in favor of the simpler conda doctor --fix approach.
Register a health check with conda doctor that: - Checks if the base environment is protected (frozen) - Offers to fix by protecting the base environment The health check only runs when checking the base environment and provides verbose output explaining why protection is recommended. Implementation split: hookimpl in plugin.py, functions in health_check.py
8ee01c5 to
453e283
Compare
Import health check status marks from conda instead of defining locally.
- Move health_check.py to health_checks/base_protection.py - Add health_checks/__init__.py with plugins list - Move @hookimpl decorator into base_protection module - Update plugin.py to import health_checks for registration
Keep the implementation in health_checks/base_protection.py but define the hookimpl in plugin.py with a lazy import to avoid import-time side effects.
- Keep main_fix_base.py as internal implementation for health check fix - Update README to document using 'conda doctor --fix' for base protection - Remove protect subcommand registration that was never completed
- Delete main_fix_base.py - Move all protection workflow logic into health_checks/base_protection.py - The fix is now self-contained in the health check module
- Fix SUCCESS_MESSAGE to show activation command instead of claiming auto-activation - Simplify variable names and reduce redundancy - Shorten warning messages - Use pathlib.Path for cleaner path handling
- Set id='base-protection' for cleaner CLI usage - Update README with new --list and --fix id syntax
2 tasks
- Update CondaHealthCheck to use `fixer` parameter with ConfirmCallback - Replace confirm_yn() calls with confirm() callback passed by framework - Add separate `fix` description parameter for --list output - Bump conda dependency to >=26.1.0 - Add conda-canary channel testing to CI to catch compatibility issues early
The new health check API is on conda main but not released. Keep the existing version requirement for stable channels and test with conda-canary for the unreleased API.
The new health check API (fixer with ConfirmCallback) is only available in conda-canary builds. Only run tests with conda-canary until the required conda version is released. The full test matrix is preserved in comments for easy restoration.
conda-canary may not have Python 3.13 builds for all platforms. Use Python 3.12 and restrict platform solving to linux-64 only.
Pixi tries to solve all environments for all platforms, which fails with conda-canary. Use setup-miniconda directly with conda-canary channel for simpler, more reliable canary testing.
- Test is_base_environment and is_base_protected helper functions - Test check action for base environment detection - Test fix fixer early exit conditions - Test plugin registration (skipped on older conda without fixer API) - Add fallback for OK_MARK/X_MARK constants not in stable conda
- Convert class-based tests to function-based tests - Use pytest fixtures (fake_base_env, protected_base_env) instead of mocks - Use native pytest fixtures (tmp_path, monkeypatch, capsys) - Restructure fix() to defer imports until after confirm callback
The fixer API (with ConfirmCallback) requires conda >= 26.1.0. On older conda versions, only the check action is registered, allowing the plugin to work without the fix functionality.
- Make version assertions more flexible in test_update_all (canary builds have different version string formats) - Skip integration tests (test_reset, test_reset_migrate) for canary builds due to dependency resolution issues with package constraints
- Shorten summary string in plugin.py - Move Path import to TYPE_CHECKING block - Fix line length in test comment
- Use try/except in plugin.py instead of checking __dataclass_fields__ - Use hasattr() in test instead of __dataclass_fields__ - More Pythonic EAFP style
- Skip test_remove_nonessential_plugin (dependency resolution issues) - Skip test_update_all (version mismatch between module and installed)
Member
Author
|
This is on hold until the conda 26.1.0 release has happened with the require plugin hook. |
- Bump conda dependency to >=26.1.0 in pixi config - Restore full test matrix now that health check API is released - Remove backwards compatibility code from plugin.py
Member
Author
|
Updated for conda 26.1.0 release:
Ready for review. |
- Update inline import comment to explain lazy loading - Remove try/except for OK_MARK/X_MARK (available in conda 26.1.0)
- Change macos-latest to use conda-forge instead of defaults - Remove macOS platforms from pixi config when testing defaults (conda 26.1.0 not available on defaults channel for macOS)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Registers a
base-protectionhealth check that integrates withconda doctor.Fixes #74.
Requires: conda >= 26.1.0 (health check fixer API from conda/conda#15530)
What it does
conda doctor- shows if base environment is protected or notconda doctor --fix- offers to protect your base environmentWhen fixing, the health check:
defaultenvironmentdefaultUsage
Changes
base-protectionhealth check viaconda_health_checkshookconda doctoroutput