dask / distributed

A distributed task scheduler for Dask
https://distributed.dask.org
BSD 3-Clause "New" or "Revised" License
1.58k stars 717 forks source link

AttributeError: 'MultiProgressWidget' object has no attribute 'elapsed_time' #3007

Open rbavery opened 5 years ago

rbavery commented 5 years ago

I was getting an error that ipywidgets was not installed when I ran the following code

from cropmask.preprocess import PreprocessWorkflow, get_arr_channel_mean, setup_dirs
import time
import dask

param_path = "/home/ryan/work/CropMask_RCNN/cropmask/test_preprocess_config.yaml"
scene_list = [
    "/mnt/cropmaskperm/unpacked_landsat_downloads/LT050280322005012001T2-SC20190818204900", 
    "/mnt/cropmaskperm/unpacked_landsat_downloads/LT050310322005021001T1-SC20190818205059",
    "/mnt/cropmaskperm/unpacked_landsat_downloads/LT050290312005031601T1-SC20190818204935",  
    "/mnt/cropmaskperm/unpacked_landsat_downloads/LT050320312005011601T1-SC20190818205113",
]
labels_path = "/mnt/cropmaskperm/external/nebraska_pivots_projected.geojson"

setup_dirs(param_path)

# this is just to get the train dir path
wflow = PreprocessWorkflow(param_path, 
                             scene_list[0],
                             labels_path)

results = []
for scene_path in scene_list:

    wflow = dask.delayed(PreprocessWorkflow)(param_path, scene_path, labels_path)

    band_list = dask.delayed(wflow.yaml_to_band_index)()

    product_list = dask.delayed(wflow.get_product_paths)(band_list)

    dask.delayed(wflow.load_meta_and_bounds)(product_list)

    dask.delayed(wflow.load_single_scene)(product_list)

    dask.delayed(wflow.stack_and_save_bands)()

    dask.delayed(wflow.negative_buffer_and_small_filter)(-31, 100)

    dask.delayed(wflow.grid_images)()

    dask.delayed(wflow.remove_from_gridded)()

    dask.delayed(wflow.move_chips_to_folder)()

    result = dask.delayed(wflow.connected_components)()

    results.append(result)

# https://docs.dask.org/en/stable/delayed-best-practices.html
from dask.distributed import Client, progress

client = Client()  # use dask.distributed by default

x = dask.compute(*results)  # start computation in the background
progress(x)      # watch progress  

so then I installed ipywidgets version 7.5.1 in my conda environment that contains Dask and got this error when running the same code again

tornado.application - ERROR - Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7f9d23efb898>>, <Task finished coro=<MultiProgressBar.listen() done, defined at /data/anaconda/envs/cropmask/lib/python3.7/site-packages/distributed/diagnostics/progressbar.py:238> exception=AttributeError("'MultiProgressWidget' object has no attribute 'elapsed_time'")>)
Traceback (most recent call last):
  File "/data/anaconda/envs/cropmask/lib/python3.7/site-packages/tornado/ioloop.py", line 743, in _run_callback
    ret = callback()
  File "/data/anaconda/envs/cropmask/lib/python3.7/site-packages/tornado/ioloop.py", line 767, in _discard_future_result
    future.result()
  File "/data/anaconda/envs/cropmask/lib/python3.7/site-packages/distributed/diagnostics/progressbar.py", line 282, in listen
    self._draw_stop(**response)
  File "/data/anaconda/envs/cropmask/lib/python3.7/site-packages/distributed/diagnostics/progressbar.py", line 381, in _draw_stop
    + "</div>"
AttributeError: 'MultiProgressWidget' object has no attribute 'elapsed_time'

I'm not sure what the issue is here, seems to be some sort of version conflict between packages or other internal issue since I'm not invoking the "elapsed_time" attribute directly.

I'm using jupyterlab version 1.0.9, python 3.7, and dask version 2.3

rbavery commented 5 years ago

solved, I switched to using the dashboard

marberi commented 4 years ago

Also present in Dask 2.9.2. Just ran into this when trying to run on a machine where I would prefer not opening a webpage.

mrocklin commented 4 years ago
x = dask.compute(*results)  # start computation in the background
progress(x)      # watch progress  

This bug arises because x doesn't have any Dask futures attached to it. The dask.compute function is blocking and returns concrete results, not things on which you can reasonably call progress. Probably you wanted something like dask.persist here.

But, we shouldn't err in this case. I think that the challenge here is that we're only calling _draw_bar if there are keys to draw

        if self.keys and not self.widget.children:
            self.make_widget(all)
mrocklin commented 4 years ago

If someone wants to make things more robust to empty key sets that would be welcome. This shouldn't require deep Dask experience to solve.

avriiil commented 3 years ago

@mrocklin -- I just tried this code which - if I understand your comment above correctly - shouldn't work, but it does. Any pointers to better understand what's going on here?

import random 
from time import sleep
import dask

# simulate work
@dask.delayed
def work(x):
    sleep(x)
    return True

# generate tasks
random.seed(42)
tasks = [work(random.randint(1,5)) for x in range(50)]

client = Client()
futures = client.compute(tasks)

progress(futures)

image

gjoseph92 commented 3 years ago

@rrpelgrim confusingly, client.compute and dask.compute are different. client.compute is non-blocking and returns Futures. dask.compute blocks until the computation is done and returns the actual results (not Futures).

openSourcerer9000 commented 2 weeks ago

Canonical code that used to run doesn't seem to anymore. ds = xr.open_dataset(... progress(ds) Seems distributed is just broken then? Adding client.compute(ds) in between has no effect either.