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

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

Open
rbavery opened this issue Aug 28, 2019 · 6 comments
Open
Labels
good first issue Clearly described and easy to accomplish. Good for beginners to the project.

Comments

@rbavery
Copy link

rbavery commented Aug 28, 2019

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

rbavery commented Aug 28, 2019

solved, I switched to using the dashboard

@rbavery rbavery closed this as completed Aug 28, 2019
@marberi
Copy link

marberi commented Jan 28, 2020

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

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 mrocklin reopened this Feb 21, 2020
@mrocklin
Copy link
Member

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.

@mrocklin mrocklin added the good first issue Clearly described and easy to accomplish. Good for beginners to the project. label Feb 21, 2020
@avriiil
Copy link
Contributor

avriiil commented Oct 5, 2021

@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
Copy link
Collaborator

gjoseph92 commented Oct 7, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Clearly described and easy to accomplish. Good for beginners to the project.
Projects
None yet
Development

No branches or pull requests

5 participants