-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
SlogLogger emit data config #349
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #349 +/- ##
==========================================
- Coverage 93.35% 93.21% -0.15%
==========================================
Files 117 117
Lines 18803 18881 +78
==========================================
+ Hits 17554 17599 +45
- Misses 1249 1282 +33
☔ View full report in Codecov by Sentry. |
Thanks a lot for this work! I apologize again to you for the very late response. Unfortunately you chose the worst possible time to issue a PR this big as I'm currently extraordinarily busy ;) Therefore I'm unfortunately unable to give a detailed review right know, but I do want to give you a bit of feedback before you invest more time into this PR. Generally, I'm very happy to see filtering implemented in the SlogLogger; however, I'm not convinced that this approach is the way to go. A few points:
I had the need for filtering also in a new observer I am working on in #311. I chose to collect a list of strings and then only select the ones listed (see line 148 in this file). Note that this code essentially does something quite different to what you want to achieve, but I think the approach should be similar. Regarding observing parameters/gradients and so on: I would love to see this, but maybe it would be easier to implement this in a dedicated observer? I'm not sure though, just an idea to think about :) Thanks again for this contribution, I really appreciate it! I hope that not too much of your work needs to be changed and I hope that I will be able to give you a detailed review soon, but unfortunately I cannot promise it right now. |
Thanks for taking the time to look it over and provide feedback! That is a great help, and thanks for letting me know about your availability. I don't have expectations of a timeline, so please don't feel pressured to work on this. In response to your points:
I'll check out the observer you are working on, thanks for the references! For the solver specific data, like parameters and gradients, I do think it would take a different type of observer, as right now the I'm happy to completely redo it all if a better solution is out there! You know your crate, and how pieces fit together better than I do, so I'll happily take your direction. Thanks for the discussion. |
I agree that string comparisons aren't the most elegant solution, not only for type safety, but also for performance reasons.
I see, sorry for the misunderstanding!
That's a good point! The |
I found myself wanting to be able to customize what data the
SlogLogger
observer was logging, so I attempted to implement this functionality via the builder pattern as shown in the doc example in thedata
method onSlogLogger
.To do this, I needed to add the
Debug
trait as a trait bound to thetype Param
associated types, hence why this PR touches so many files. This could cause breaking changes for users.Since this uses a builder style pattern to define what data is logged, the default contains the same data as what was previously hard coded, so end users should not experience any breaking changes in their observer configurations. To customize the data that is logged, a new
enum
calledStateData
has been defined in thestate/mod.rs
file that covers all the available data you can get from theState
trait. A user supplies aVec
of these enum variants and then the logger iterates through and emits them. TheDebug
trait was needed because I wanted to print out theParam
s as well, which are generics.The motivation for doing this was to actually be able to log the gradient of a problem as well, but since not every solver has a defined gradient, I'm less sure that can be done. I will need assistance in evaluating that possibility, since it would significantly help with debugging!
Let me know what you think! Thanks for building a cool crate :)