Skip to content
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

Merged
merged 18 commits into from
Nov 2, 2016
Merged

New progress API #19

merged 18 commits into from
Nov 2, 2016

Conversation

pfitzseb
Copy link
Member

@pfitzseb pfitzseb commented Oct 22, 2016

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:
progress

Some details:

  • The progress bar stack can hold determinate as well as indeterminate progress bars, but only the former will be displayed.
  • The global progress bar is the bottom-most determinate progress bar. If there are no determinate progress bars in the stack, it will be an indeterminate progress bar. If the stack is empty, it will be empty as well.
  • Timing calculations are done in julia-client right now, but could conceivably be done in ink instead. Let me know if anyone has any opinions on that.
  • The lower level API (everything not @progress) should be sufficiently powerful for most applications, but is easily extensible if not.
  • ProgressBar.msg (and therefore msg!()) don't have any effect on what's displayed right now. Originally I wanted to display msg 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!

@pfitzseb
Copy link
Member Author

progress

So, things have gotten a bit prettier. And in the example above there's both versions of the API on display.

(The inner progress bar doesn't show any ETA because no once cares about a remaining time of < 1 second, so none will be displayed in that case)

@pfitzseb
Copy link
Member Author

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...).

@ChrisRackauckas
Copy link
Member

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.

@pfitzseb
Copy link
Member Author

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...

@codecov-io
Copy link

codecov-io commented Oct 26, 2016

Current coverage is 14.95% (diff: 37.50%)

Merging #19 into master will decrease coverage by 0.43%

@@             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          

Powered by Codecov. Last update 1e914ed...471032a

@@ -77,3 +54,5 @@ structure(s::Ptr) = s
structure(s::String) = s
# TODO: do this recursively
structure(x::Array) = x

include("progress.jl")
Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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)
Copy link
Member

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

Copy link
Member Author

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).

@MikeInnes
Copy link
Member

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 @progress, but if I do j = ProgressBar(); progress!(j, n) nothing shows up. Any ideas why that is?

@MikeInnes
Copy link
Member

Oh wait, I remember now, we clear everything when the client is done.

@pfitzseb
Copy link
Member Author

pfitzseb commented Nov 2, 2016

Yeah, that's probably it. I thought about this a bit and now kinda like your idea of wrapping everything in a try ... finally ... and only clearing the indeterminate progress bar we create when a job starts.

@MikeInnes
Copy link
Member

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()))
Copy link
Member

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).

Copy link
Member Author

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?)
@pfitzseb
Copy link
Member Author

pfitzseb commented Nov 2, 2016

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?

Copy link
Member

@MikeInnes MikeInnes left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants