-
Notifications
You must be signed in to change notification settings - Fork 1.9k
add "environment consistency" health check to conda doctor
#14726
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
Conversation
CodSpeed Performance ReportMerging #14726 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add tests (both consistent and inconsistent environments) to better understand if this check is doing what we expect it to be doing.
Is a solve really necessary here. Iterating over the PrefixRecords and testing if their dependencies are met by packages in the prefix is sufficient to validate an environment. This process can be done using MatchSpecs and not the solver. |
Can a similar check be done by validating that all dependencies for each packages installed in the environment in question are met? This seems favorable given it can be accomplished without engaging the solver or creating mock channels. The following snippet performs this check: def consistent_env_check(prefix: str, verbose: bool) -> None:
# get the plugin manager from context
pm = context.plugin_manager
# find virtual packages
virtual_packages = {str(p.name): p for p in pm.get_virtual_package_records()}
# get prefix data
prefix_data = PrefixData(prefix)
issues = []
# look at each package in the environment for conflicts
prefix_record: PrefixRecord
for prefix_record in prefix_data.iter_records():
for depend in prefix_record.depends:
matchspec = MatchSpec(depend)
package_record_with_name = prefix_data.get(
matchspec.name,
default=virtual_packages.get(matchspec.name, None),
)
if package_record_with_name is None:
issues.append(f"No package {matchspec.name} required by {prefix_record} ({matchspec})")
continue
if not matchspec.match(package_record_with_name):
issues.append(f"{package_record_with_name} does not match {prefix_record} ({matchspec})")
continue
if issues:
print(
f"{X_MARK} The environment is not consistent due to the following issues:\n",
''.join(issues),
)
else:
print(f"{OK_MARK} The environment is consistent.\n") |
@jjhelmus thank you for your suggested changes. |
Description
This PR adds a new health check to
conda doctor
called "environment consistency check".resolves #14715
Todo
Checklist - did you ...
news
directory (using the template) for the next release's release notes?