-
Notifications
You must be signed in to change notification settings - Fork 191
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
Logging. #71
Comments
Hi, I'd like to help out with this! What would you like logged? |
Hey @arcavaliere that would be awesome if you have the time! It's not a glamorous issue but super important for developing good software. How familiar are you with Julia? I think the first step is to figure out how to use the logging macros, e.g. So instead of julia> @info "Test line"
[ Info: Test line which isn't super useful hopefully we can have logging messages like [09/10/2019 16:12:33] some_file.jl:55: Test line which would be more useful. If that's possible, I think we can start logging a lot more stuff knowing that the messages will have useful timestamps and line numbers. |
@ali-ramadhan I'm just getting started with Julia (coming from a Python background). I'll start looking into those macros! |
Awesome, let us know if you have any questions about anything! Julia Slack is a pretty nice community and are pretty fast at answering general questions too, if you're interested. You just have to request an invite but everyone gets one: https://slackinvite.julialang.org/ |
@arcavaliere just to clarify what I think this issue is all about: during a simulation we often would like to print messages that inform us of the simulation's progress. One example of this comes from a This printing produces a stream of messages during the simulation: julia> include("ocean_wind_mixing_and_convection.jl")
i: 0010, t: 11.000 s, Δt: 1.100 s, wmax = 7.8e-04 ms⁻¹, wall time: 594.383 ms
i: 0020, t: 23.100 s, Δt: 1.210 s, wmax = 1.5e-03 ms⁻¹, wall time: 581.628 ms
i: 0030, t: 36.410 s, Δt: 1.331 s, wmax = 2.3e-03 ms⁻¹, wall time: 567.346 ms
i: 0040, t: 51.051 s, Δt: 1.464 s, wmax = 3.2e-03 ms⁻¹, wall time: 562.455 ms
i: 0050, t: 1.119 min, Δt: 1.611 s, wmax = 4.2e-03 ms⁻¹, wall time: 576.511 ms
i: 0060, t: 1.415 min, Δt: 1.772 s, wmax = 5.2e-03 ms⁻¹, wall time: 571.096 ms In this case, the information we decide to print is:
I think this issue is about a better way to achieve the printing of simulation progress. Two ideas are:
I've thought a bit about 2: I think a generic progress messenger would be both configurable but also include some comforting defaults. A simple way to start could be something like struct ProgressPrinter{DT, M, D}
Δt :: DT
model :: M
diagnostics :: D
end with some kind of print function, something like pretty_Δt(Δt::Number) = prettytime(Δt)
pretty_Δt(Δt::TimeStepWizard) = prettytime(wizard.Δt)
function Base.print(progress::ProgressMessenger)
@printf("i: %04d, t: %s, Δt: %s,
progress.model.clock.iteration, prettytime(progress.model.clock.time), pretty_Δt(progress.Δt))
return nothing
end One could then expand on this design by setting up the struct PrintableDiagnostic{D}
diagnostic :: D
format :: String
name :: String
units :: String
end
function pretty_diagnostic(pd::PrintableDiagnostic, model)
return @sprintf("%s: $(pd.format) %s", pd.name, pd.diagnostic(model), pd.units)
end with this design, the user can pass a list of As for option 1 of using a logging package, perhaps it could be nice to use some logging functionality that's configurable with global variables (?) rather than manually creating a Perhaps @ali-ramadhan has more to say. Another thing we have talked about is somehow having the ability to live-update messages in the terminal (rather than printing a stream of message). This would be nice because it could dramatically reduce the text-noise that a stream of messages invokes, allowing the user to much more easily read and interpret the output of a simulation progress (in addition to creating the possibility for nice pseudo-animations via Any work on any of these ideas could be useful! I'd be happy to Skype to talk more and clarify any questions. |
These are definitely cool ideas for progress statements! I see logging as being much more general though. It should also be used when printing progress statements, but I think it's especially useful to have And maybe |
That sounds like it could be nice; can you maybe give some examples? These messages used in constructors perhaps? So there are two issues: simulation progress statements, and logging for model construction / instantiation? |
I started working on a Additional log levels can be defined if there would be interest in something like For |
Didn't know you could define custom macros like What's the error you're getting? Can you post your code in this issue (or open a pull request)? We can help out with debugging! |
@arcavaliere There's some discussion about logging at CliMA/ClimateMachine.jl#134 |
Here's the PR. I'm running into a |
Hi guys, please feel free to ping me on all logging-related stuff for CLiMA. I pushed through the logging frontend API which exists in 1.0 and I think it can help you understand your simulations. I'm particularly keen to hear use cases related to CLIMA because it's a large scale code with several modules running in a distributed execution environment. Some new logging backend components will need to be invented to make this work well but I think the existing logging frontend is a solid foundation to build on. Regarding live tracking of simulation progress, a couple of points:
|
Hi @c42f thank you for chiming in! Will definitely ping you as we work on logging. I think we probably should have tackled logging much earlier. We still use Definitely hoping we can reach a useful logger that can
Although @arcavaliere seems to be developing a pretty general-purpose MicroLogging.jl looks pretty neat! I like that it puts the log level, file name, and line number on the right as putting them on the left causes messages not to align and makes logs harder to read. TensorBoardLogger looks pretty cool! Would be awesome to have something like that one day, but I guess you'd have to use something like ncusrses... |
I updated the PR with |
That's awesome, thanks @arcavaliere! I think if we can get a printing format similar to MicroLogging.jl with a timestamp on the left and log level + line location then we'll have a great logger we can merge into the code and start using! And once we start using it we can tweak and improve it as we learn more. But let me know if you had other features in mind! |
I do think As you can see over on the |
By the way, this is available in stdlib |
Just reading the code, I see you've assigned them different importance levels. So perhaps I'm wrong! |
Resolved by @arcavaliere in PR #478 🎉 |
Good logging should be a high priority item. Python's logging is great...
Some options:
The text was updated successfully, but these errors were encountered: