Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from dash import html, dcc, callback
import dash

Check warning on line 2 in 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused import dash (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py:2:0: W0611: Unused import dash (unused-import)
import dash_bootstrap_components as dbc
import dash_mantine_components as dmc
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go

Check warning on line 6 in 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused plotly.graph_objects imported as go (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py:6:0: W0611: Unused plotly.graph_objects imported as go (unused-import)
import pandas as pd
import logging
from dateutil.relativedelta import * # type: ignore
import plotly.express as px
from pages.utils.graph_utils import get_graph_time_values, color_seq
from pages.utils.graph_utils import create_heatmap_figure, get_graph_time_values, color_seq
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused get_graph_time_values imported from pages.utils.graph_utils (unused-import)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused color_seq imported from pages.utils.graph_utils (unused-import)

from queries.contributors_query import contributors_query as cnq
from queries.cntrb_per_file_query import cntrb_per_file_query as cpfq
from queries.repo_files_query import repo_files_query as rfq
Expand All @@ -16,7 +15,7 @@
from pages.utils.job_utils import nodata_graph
import pages.utils.preprocessing_utils as preproc_u
import time
from dash.exceptions import PreventUpdate

Check warning on line 18 in 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused PreventUpdate imported from dash.exceptions (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/cntrb_file_heatmap.py:18:0: W0611: Unused PreventUpdate imported from dash.exceptions (unused-import)
import app
import cache_manager.cache_facade as cf

Expand Down Expand Up @@ -332,18 +331,7 @@


def create_figure(df: pd.DataFrame):
fig = px.imshow(
df,
labels=dict(x="Time", y="Directory Entries", color="Contributors"),
color_continuous_scale=px.colors.sequential.deep,
)

fig["layout"]["yaxis"]["tickmode"] = "linear"
fig["layout"]["height"] = 700
fig["layout"]["coloraxis_colorbar_x"] = -0.15
fig["layout"]["yaxis"]["side"] = "right"

return fig
return create_heatmap_figure(df, color_label="Contributors")


def df_file_clean(df_file: pd.DataFrame, df_file_cntbs: pd.DataFrame, bot_switch):
Expand Down
20 changes: 3 additions & 17 deletions 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from dash import html, dcc, callback
import dash

Check warning on line 2 in 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused import dash (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py:2:0: W0611: Unused import dash (unused-import)
import dash_bootstrap_components as dbc
import dash_mantine_components as dmc
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go

Check warning on line 6 in 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused plotly.graph_objects imported as go (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py:6:0: W0611: Unused plotly.graph_objects imported as go (unused-import)
import pandas as pd
import logging
from dateutil.relativedelta import * # type: ignore
import plotly.express as px
from pages.utils.graph_utils import create_heatmap_figure
from queries.prs_query import prs_query as prq
from queries.pr_files_query import pr_file_query as prfq
from queries.repo_files_query import repo_files_query as rfq
from app import augur
import io

Check warning on line 15 in 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused import io (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py:15:0: W0611: Unused import io (unused-import)
from pages.utils.job_utils import nodata_graph
import time
from dash.exceptions import PreventUpdate

Check warning on line 18 in 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused PreventUpdate imported from dash.exceptions (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py:18:0: W0611: Unused PreventUpdate imported from dash.exceptions (unused-import)
import app

Check warning on line 19 in 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused import app (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/contribution_file_heatmap.py:19:0: W0611: Unused import app (unused-import)
import cache_manager.cache_facade as cf

PAGE = "codebase"
Expand Down Expand Up @@ -339,22 +339,8 @@


def create_figure(df: pd.DataFrame, graph_view):
legend_title = "PRs Opened"
if graph_view == "merged_at":
legend_title = "PRs Merged"

fig = px.imshow(
df,
labels=dict(x="Time", y="Directory Entries", color=legend_title),
color_continuous_scale=px.colors.sequential.deep,
)

fig["layout"]["yaxis"]["tickmode"] = "linear"
fig["layout"]["height"] = 700
fig["layout"]["coloraxis_colorbar_x"] = -0.15
fig["layout"]["yaxis"]["side"] = "right"

return fig
color_label = "PRs Merged" if graph_view == "merged_at" else "PRs Opened"
return create_heatmap_figure(df, color_label=color_label)


def df_file_clean(df_file: pd.DataFrame, df_file_pr: pd.DataFrame):
Expand Down
16 changes: 2 additions & 14 deletions 8Knot/pages/codebase/visualizations/reviewer_file_heatmap.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from dash import html, dcc, callback
import dash

Check warning on line 2 in 8Knot/pages/codebase/visualizations/reviewer_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused import dash (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/reviewer_file_heatmap.py:2:0: W0611: Unused import dash (unused-import)
import dash_bootstrap_components as dbc
import dash_mantine_components as dmc
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go

Check warning on line 6 in 8Knot/pages/codebase/visualizations/reviewer_file_heatmap.py

View workflow job for this annotation

GitHub Actions / python-lint

[pylint] reported by reviewdog 🐶 W0611: Unused plotly.graph_objects imported as go (unused-import) Raw Output: 8Knot/pages/codebase/visualizations/reviewer_file_heatmap.py:6:0: W0611: Unused plotly.graph_objects imported as go (unused-import)
import pandas as pd
import logging
from dateutil.relativedelta import * # type: ignore
import plotly.express as px
from pages.utils.graph_utils import get_graph_time_values, color_seq
from pages.utils.graph_utils import create_heatmap_figure, get_graph_time_values, color_seq
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused get_graph_time_values imported from pages.utils.graph_utils (unused-import)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused color_seq imported from pages.utils.graph_utils (unused-import)

from queries.contributors_query import contributors_query as cnq
from queries.cntrb_per_file_query import cntrb_per_file_query as cpfq
from queries.repo_files_query import repo_files_query as rfq
Expand Down Expand Up @@ -332,18 +331,7 @@


def create_figure(df: pd.DataFrame):
fig = px.imshow(
df,
labels=dict(x="Time", y="Directory Entries", color="Contributors"),
color_continuous_scale=px.colors.sequential.deep,
)

fig["layout"]["yaxis"]["tickmode"] = "linear"
fig["layout"]["height"] = 700
fig["layout"]["coloraxis_colorbar_x"] = -0.15
fig["layout"]["yaxis"]["side"] = "right"

return fig
return create_heatmap_figure(df, color_label="Contributors")


def df_file_clean(df_file: pd.DataFrame, df_file_cntbs: pd.DataFrame, bot_switch):
Expand Down
34 changes: 34 additions & 0 deletions 8Knot/pages/utils/graph_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import datetime as dt
import pandas as pd
import plotly.express as px

# list of graph color hex
color_seq = [
Expand All @@ -25,6 +27,38 @@
"#B54708", # Yellow 700 - dark yellow
]

# Sequential color scale for heatmaps (light -> dark blue, matches app theme)
heatmap_color_scale = [baby_blue[0], baby_blue[2], baby_blue[4], baby_blue[6], baby_blue[8]]


def create_heatmap_figure(
df: pd.DataFrame,
color_label: str,
x_label: str = "Time",
y_label: str = "Directory Entries",
):

fig = px.imshow(
df,
labels=dict(x=x_label, y=y_label, color=color_label),
color_continuous_scale=heatmap_color_scale,
)
fig.update_layout(
height=700,
font=dict(size=14),
xaxis_title=x_label,
yaxis_title=y_label,
yaxis=dict(tickmode="linear", side="right"),
coloraxis_colorbar_x=-0.15,
coloraxis=dict(
colorbar=dict(
tickfont=dict(color="white"),
title=dict(font=dict(color="white")),
)
),
)
return fig


def get_graph_time_values(interval):
"""
Expand Down
Loading