-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from savitakartik/nodes_tab
First pass at Nodes tab
- Loading branch information
Showing
14 changed files
with
275 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Global plot settings | ||
PLOT_WIDTH = 1000 | ||
PLOT_HEIGHT = 600 | ||
THRESHOLD = 1000 # max number of points to overlay on a plot | ||
THRESHOLD = 1000 # max number of points to overlay on a plot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import os | ||
import importlib | ||
import os | ||
|
||
# List all files in the current directory | ||
for module_file in os.listdir(os.path.dirname(__file__)): | ||
# Check if it's a python file and not this __init__ file | ||
if module_file.endswith('.py') and module_file != '__init__.py': | ||
if module_file.endswith(".py") and module_file != "__init__.py": | ||
module_name = module_file[:-3] # remove the .py extension | ||
module = importlib.import_module('.' + module_name, package=__name__) | ||
module = importlib.import_module("." + module_name, package=__name__) | ||
|
||
# Add the page function to the current module's namespace | ||
globals()[module_name] = module.page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import functools | ||
|
||
import holoviews as hv | ||
import holoviews.operation.datashader as hd | ||
import hvplot.pandas # noqa | ||
import numpy as np | ||
import panel as pn | ||
|
||
import config | ||
from plot_helpers import filter_points | ||
from plot_helpers import hover_points | ||
from plot_helpers import make_hist_matplotlib | ||
|
||
|
||
def page(tsm): | ||
hv.extension("matplotlib") | ||
df_nodes = tsm.nodes_df | ||
df_internal_nodes = df_nodes[ | ||
(df_nodes.is_sample == 0) & (df_nodes.ancestors_span != -np.inf) | ||
] | ||
bins = min(50, int(np.sqrt(len(df_internal_nodes)))) | ||
|
||
ancestor_spans_hist_func = functools.partial( | ||
make_hist_matplotlib, | ||
df_internal_nodes.ancestors_span, | ||
"Ancestor spans per node", | ||
num_bins=bins, | ||
log_y=True, | ||
) | ||
|
||
log_y_checkbox = pn.widgets.Checkbox(name="log y-axis of histogram", value=True) | ||
|
||
ancestor_spans_hist_panel = pn.bind( | ||
ancestor_spans_hist_func, | ||
log_y=log_y_checkbox, | ||
) | ||
|
||
hist_panel = pn.Column( | ||
ancestor_spans_hist_panel, | ||
) | ||
|
||
hv.extension("bokeh") | ||
points = df_nodes.hvplot.scatter( | ||
x="ancestors_span", | ||
y="time", | ||
hover_cols=["ancestors_span", "time"], | ||
).opts(width=config.PLOT_WIDTH, height=config.PLOT_HEIGHT) | ||
|
||
range_stream = hv.streams.RangeXY(source=points) | ||
streams = [range_stream] | ||
filtered = points.apply(filter_points, streams=streams) | ||
hover = filtered.apply(hover_points, threshold=config.THRESHOLD) | ||
shaded = hd.datashade(filtered, width=400, height=400, streams=streams) | ||
|
||
main = (shaded * hover).opts( | ||
hv.opts.Points(tools=["hover"], alpha=0.1, hover_alpha=0.2, size=10) | ||
) | ||
|
||
plot_options = pn.Column( | ||
pn.pane.Markdown("# Plot Options"), | ||
log_y_checkbox, | ||
) | ||
return pn.Column(main, hist_panel, plot_options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import panel as pn | ||
|
||
|
||
def page(tsm): | ||
return pn.pane.HTML(tsm.ts) | ||
return pn.pane.HTML(tsm.ts) |
Oops, something went wrong.