def test_cache_profiler_plot(): with CacheProfiler(metric_name="non-standard") as cprof: get(dsk, "e") p = cprof.visualize( width=500, height=300, tools="hover", title="Not the default", show=False, save=False, ) if BOKEH_VERSION().major < 3: assert p.plot_width == 500 assert p.plot_height == 300 else: assert p.width == 500 assert p.height == 300 assert len(p.tools) == 1 assert isinstance(p.tools[0], bokeh.models.HoverTool) assert p.title.text == "Not the default" assert p.axis[1].axis_label == "Cache Size (non-standard)" # Test empty, checking for errors cprof.clear() with warnings.catch_warnings(record=True) as record: cprof.visualize(show=False, save=False) assert not record
def test_profiler_plot(): with prof: get(dsk, "e") p = prof.visualize( width=500, height=300, tools="hover", title="Not the default", show=False, save=False, ) if BOKEH_VERSION().major < 3: assert p.plot_width == 500 assert p.plot_height == 300 else: assert p.width == 500 assert p.height == 300 assert len(p.tools) == 1 assert isinstance(p.tools[0], bokeh.models.HoverTool) assert p.title.text == "Not the default" # Test empty, checking for errors prof.clear() with warnings.catch_warnings(record=True) as record: prof.visualize(show=False, save=False) assert not record
def test_resource_profiler_plot(): with ResourceProfiler(dt=0.01) as rprof: get(dsk2, "c") p = rprof.visualize( width=500, height=300, tools="hover", title="Not the default", show=False, save=False, ) if BOKEH_VERSION().major < 3: assert p.plot_width == 500 assert p.plot_height == 300 else: assert p.width == 500 assert p.height == 300 assert len(p.tools) == 1 assert isinstance(p.tools[0], bokeh.models.HoverTool) assert p.title.text == "Not the default" # Test with empty and one point, checking for errors rprof.clear() for results in [[], [(1.0, 0, 0)]]: rprof.results = results with warnings.catch_warnings(record=True) as record: p = rprof.visualize(show=False, save=False) assert not record # Check bounds are valid assert p.x_range.start == 0 assert p.x_range.end == 1 assert p.y_range.start == 0 assert p.y_range.end == 100 assert p.extra_y_ranges["memory"].start == 0 assert p.extra_y_ranges["memory"].end == 100
def test_plot_multiple(): from dask.diagnostics.profile_visualize import visualize with ResourceProfiler(dt=0.01) as rprof: with prof: get(dsk2, "c") p = visualize([prof, rprof], label_size=50, title="Not the default", show=False, save=False) # Grid plot layouts changed in Bokeh 3. # See https://github.com/dask/dask/issues/9257 for more details if BOKEH_VERSION().major < 3: figures = [r[0] for r in p.children[1].children] else: figures = [r[0] for r in p.children] assert len(figures) == 2 assert figures[0].title.text == "Not the default" assert figures[0].xaxis[0].axis_label is None assert figures[1].title is None assert figures[1].xaxis[0].axis_label == "Time (s)" # Test empty, checking for errors prof.clear() rprof.clear() visualize([prof, rprof], show=False, save=False)