Skip to content

add kwargs to progressbars#2638

Merged
jakirkham merged 3 commits intodask:masterfrom
manugarri:progress-kwargs
May 29, 2019
Merged

add kwargs to progressbars#2638
jakirkham merged 3 commits intodask:masterfrom
manugarri:progress-kwargs

Conversation

@manugarri
Copy link
Copy Markdown
Contributor

This PR allows the user to use the progress function passing progressbar specific arguments, such as interval for TextProgressBars.

Im not sure I have followed all the contributing guidelines. I read the contributing docs and run the tests, but got some tests failing from master.

@quasiben
Copy link
Copy Markdown
Member

@manugarri thanks for the PR. It looks like interval is already a valid argument for TextProgressBars

class TextProgressBar(ProgressBar):
def __init__(
self,
keys,
scheduler=None,
interval="100ms",
width=40,
loop=None,
complete=True,
start=True,

Are there other kwargs you wish to pass ? If so, perhaps add a test to https://github.com/dask/distributed/blob/master/distributed/diagnostics/tests/test_progressbar.py ?

@manugarri
Copy link
Copy Markdown
Contributor Author

@quasiben I know, and this PR basically allows you to pass the argument interval to the general function progress. This way you can add the interval when you are running a cli script.

If not the only alternative to reduce the interval (which produces a long log file on Yarn EMR) is to do something like this (which works, but its not as concise).

from distributed.diagnostics.progressbar import TextProgressBar
from distributed.client import futures_of
output =output.persist()
TextProgressBar(futures_of(output), interval="10s")
output.compute()

Regarding the tests, I can add them but i am not sure it makes sense (since Im not altering the ProgressBar class at all, only allowing it to process kwargs).

@quasiben
Copy link
Copy Markdown
Member

Ah, apologies. I misunderstood.

I think if you want to use progress with arbitrary kwargs you will need to change the assertion in the function definition.

>>> progress(futures) # doctest: +SKIP
[########################################] | 100% Completed | 1.7s
"""
notebook = kwargs.pop("notebook", None)
multi = kwargs.pop("multi", True)
complete = kwargs.pop("complete", True)
assert not kwargs

@mrocklin do you recall why this assertion is made ?

@mrocklin
Copy link
Copy Markdown
Member

@mrocklin do you recall why this assertion is made ?

Unfortunately not

@manugarri
Copy link
Copy Markdown
Contributor Author

@quasiben yup that makes sense, it is easy to assign the remaining bar specific args to a variable and pop them off the kwargs so the assertion wont fail (even though it would be good to know why that assert is there)

@mrocklin
Copy link
Copy Markdown
Member

mrocklin commented May 4, 2019

Checking in, what's the status here?

@quasiben
Copy link
Copy Markdown
Member

quasiben commented May 4, 2019

@manugarri are you planning on removing the assertion and adding a test ?

@manugarri
Copy link
Copy Markdown
Contributor Author

@quasiben I am, my son was just born 2 days ago and we just left the hospital. Will do a PR as soon as I can :D

@quasiben
Copy link
Copy Markdown
Member

quasiben commented May 6, 2019

@manugarri congratulations!!! be with family -- this can wait

@manugarri
Copy link
Copy Markdown
Contributor Author

@quasiben I removed the assertion, let me know if its ok :)

@quasiben
Copy link
Copy Markdown
Member

@manugarri apologies for dropping this. There are still some linting issues -- if you run black distributed this should correct everything for you. Also, I would recommend adding the following test to test_progressbar.py

def test_progress_function_w_kwargs(client, capsys):
    f = client.submit(lambda: 1)
    g = client.submit(lambda: 2)

    progress(f, interval="20ms")
    check_bar_completed(capsys)

@mrocklin
Copy link
Copy Markdown
Member

Merging this in. Thanks @manugarri !

Also, I notice that this is your first code contribution to this repository. Welcome!

@quasiben
Copy link
Copy Markdown
Member

Yes, thank you @manugarri !

Thanks for merging @mrocklin

@manugarri
Copy link
Copy Markdown
Contributor Author

thanks guys!, i apologize for not adding the test, im a bit behind these days :)

@jakirkham jakirkham merged commit 23b1d93 into dask:master May 29, 2019
@jakirkham
Copy link
Copy Markdown
Member

It seems we forgot to merge. Sorry about that. Have gone ahead and merged. Thanks all! 😄

muammar added a commit to muammar/distributed that referenced this pull request Jun 12, 2019
* upstream/master: (58 commits)
  Add unknown pytest markers (dask#2764)
  Delay lookup of allowed failures. (dask#2761)
  Change address -> worker in ColumnDataSource for nbytes plot (dask#2755)
  Remove module state in Prometheus Handlers (dask#2760)
  Add stress test for UCX (dask#2759)
  Add nanny logs (dask#2744)
  Move some of the adaptive logic into the scheduler (dask#2735)
  Add SpecCluster.new_worker_spec method (dask#2751)
  Worker dashboard fixes (dask#2747)
  Add async context managers to scheduler/worker classes (dask#2745)
  Fix the resource key representation before sending graphs (dask#2716) (dask#2733)
  Allow user to configure whether workers are daemon. (dask#2739)
  Pin pytest >=4 with pip in appveyor and python 3.5 (dask#2737)
  Add Experimental UCX Comm (dask#2591)
  Close nannies gracefully (dask#2731)
  add kwargs to progressbars (dask#2638)
  Add back LocalCluster.__repr__. (dask#2732)
  Move bokeh module to dashboard (dask#2724)
  Close clusters at exit (dask#2730)
  Add SchedulerPlugin TaskState example (dask#2622)
  ...
muammar added a commit to muammar/distributed that referenced this pull request Jul 18, 2019
* upstream/master: (43 commits)
  Add unknown pytest markers (dask#2764)
  Delay lookup of allowed failures. (dask#2761)
  Change address -> worker in ColumnDataSource for nbytes plot (dask#2755)
  Remove module state in Prometheus Handlers (dask#2760)
  Add stress test for UCX (dask#2759)
  Add nanny logs (dask#2744)
  Move some of the adaptive logic into the scheduler (dask#2735)
  Add SpecCluster.new_worker_spec method (dask#2751)
  Worker dashboard fixes (dask#2747)
  Add async context managers to scheduler/worker classes (dask#2745)
  Fix the resource key representation before sending graphs (dask#2716) (dask#2733)
  Allow user to configure whether workers are daemon. (dask#2739)
  Pin pytest >=4 with pip in appveyor and python 3.5 (dask#2737)
  Add Experimental UCX Comm (dask#2591)
  Close nannies gracefully (dask#2731)
  add kwargs to progressbars (dask#2638)
  Add back LocalCluster.__repr__. (dask#2732)
  Move bokeh module to dashboard (dask#2724)
  Close clusters at exit (dask#2730)
  Add SchedulerPlugin TaskState example (dask#2622)
  ...
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