-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add debug logging for exclude-newer filtering #16606
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
Open
marcvernet31
wants to merge
2
commits into
astral-sh:main
Choose a base branch
from
marcvernet31:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ use std::sync::Arc; | |
| use std::time::Instant; | ||
| use std::{iter, slice, thread}; | ||
|
|
||
| use dashmap::DashMap; | ||
| use dashmap::{DashMap, DashSet}; | ||
| use either::Either; | ||
| use futures::{FutureExt, StreamExt}; | ||
| use itertools::Itertools; | ||
|
|
@@ -135,6 +135,8 @@ struct ResolverState<InstalledPackages: InstalledPackagesProvider> { | |
| unavailable_packages: DashMap<PackageName, UnavailablePackage>, | ||
| /// Incompatibilities for packages that are unavailable at specific versions. | ||
| incomplete_packages: DashMap<PackageName, DashMap<Version, MetadataUnavailable>>, | ||
| /// Packages for which we've already logged `exclude_newer` messages. | ||
| logged_exclude_newer: DashSet<PackageName>, | ||
| /// The options that were used to configure this resolver. | ||
| options: Options, | ||
| /// The reporter to use for this resolver. | ||
|
|
@@ -254,6 +256,7 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider> | |
| installed_packages, | ||
| unavailable_packages: DashMap::default(), | ||
| incomplete_packages: DashMap::default(), | ||
| logged_exclude_newer: DashSet::default(), | ||
| options, | ||
| reporter: None, | ||
| }; | ||
|
|
@@ -1262,6 +1265,9 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
|
|
||
| debug!("Searching for a compatible version of {package} ({range})"); | ||
|
|
||
| // Get the exclude_newer timestamp for this package | ||
| let exclude_newer = self.options.exclude_newer.exclude_newer_package(name); | ||
|
|
||
| // Find a version. | ||
| let Some(candidate) = self.selector.select( | ||
| name, | ||
|
|
@@ -1273,8 +1279,17 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
| index, | ||
| env, | ||
| self.tags.as_ref(), | ||
| exclude_newer, | ||
| ) else { | ||
| // Short circuit: we couldn't find _any_ versions for a package. | ||
| // Log exclude_newer message once per package across all forks. | ||
| if let Some(exclude_newer_ts) = exclude_newer { | ||
| if self.logged_exclude_newer.insert(name.clone()) { | ||
| debug!( | ||
| "Excluding candidates for {name} published after {exclude_newer_ts}" | ||
| ); | ||
|
Comment on lines
+1288
to
+1290
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this being logged if exclude newer is set and we visit this package? That seems misleading? Shouldn't we only log it if we actually filtered a distribution due to exclude newer? Why should we have this in a debug log rather than a hint on failed resolution? |
||
| } | ||
| } | ||
| return Ok(None); | ||
| }; | ||
|
|
||
|
|
@@ -1480,6 +1495,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
| candidate.version().clone().without_local(), | ||
| )); | ||
|
|
||
| let exclude_newer = self.options.exclude_newer.exclude_newer_package(name); | ||
| let Some(base_candidate) = self.selector.select( | ||
| name, | ||
| &range, | ||
|
|
@@ -1490,6 +1506,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
| index, | ||
| env, | ||
| self.tags.as_ref(), | ||
| exclude_newer, | ||
| ) else { | ||
| return Ok(None); | ||
| }; | ||
|
|
@@ -2495,6 +2512,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
|
|
||
| // Try to find a compatible version. If there aren't any compatible versions, | ||
| // short-circuit. | ||
| let exclude_newer = self.options.exclude_newer.exclude_newer_package(&package_name); | ||
| let Some(candidate) = self.selector.select( | ||
| &package_name, | ||
| &range, | ||
|
|
@@ -2505,6 +2523,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag | |
| None, | ||
| &env, | ||
| self.tags.as_ref(), | ||
| exclude_newer, | ||
| ) else { | ||
| return Ok(None); | ||
| }; | ||
|
|
||
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
Oops, something went wrong.
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.
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.
I don't understand why we need to pass it through here if it's not used here?