-
Notifications
You must be signed in to change notification settings - Fork 44
Logging to help debugging #107
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
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7bb44c4
feat: add logging to help debugging
mpizenberg 780c34d
debug: impl Display for partial solution
mpizenberg 5b8e58e
fix cherry picking
mpizenberg e61bffa
Fix display of assignments in partial_solution
mpizenberg d588b91
debug: nits
Eh2406 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
| //! A Memory acts like a structured partial solution | ||
| //! where terms are regrouped by package in a [Map](crate::type_aliases::Map). | ||
|
|
||
| use std::collections::BTreeSet; | ||
| use std::fmt::Display; | ||
|
|
||
| use crate::internal::arena::Arena; | ||
| use crate::internal::incompatibility::{IncompId, Incompatibility, Relation}; | ||
| use crate::internal::small_map::SmallMap; | ||
|
|
@@ -32,6 +35,24 @@ pub struct PartialSolution<P: Package, V: Version> { | |
| package_assignments: Map<P, PackageAssignments<P, V>>, | ||
| } | ||
|
|
||
| impl<P: Package, V: Version> Display for PartialSolution<P, V> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| let assignments: BTreeSet<String> = self | ||
| .package_assignments | ||
| .iter() | ||
| .map(|(p, pa)| format!("{}: {}", p, pa)) | ||
| .collect(); | ||
| let assignments: Vec<_> = assignments.into_iter().collect(); | ||
|
||
| write!( | ||
| f, | ||
| "next_global_index: {}\ncurrent_decision_level: {:?}\npackage_assignements:\n{}", | ||
| self.next_global_index, | ||
| self.current_decision_level, | ||
| assignments.join("\n") | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| /// Package assignments contain the potential decision and derivations | ||
| /// that have already been made for a given package, | ||
| /// as well as the intersection of terms by all of these. | ||
|
|
@@ -43,19 +64,54 @@ struct PackageAssignments<P: Package, V: Version> { | |
| assignments_intersection: AssignmentsIntersection<V>, | ||
| } | ||
|
|
||
| impl<P: Package, V: Version> Display for PackageAssignments<P, V> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| let derivations: Vec<_> = self | ||
| .dated_derivations | ||
| .iter() | ||
| .map(|dd| dd.to_string()) | ||
| .collect(); | ||
| write!( | ||
| f, | ||
| "decision range: {:?}..{:?}\nderivations:\n {}\n,assignments_intersection: {}", | ||
| self.smallest_decision_level, | ||
| self.highest_decision_level, | ||
| derivations.join("\n "), | ||
| self.assignments_intersection | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub struct DatedDerivation<P: Package, V: Version> { | ||
| global_index: u32, | ||
| decision_level: DecisionLevel, | ||
| cause: IncompId<P, V>, | ||
| } | ||
|
|
||
| impl<P: Package, V: Version> Display for DatedDerivation<P, V> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| write!(f, "{:?}, cause: {:?}", self.decision_level, self.cause) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| enum AssignmentsIntersection<V: Version> { | ||
| Decision((u32, V, Term<V>)), | ||
| Derivations(Term<V>), | ||
| } | ||
|
|
||
| impl<V: Version> Display for AssignmentsIntersection<V> { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| match self { | ||
| Self::Decision((lvl, version, _)) => { | ||
| write!(f, "Decision: level {}, v = {}", lvl, version) | ||
| } | ||
| Self::Derivations(term) => write!(f, "Derivations term: {}", term), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub enum SatisfierSearch<P: Package, V: Version> { | ||
| DifferentDecisionLevels { | ||
|
|
@@ -258,7 +314,14 @@ impl<P: Package, V: Version> PartialSolution<P, V> { | |
| // Check none of the dependencies (new_incompatibilities) | ||
| // would create a conflict (be satisfied). | ||
| if store[new_incompatibilities].iter().all(not_satisfied) { | ||
| log::info!("add_decision: {} @ {}", package, version); | ||
| self.add_decision(package, version); | ||
| } else { | ||
| log::info!( | ||
| "not adding {} @ {} because of its dependencies", | ||
| package, | ||
| version | ||
| ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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
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.
No objection, just wondering:
What features are we trying to opted out of? Why
default-features = false?