Progressbar: Integration with Julia's logging interface #67
Replies: 14 comments 11 replies
-
It doesn't produce a progress bar. That's exactly the thing: progress bars should not be also defining the data format. This is just throwing a logging message that is then picked up by all of the progress bar packages that are used (but not the old deprecated ones like ProgressMeter.jl)
@pfitzseb would know this.
That's for the user of the progress bar, not the package emitting progress bar information. Why would the ODE solver be choosing for a user whether to emit to the terminal or VS Code? Why would an ODE solver have to know that VS Code is a thing that exists? It's a separation of concerns.
One, both, or neither. The ODE solver doesn't care. That's for the front end to choose. |
Beta Was this translation helpful? Give feedback.
-
I think I'm starting to get it more, and it's potentially very useful. But I still have some questions (though you mentioned perhaps someone else should answer them):
This is were you start to loose me. A key feature of Term's progress bars are that they're highly customizible. There's several preset styles/column types but you can create your own to customize the progress bars for your application. Perhaps an ODE solvers wants to display specific types of information. I don't know much about how ODEs are solved under the hood, but you can imagine wanting to show something like objective function value or some other information about what's happening under the hood. Indeed perhaps you want to allow the users to choose how much detail they want to see and create different progress bar visualizations accordingly. Another package might want to display download file size/speed etc... It's not clear to me that going through
And here is where I'm completely lost. What do you mean to emit to VS Code? To it's embedded Julia REPL? Progress bars in term will show wherever Thanks for the help and info. |
Beta Was this translation helpful? Give feedback.
-
Did you take a look at the ProgressLogging docs? We're basically (ab)using the logging interface to decouple progress bar updates from the rendering. VS Code runs all user code with its own logger, which special cases ProgressLogging log-messages and pipes everything else through to the global/parent logger. |
Beta Was this translation helpful? Give feedback.
-
I did, but there's not much as far as docs go beyond the few lines that are also in the README. There's one minimal example and no display of what the output is or any explanation of what's happening under the hood (or other ways in which the package can be used). How am I to understand "We're basically (ab)using the logging interface to decouple progress bar updates from the rendering." from that? How would one know how to personalize the display or integrate ProgressLogging with another library?
As far as I can tell
I see, that seems useful indeed. I haven't used Juno yet bot one day I will make sure Term works on it. For now this wouldn't be possible with Term. I thank you both for your time, but it seems to me like this is not going to work out. E.g. this code in Term: pbar = ProgressBar(; refresh_rate=60, expand=false, width=150)
outer = addjob!(pbar; N=3, description="outer")
start!(pbar)
for i in 1:3
inner = addjob!(pbar, N=100, description="inner $i")
for j in 1:100
update!(inner)
sleep(0.005)
end
update!(outer)
removejob!(pbar, inner)
sleep(0.02)
end
stop!(pbar) Has one main progress bar for the outer loop and other ones for the inner loops which are spawned/deleted as necessary, while this creates 3 progress bars that are updated simultaneously but finish at different times: pbar = ProgressBar(; refresh_rate=60, expand=false, width=150)
j1 = addjob!(pbar; N=50, description="First")
j2 = addjob!(pbar; N=75, description="Second")
j3 = addjob!(pbar; N=100, description="Third")
for i in 1:100
update!(j1)
update!(j2)
update!(j3)
sleep(0.005)
end
stop!(pbar) I just don't understand how you would achieve this kind of control with the things you're suggesting. I suppose in the end if all you want is a simple progressbar then all this overhead is unnecessary (though Term also has a |
Beta Was this translation helpful? Give feedback.
-
I don't quite see why any of that wouldn't be possible with the ProgressLogging infrastructure. TerminalLoggers.jl is another frontend for it and you'd write your examples as e.g.
|
Beta Was this translation helpful? Give feedback.
-
I think I'm starting to understand more now, thank you. I would have to replace I think that could work, but I don't think I like it, for several reasons:
Also I couldn't get it to work in VS Code, it shows this at the bottom instead of printing to the console. I think this is what @ChrisRackauckas was referring to above, but this is emphatically not what I would like to happen with Term: Also, a slight change to the example messes everything up: using UUIDs
id1, id2, id3 = uuid4(), uuid4(), uuid4();
for i in 1:100
i % 25 == 0 && @info ProgressLogging.Progress(id1, min(i/50, 1), name="first")
@info ProgressLogging.Progress(id2, min(i/75, 1), name="second")
@info ProgressLogging.Progress(id3, min(i/100, 1), name="third")
sleep(0.005)
end
@info ProgressLogging.Progress(id1, done=true)
@info ProgressLogging.Progress(id2, done=true)
@info ProgressLogging.Progress(id3, done=true) The first bar now should be updated more rarely, but it should still be visible, when I try it in the REPL it disappears when it's not updated, this is decidedly not what I want to happen. Also, this would mean that progressbars are updated only when |
Beta Was this translation helpful? Give feedback.
-
There's a setting for that; VS Code is currently fairly intrusive in that it inserts itself between the global logger and user code (which can of course be circumvented via
It doesn't, really. The progress meter is only created once the first
What does that mean? You also have explicit statements for updating progress ( Anyways, I think you're looking at this from the wrong perspective -- seems to me that the important part is for Term to be able to act as a progress frontend, so that library authors can write frontend-independent logging code. |
Beta Was this translation helpful? Give feedback.
-
Okay I think I finally understand. I really appreciate both of you taking the time to walk me through this, now I should spend some time thinking about it and mess around with progress bars. I still have some reserves about going through the logging interface and having to set a global logger, but if I find a way to have all of term's features and a nice syntax I think it should be doable. Thanks again, I'll keep you posted |
Beta Was this translation helpful? Give feedback.
-
That's not any different from https://fedeclaudi.github.io/Term.jl/dev/adv/logging/? |
Beta Was this translation helpful? Give feedback.
-
From @pfitzseb previous comment:
Wait, let me see if I understand correctly. You mean that the package developer does not specify what the progress bar should look like, just that there should be one, and then the user can choose to use Term or another library to visualize the progress bar? If that's the case I previously misunderstood what you meant. if integrator.opts.progress
@logmsg(LogLevel(-1),
integrator.opts.progress_name,
_id = :OrdinaryDiffEq,
message=integrator.opts.progress_message(integrator.dt,integrator.u,integrator.p,integrator.t),
progress="done")
end and what the progressbar looks like depends on what "progressbar rendering package" the user has? That's cool I guess, I can see the benefit in that. It's something that Term should do, be one of the "rendering packages" a downstream user can use. But a core feature of Term in general and the progressbars in particular is customization and being able to create beautiful terminal output, which inevitably involves specifying what the bar should look like using Term. So I think Term should do that, align with the original suggestion of @ChrisRackauckas but also have it's own logging API for users that want more control and don't want to use the logging system (which I realize now is probably what @mkschleg suggested earlier). I still don't understand the whole think about having to write different logic based on where the code's running. That's beyond me. But I think if understand how to do it I will implement the recomended behavior too. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I couldn't help myself, I had to make it better before release. Now you can use nested @progress "outer...." for i in 1:6
@progress "inner... $i" for j in 1:100
sleep(0.01)
end
end
|
Beta Was this translation helpful? Give feedback.
-
This is late to the game, and maybe more motivation isn't required, but another benefit of using the Logging interface that would be critical to many of my applications is that I would want to be able to use things like |
Beta Was this translation helpful? Give feedback.
-
let me review. thank you |
Beta Was this translation helpful? Give feedback.
-
Followup on discussion started in #51 by ChrisRackauckas, see here
From Chris:
Thanks for the additional info Chris. I think this reflects my ignorance about Julia's ecosystem more than anything else, but I'm still confused:
@logmsg
produced a single message.-1
which makes me think that the progress bar is not actually shown to the user.4 is the crucial point. Progressbars should be logged nicely, but the core feature is to show progress to the user, in real time. From what I can see what you're suggesting doesn't do that.
Again, my ignorance: what do Juno, VS Code and ProgressLogging do in this context exactly?
As mentioned in the issue discussion linked above, I need a progressbar capable of handling:
all of which should render nicely in the terminal. So far nothing of what I've seen suggests that Julia's built-in interface (for logging or for progress bars?) can handle all of this. As mentioned I'm happy to conform if there's an infrastructure capable of handling Term's needs, but I won't sacrifice functionality otherwise.
Ps.: Can you provide an image of what the output from the line you've linked to looks like (in the terminal and a in a log file)?
Beta Was this translation helpful? Give feedback.
All reactions