Repository navigation
Closed
Description
People often want to get the data on the task stream in a structured format. This is possible today with some pain. Here is an example:
In [1]: from dask.distributed import Client
In [2]: client = Client()
In [3]: # open dashboard to ensure that the scheduler captures information
In [4]: import dask.array as da
In [5]: x = da.random.random((10, 10), chunks=(5, 5))
In [6]: y = (x + x.T).persist()
In [7]: def f(dask_scheduler):
...: from distributed.bokeh.task_stream import TaskStreamPlugin
...: for plugin in dask_scheduler.plugins:
...: if isinstance(plugin, TaskStreamPlugin):
...: return plugin.buffer
...:
In [8]: client.run_on_scheduler(f)
Out[8]:
[{'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 0, 1)",
'nbytes': 200,
'startstops': (('deserialize', 1531409759.1762872, 1531409759.2346888),
('compute', 1531409759.2363048, 1531409759.2377546)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41153'},
{'key': "('transpose-9114dbb1ddcfe7f13e190d36cd1c2016', 1, 0)",
'nbytes': 200,
'startstops': (('compute', 1531409759.241821, 1531409759.241839),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41153'},
{'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 0, 0)",
'nbytes': 200,
'startstops': (('deserialize', 1531409759.1766217, 1531409759.240885),
('compute', 1531409759.241804, 1531409759.2433474)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41901'},
{'key': "('transpose-add-2a75b9ccf51332e12722bea5cd5fe054', 0, 0)",
'nbytes': 200,
'startstops': (('compute', 1531409759.247657, 1531409759.2477224),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41901'},
{'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 0, 0)",
'nbytes': 200,
'startstops': (('compute', 1531409759.2537527, 1531409759.2537668),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41901'},
{'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 1, 0)",
'nbytes': 200,
'startstops': (('deserialize', 1531409759.1754217, 1531409759.2527452),
('compute', 1531409759.2543166, 1531409759.25571)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41139'},
{'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 1, 1)",
'nbytes': 200,
'startstops': (('deserialize', 1531409759.1780434, 1531409759.2550313),
('compute', 1531409759.2560167, 1531409759.2574341)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:46339'},
{'key': "('transpose-9114dbb1ddcfe7f13e190d36cd1c2016', 0, 1)",
'nbytes': 200,
'startstops': (('compute', 1531409759.2596776, 1531409759.259698),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41139'},
{'key': "('transpose-add-2a75b9ccf51332e12722bea5cd5fe054', 1, 1)",
'nbytes': 200,
'startstops': (('compute', 1531409759.2631009, 1531409759.2631717),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:46339'},
{'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 1, 1)",
'nbytes': 200,
'startstops': (('compute', 1531409759.2695944, 1531409759.269626),),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:46339'},
{'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 0, 1)",
'nbytes': 200,
'startstops': (('transfer', 1531409759.268001, 1531409759.2770529),
('compute', 1531409759.2778597, 1531409759.2778904)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41139'},
{'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 1, 0)",
'nbytes': 200,
'startstops': (('transfer', 1531409759.259737, 1531409759.2771356),
('compute', 1531409759.2778504, 1531409759.2778778)),
'status': 'OK',
'thread': 140000297481984,
'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
'worker': 'tcp://127.0.0.1:41153'}]Some things to clean up:
- Make it easier to ensure that the task stream plugin is running without explicitly opening up the dashboard
- Make this process idempotent, so that we only ever have one plugin running
- Ensure that we want the buffer to be a list, rather than a deque
- Make this available through a method on the client
Metadata
Metadata
Assignees
Labels
No labels
Activity
nicolls1 commentedon Jul 16, 2018
Is it possible to specify a plugin on scheduler startup or is this something that could also be included? Does it currently work that the plugin is only run for a given client or when I register a plugin is it for all new and existing connections?
I am thinking of making a amqp plugin to have the scheduler write the task information for processing externally and I would like to not have to add the plugin every time my clients connect.
Also for 2, does this mean that the scheduler can not chain plugins together or that when they are multiple they need to be run on the same thread?
mrocklin commentedon Jul 16, 2018
The easiest way to do this today would be to add a
--preloadscript. See https://distributed.readthedocs.io/en/latest/setup.html?#customizing-initialization for an exampleThis would be great to see, especially if it was open sourced somewhere. I think that this would be useful to others as well
Many plugins operate at the same time. They run in the event loop and so are on the same thread as the scheduler. Ideally their operations should be fast and not block.
nicolls1 commentedon Jul 16, 2018
Great thanks! Have been doing this on my workers but didn't realize it could be on the scheduler also. The help string makes it seem like you can only specify what should be run on all workers, maybe I'm on an old version also:
Would an example in the docs be the appropriate way to open source it or what would be the best way in your mind?
Got it, thanks!
mrocklin commentedon Jul 16, 2018
Ah, indeed. Do you have any desire to fix the help string there?
nicolls1 commentedon Jul 16, 2018
Sure, will do.
mrocklin commentedon Jul 16, 2018
That might be best. I'm not sure. I'm a little curious how large it will be.