Skip to content

Commit

Permalink
Merge branch 'plots/sankey' into visualization - early parts
Browse files Browse the repository at this point in the history
* plots/sankey: (28 commits)
  diffinsights_web: File with Sankey data -> file without transition works
  diffinsights_web: Improve message when Sankey diagram is not possible
  diffinsigths_web: Remove leftover debug-print, fix unlikely case
  diffinsights_web: Fix SankeyPlot not refreshing on file change
  diffinsights_web: Fix LinesStatsDataStore not refreshing on file change
  diffinsights_web: Turn off disabling SANKEY_DIAGRAM for "Contributions:"
  diffinsights_web: Add support for "sankey" plot type to sampling_info()
  diffinsights_web: Add SankeyPlot to list of possible plots
  diffinsights_web: Rename data_store to timeline_data_store in contributors.py
  diffinsights_web: Add views/plots/sankey.py
  diffinsights_web: Fix handling of missing lines-stats file
  diffinsights_web: Add process_sankey()
  diffinsights_web: Handle input of None in count_file_x_line_lines_stats()
  diffinsights_web: Add sankey_plot_from_triplets() for rough preview
  diffinsights_web: Add reduce_sankey_thin_out()
  diffinsights_web: Add reduce_sankey_from_tail()
  diffinsights_web: Add add_dashdash_dirs_to_counter(), not tested
  diffinsights_web: Add path_to_dirs_only_counter()
  diffinsights_web: Add sankey_triples_from_counter() and its reverse
  diffinsights_web: Add limit_count_to_selected_files()
  ...
  • Loading branch information
jnareb committed Dec 9, 2024
2 parents fd74a11 + 32bf65c commit f15ad8e
Show file tree
Hide file tree
Showing 9 changed files with 640 additions and 33 deletions.
41 changes: 27 additions & 14 deletions src/diffinsights_web/apps/contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import panel as pn

import diffinsights_web.utils.notifications as notifications
from diffinsights_web.datastore.timeline import TimelineDataStore, find_dataset_dir
from diffinsights_web.datastore.linesstats import LinesStatsDataStore
from diffinsights_web.datastore.timeline import TimelineDataStore
from diffinsights_web.datastore import find_dataset_dir
from diffinsights_web.utils.notifications import onload_callback
from diffinsights_web.views.authorsgrid import AuthorInfo, AuthorsGrid
from diffinsights_web.views.dataexplorer import TimelineJSONViewer, TimelinePerspective, \
TimelineDataFrameEnum, perspective_pane
from diffinsights_web.views.info import ContributorsHeader, RepoPlotHeader, ContributionsPercHeader
from diffinsights_web.views.plots.sankey import SankeyPlot
from diffinsights_web.views.plots.timeseries import TimeseriesPlot
from diffinsights_web.widgets.caching import ClearCacheButton

Expand All @@ -27,33 +30,43 @@
pn.state.onload(onload_callback)

dataset_dir = find_dataset_dir()
data_store = TimelineDataStore(dataset_dir=dataset_dir)
timeline_data_store = TimelineDataStore(dataset_dir=dataset_dir)
lines_stats_data_store = LinesStatsDataStore(
dataset_dir=dataset_dir,
timeseries_file=timeline_data_store.select_file_widget,
repo_name=timeline_data_store.select_repo_widget,
)

page_header = ContributorsHeader(
repo=data_store.select_repo_widget,
freq=data_store.resample_frequency_widget,
end_date=data_store.timeline_max_date_rx,
repo=timeline_data_store.select_repo_widget,
freq=timeline_data_store.resample_frequency_widget,
end_date=timeline_data_store.timeline_max_date_rx,
)
sankey_plot = SankeyPlot(
data_store=lines_stats_data_store,
from_date_str=page_header.select_period_from_widget,
)
timeseries_plot = TimeseriesPlot(
data_store=data_store,
data_store=timeline_data_store,
column_name=page_header.select_contribution_type_widget,
from_date_str=page_header.select_period_from_widget,
sankey_plot=sankey_plot,
)
timeseries_plot_header = RepoPlotHeader(
freq=data_store.resample_frequency_widget,
freq=timeline_data_store.resample_frequency_widget,
column_name=page_header.select_contribution_type_widget,
plot=timeseries_plot,
)
contributions_perc_header = ContributionsPercHeader(
data_store=data_store,
data_store=timeline_data_store,
from_date_str=page_header.select_period_from_widget,
)
authors_info_panel = AuthorInfo(
data_store=data_store,
data_store=timeline_data_store,
authors_info_df=timeseries_plot.authors_info_df_rx,
)
authors_grid = AuthorsGrid(
data_store=data_store,
data_store=timeline_data_store,
main_plot=timeseries_plot,
authors_info_df=timeseries_plot.authors_info_df_rx,
top_n=authors_info_panel.top_n_widget,
Expand All @@ -65,7 +78,7 @@
title="Contributors Graph", # TODO: make title dynamic
favicon="favicon.svg",
sidebar=[
data_store,
timeline_data_store,
*authors_info_panel.widgets(),

pn.layout.Divider(), # - - - - - - - - - - - - -
Expand All @@ -88,11 +101,11 @@
authors_grid,
],
)
timeline_perspective = TimelinePerspective(data_store=data_store)
timeline_perspective = TimelinePerspective(data_store=timeline_data_store)
template.main.extend([
pn.layout.Divider(),
pn.Tabs(
('JSON', TimelineJSONViewer(data_store=data_store)),
('JSON', TimelineJSONViewer(data_store=timeline_data_store)),
('data', timeline_perspective.panel(TimelineDataFrameEnum.TIMELINE_DATA)),
('resampled', timeline_perspective.panel(TimelineDataFrameEnum.RESAMPLED_DATA)),
('by author+resampled', timeline_perspective.panel(TimelineDataFrameEnum.BY_AUTHOR_DATA)),
Expand All @@ -101,7 +114,7 @@
perspective_pane(
df=timeseries_plot.authors_info_df_rx,
title=pn.rx("Authors info for repo={repo!r}, from={from_date!r}") \
.format(repo=data_store.select_repo_widget,
.format(repo=timeline_data_store.select_repo_widget,
from_date=page_header.select_period_from_widget)
)
),
Expand Down
17 changes: 17 additions & 0 deletions src/diffinsights_web/datastore/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pathlib import Path
from typing import Optional

import panel as pn

DATASET_DIR = 'data/examples/stats'


@pn.cache
def find_dataset_dir() -> Optional[Path]:
for TOP_DIR in ['', '..', '../..']:
full_dir = Path(TOP_DIR).joinpath(DATASET_DIR)

if full_dir.is_dir():
return full_dir

return None
Loading

0 comments on commit f15ad8e

Please sign in to comment.