-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
automatic cross platform progress monitoring #450
Conversation
No noticable overhead: using OrdinaryDiffEq
using BenchmarkTools
@btime solve(
ODEProblem((u, p, t) -> -u, 1.0, nothing),
Euler();
dt = 0.5,
tspan = (0.0, 0.1),
#progress = true,
#progress_steps = 1,
)
# Before
44.600 μs (334 allocations: 26.61 KiB)
45.900 μs (334 allocations: 26.61 KiB)
# After
45.000 μs (338 allocations: 26.75 KiB)
46.500 μs (338 allocations: 26.75 KiB) |
@davidanthoff is there a logger that needs to be set with VSCode? |
We don't have any progress UI support in VS Code. |
I don't think this is a good solution. Setting logger sinks should be controlled at the top application level and never in libraries. This allows libraries to compose together while giving the application control of the log stream. What if people want to send informational messages from DiffEq to a file? (Or from a user defined function DiffEq calls?) Overriding the global logger sink prevents this.
In the case of interactive work, the "application level" for the purposes of user code is the REPL in use. So it's appropriate for
In summary, if you're having trouble with Juno + TerminalLoggers, we need to figure out what's going wrong and sort it out at the application level. Not in the libraries which the user may happen to have loaded. |
No, it definitely does not do that...
What about having the logger as a keyword argument? I'm looking for a solution for today, and a discussion for tomorrow. |
@@ -255,3 +255,6 @@ prob2dtmin(tspan, onet, ::Any) = onet*1//10^(10) | |||
timedepentdtmin(integrator::DEIntegrator) = timedepentdtmin(integrator.t, integrator.opts.dtmin) | |||
timedepentdtmin(t::AbstractFloat, dtmin) = abs(max(eps(t), dtmin)) | |||
timedepentdtmin(::Any, dtmin) = abs(dtmin) | |||
|
|||
maybe_with_logger(f, logger) = logger === nothing ? f() : with_logger(f, logger) | |||
default_logger() = Juno.isactive() ? nothing : TerminalLogger() |
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.
default_logger() = Juno.isactive() ? nothing : TerminalLogger() | |
default_logger() = Juno.isactive() || current_logger() isa TerminalLogger ? nothing : TerminalLogger() |
or, even more hacky "solution" that does not require Juno
:
default_logger() = Juno.isactive() ? nothing : TerminalLogger() | |
default_logger() = | |
Logging.min_enabled_level(current_logger()) == LogLevel(-1) ? nothing : TerminalLogger() |
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.
how does the latter work with Juno?
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.
Actually, I think @devmotion's solution using LoggingExtras.TeeLogger
is much better SciML/DifferentialEquations.jl#424 (comment)
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.
how does the latter work with Juno?
The log level of the JunoProgressLogger
is guaranteed to be <= -1: https://github.com/JunoLab/Atom.jl/blob/016327893e4c2a22688446758debd1a4d47ed721/src/progress.jl#L75-L76
I agree with all what @c42f said. But, for a short term solution, I don't think it's a horrible idea.
One workaround is to use |
BTW, if you want progress bars to be nicely shown in Windows consoles, https://github.com/tkf/ConsoleProgressMonitor.jl may be better. It just uses ProgressMeter.jl behind the scene. Though I consider ConsoleProgressMonitor.jl more or less dead as I only use TerminalLoggers.jl. |
Ok. But I'm then confused that |
Yeah, it's just some functions for interacting with Juno, but doesn't include Atom.jl or the big dependencies. |
Actually, I think a better solution is to just check if get(NamedTuple(kwargs), :progress, false) === true &&
Logging.min_enabled_level(current_logger()) > LogLevel(-1)
@warn """
`progress = true` is passed but your logger does not support progress bars.
Please see the documentation for how to set it up:
https://...
"""
end |
Maybe we can add a function (say) |
That would also work (add the I think the long term direction for progress should be to remove the
This seems like a good thing to try out. I feel like it's roughly the job of Btw, I was thinking something kind of related — that a filter for progress logs could sensibly live in |
Good idea 👍
Agree in general, but for DiffEq API, I think it's reasonable to have
Agree. Let's track that it in JuliaLogging/ProgressLogging.jl#9 |
I would like this too: everything across Julia should have a common way to turn on/off all logging, like warnings, progress bars, etc. Having a different setup for every package, and not being able to turn it off in many, is just confusing and doesn't compose well. But for now this seems like the best solution, so I'll merge but I'm glad there's an ongoing discussion to be had 😄 |
I completely agree, and so for quite some time I was arguing that we should not provide a default progress logger in AbstractMCMC but only display a warning if the current logger seems unable to handle progress logs (based on the |
For the record: JunoLab/Atom.jl#298 fixes the problems with Juno + TerminalLoggers.jl (or any other non-Base global logger). |
@pfitzseb @tkf @devmotion @c42f any issues you see with doing this kind of thing?