MCPcopy Create free account
hub / github.com/dask/dask / plot_tasks

Function plot_tasks

dask/diagnostics/profile_visualize.py:158–263  ·  view source on GitHub ↗

Visualize the results of profiling in a bokeh plot. Parameters ---------- results : sequence Output of Profiler.results dsk : dict The dask graph being profiled. start_time : float Start time of the profile in seconds end_time : float End time

(
    results, dsk, start_time, end_time, palette="Viridis", label_size=60, **kwargs
)

Source from the content-addressed store, hash-verified

156
157
158def plot_tasks(
159 results, dsk, start_time, end_time, palette="Viridis", label_size=60, **kwargs
160):
161 """Visualize the results of profiling in a bokeh plot.
162
163 Parameters
164 ----------
165 results : sequence
166 Output of Profiler.results
167 dsk : dict
168 The dask graph being profiled.
169 start_time : float
170 Start time of the profile in seconds
171 end_time : float
172 End time of the profile in seconds
173 palette : string, optional
174 Name of the bokeh palette to use, must be a member of
175 bokeh.palettes.all_palettes.
176 label_size: int (optional)
177 Maximum size of output labels in plot, defaults to 60
178 **kwargs
179 Other keyword arguments, passed to bokeh.figure. These will override
180 all defaults set by visualize.
181
182 Returns
183 -------
184 The completed bokeh plot object.
185 """
186 bp = import_required("bokeh.plotting", _BOKEH_MISSING_MSG)
187 from bokeh.models import HoverTool
188
189 defaults = dict(
190 title="Profile Results",
191 tools="hover,save,reset,xwheel_zoom,xpan",
192 toolbar_location="above",
193 width=800,
194 height=300,
195 )
196 # Support plot_width and plot_height for backwards compatibility
197 if "plot_width" in kwargs:
198 kwargs["width"] = kwargs.pop("plot_width")
199 if "plot_height" in kwargs:
200 kwargs["height"] = kwargs.pop("plot_height")
201 defaults.update(**kwargs)
202
203 if results:
204 keys, tasks, starts, ends, ids = zip(*results)
205
206 id_group = groupby(itemgetter(4), results)
207 timings = {
208 k: [i.end_time - i.start_time for i in v] for (k, v) in id_group.items()
209 }
210 id_lk = {
211 t[0]: n
212 for (n, t) in enumerate(
213 sorted(timings.items(), key=itemgetter(1), reverse=True)
214 )
215 }

Callers 1

_plotMethod · 0.90

Calls 5

import_requiredFunction · 0.90
itemgetterClass · 0.85
get_colorsFunction · 0.85
popMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected