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

Refine debug #370

Merged
merged 18 commits into from
Mar 19, 2024
Merged

Refine debug #370

merged 18 commits into from
Mar 19, 2024

Conversation

kellertuer
Copy link
Member

@kellertuer kellertuer commented Mar 16, 2024

Yesterday I was a bit annoyed, when trying to help @flgoyens on a debug issue.
Especially, besides the :Stop to debug the stopping criterion, everything was added to :All which still meant it was only reset on start and called in the iteration.

This aims to resolve this.

  • introduces a new hook at the beginning of the iteration
  • refine when debugs are reset on start
  • remove the :All entry, that was used (exclusively) until now
  • introduce a new entry in debug= with Pairs to allow more control where to put Debug.

Since all this is internal and none of the other tests broke, I would consider this still non-breaking (since I assume besides me no one explicitly used :All). All old arrays of debug= still work

I started a few examples in the docs. The new possibilities are now

  • debug = [:Iteration, " | ", :Cost, :Stop] works as before but
  • debug = [ :BeforeIteration => :Iteration, " | ", :Cost] is the new notation that specifically adds :Iteration printing to before calling a step.
  • debug = [:BeforeIteration => :Iteration, :Iteration => [" | ", :Cost], :Stop => :Stop] is now also new but equivalent to the previous one , since :Stop is always added to the end of the algorithm (stored in :Stop) and by default all other things are added to the iteration step (now) at :Iteration.

The last point also shows that this is basically debugception. We can have sequences of debug in single sub-spaces.
So this is more precise, but we keep the simplicity from before (all old debug specifications work as before), but also more flexible.

ToDo

  • refine the documentation
  • extend the tutorial to cover this as well, e.g. printing the iteration number before the subsolver starts

Copy link

codecov bot commented Mar 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.73%. Comparing base (8124786) to head (f5ddd78).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #370   +/-   ##
=======================================
  Coverage   99.73%   99.73%           
=======================================
  Files          73       73           
  Lines        6839     6876   +37     
=======================================
+ Hits         6821     6858   +37     
  Misses         18       18           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kellertuer
Copy link
Member Author

Oh I just noticed the mechanism with DebugEvery does no longer work in this setting.

Until now it “activated” the sub solvers output “for the next iteration” since it was called in the iteration debug after the iteration.
Currently it is called (in the example) before the iteration already, hence I had to fix the number (because now it activated one too early basically). this has to be adapted and I am not yet 100% sure how, maybe with a double check

The two things that have to work is

  1. At the current iteration :BeforeIteration might set the subsolver active (if present)
  2. At an iteration :Iteration might set active for the next iteration

The problem is that the DebugEvery does not “know” which of these two states it is in, so maybe this has to become a variable somehow.

@kellertuer
Copy link
Member Author

I found a solution, the DebugEvery now has an activation_offset to distinguish between this and next iteration to activate, :BeforeIteration sets the default 1 (next) to 0 (this). 1 stays the default since when doing all this by hand (the debug dictionary) the current default will stay the one most used (after iteration debug -> next iterations activation).

@kellertuer
Copy link
Member Author

Here is the new feature summarised https://manoptjl.org/previews/PR370/tutorials/HowToDebug/#Specifying-when-to-print-something – the next section can now also show an even nicer print for sub-solvers, since the iteration number can now first be printed, before the subsolver starts printing.

…opt.jl into kellertuer/more-debug

# Conflicts:
#	docs/src/tutorials/HowToDebug.md
@kellertuer kellertuer added the Ready-for-Review A label for pull requests that are feature-ready label Mar 18, 2024
@kellertuer kellertuer merged commit 342004e into master Mar 19, 2024
15 checks passed
@kellertuer kellertuer deleted the kellertuer/more-debug branch May 4, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready-for-Review A label for pull requests that are feature-ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant