-
Notifications
You must be signed in to change notification settings - Fork 23
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
New progress API #19
New progress API #19
Conversation
Also, does the next release have to support 0.4? I can't figure out how to get the macros working there (and don't rellay want to spend any more time on it anyways...). |
I know I will be making heavy use of this, but am not supporting v0.4 in any of my packages anymore, but that's just me. |
Right. We also have the latest released version of Juno.jl working on 0.4, so maybe that's enough. Apart from that: What are your thoughts for fallbacks if the code isn't running in Juno? I guess we could redirect our methods to ProgressMeter.jl or create our own implementation of a progress meter in the console, but I'm not super interested in that... |
and relocate progress.jl
c4dfbbc
to
e4b634c
Compare
Current coverage is 14.95% (diff: 37.50%)@@ master #19 diff @@
==========================================
Files 7 8 +1
Lines 91 107 +16
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 14 16 +2
- Misses 77 91 +14
Partials 0 0
|
@@ -77,3 +54,5 @@ structure(s::Ptr) = s | |||
structure(s::String) = s | |||
# TODO: do this recursively | |||
structure(x::Array) = x | |||
|
|||
include("progress.jl") |
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.
This is easier to follow if it's included directly from Juno.jl
|
||
type ProgressBar | ||
leftText::String | ||
rightText::String |
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.
Are there any benefits to storing these properties rather than just sending messages to the frontend? Not sure that it's likely to cause issues, but generally it's a good idea to store any state in one place only.
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.
Not really -- in theory it would be enough to have the id/uuid stored. It's just more convenient because we then only have to handle one update case on the Atom side.
Also, I'm lazy and didn't want to have to write Atom.msg("progress!", "update", Dict(:id => p.id, :rightText => s))
or similar.
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.
I'll make the switch to not having any state in the julia object, seems a lot better.
id::String | ||
progress::Float64 | ||
msg::String | ||
determinate::Bool |
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.
Given that progress
and determinate
are exclusive anyway, could we use a special value like NaN
for indeterminate bars?
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.
Yep. I'd go with negative values though.
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 come?
Create a new progress bar and register it with Juno, if possible. | ||
""" | ||
function ProgressBar(;name = "", msg = "") | ||
id = randstring(10) |
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.
If we're going to do IDs like this, may as well use a UUID
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.
Yeah, I wanted to do that but was to lazy to figure out how to get them (since they aren't exported from Base).
I'm playing around with this and it's awesome. I also think it's basically good to go across the board, modulo any final tweaks you want to make. One thing – it's working great for me via |
Oh wait, I remember now, we clear everything when the client is done. |
Yeah, that's probably it. I thought about this a bit and now kinda like your idea of wrapping everything in a |
Ok great, I've made that tweak. As much as anything, making it possible to try the API interactively is a big boon. |
also, parametrize them on whether Juno is running so we can easily define fallbacks for the REPL (maybe use Blink to show progress bars?)
@@ -16,9 +13,10 @@ end | |||
Create a new progress bar and register it with Juno, if possible. | |||
""" | |||
function ProgressBar(;name = "", msg = "") | |||
id = string(Base.Random.uuid1()) | |||
p = ProgressBar(name, "", id, 0.0, msg) | |||
p = ProgressBar{Val{isactive()}}(string(Base.Random.uuid1())) |
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.
FWIW, you could use ProgressBar{true}
directly here.
However, I'm not sure what the aim is with storing this in the type. isactive()
could change in which case this will be incorrect. In future I'd also like to handle the case where the user disconnects and reconnects to the running Julia session (though we don't have to handle that immediately of course).
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.
Heh, just wanted to abuse multiple dispatch for the fallback ;)
But yeah, I'll revert to if isactive() ... else ...
on every call.
and check for `isactive()` on every update call.
and improve docs
so let's get rid of the `!`
(I think?)
Alright, I've changed the API a bit and added a new convenience method. Are there any major issues left in any part of this, or can we merge soon? |
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.
I can't think of any other major issues, so merge at your leisure.
Corresponding Juniper: http://discuss.junolab.org/t/juniper-progress-meters/893/4
Related: JunoLab/atom-julia-client#271 and JunoLab/atom-ink#90; supersedes #4.
Preview:

Some details:
@progress
) should be sufficiently powerful for most applications, but is easily extensible if not.ProgressBar.msg
(and thereforemsg!()
) don't have any effect on what's displayed right now. Originally I wanted to displaymsg
as a tooltip when hovering over a progress bar, but I'm not sure if that's a good solution.cc @ChrisRackauckas, @MikeInnes: Let me know what you think!