Skip to content

Commit

Permalink
add helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
feststelltaste committed Mar 15, 2024
1 parent 17b576e commit da952fa
Show file tree
Hide file tree
Showing 3 changed files with 253 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Define the repository directory
REPO_DIR="../../angular/"

# Move to the repository directory
cd "$REPO_DIR" || exit

# Print CSV header as first line
echo "sha,timestamp,action,file_path"

# create variables for the repeated information per file
commit_hash=""
commit_timestamp=""

# Git log all the things and iterate through each commit
git log --pretty=format:"INFO,%H,%at" --date=format:"%Y-%m-%d %H:%M:%S" --name-status --diff-filter=ADR -- '*.ts' '*.js' | while read -r line; do

if [[ "$line" =~ "INFO" ]]; then
commit_hash=$(echo "$line" | cut -d ',' -f 2)
commit_timestamp=$(echo "$line" | cut -d ',' -f 3)
fi

# Check if the line contains actions for add and delete
if [[ "$line" =~ ^[AD] ]]; then

action=$(echo "$line" | cut -d$'\t' -f 1)
file_path=$(echo "$line" | cut -d$'\t' -f 2)

# Print commit information in CSV format
echo "$commit_hash,$commit_timestamp,$action,$file_path"
fi

# Treat rename as add and delete action
if [[ "$line" =~ ^[R] ]]; then

action="D"
file_path=$(echo "$line" | cut -d$'\t' -f 2)

echo "$commit_hash,$commit_timestamp,$action,$file_path"

action="A"
file_path=$(echo "$line" | cut -d$'\t' -f 3)

echo "$commit_hash,$commit_timestamp,$action,$file_path"
fi
done
58 changes: 58 additions & 0 deletions demos/20240315_BOBKonf_2024/hotspotsviz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pandas as pd
from matplotlib.colors import rgb2hex
from matplotlib import cm
import json
import os
from IPython.core.display import HTML



# preprocess data for plotting
def create_plot_data(df, color_column_name, size_column_name, seperator):
plot_data = pd.DataFrame(index=df.index)
plot_data['value_for_color'] = df[color_column_name]
plot_data['ratio_for_color'] = plot_data['value_for_color'] / plot_data['value_for_color'].max()
plot_data['color'] = plot_data['ratio_for_color'].apply(lambda x : rgb2hex(cm.coolwarm(x)))
plot_data['size'] = df[size_column_name]
plot_data[['path', 'name']] = df.index.str.rsplit(seperator, n=1).to_list()
plot_data['path_list'] = plot_data['path'].str.split(seperator)
return plot_data


# convert to d3 data format
def create_flare_json(df):

json_data = {'name': 'flare', 'children': []}

for _, series in df.iterrows():
hierarchical_data = series['path_list']

children = json_data['children']
for part in hierarchical_data:
entry = next((child for child in children if child.get('name', '') == part), None)
if not entry:
entry = {'name': part, 'children': []}
children.append(entry)
children = entry['children']

children.append({
'name': f"{series['name']} ({series['size']} [{series['value_for_color']}])",
'size': series['size'],
'color': series['color']
})

return json_data


# Put data into template
def create(hotspots, color_column_name, size_column_name, separator):
json_data = create_flare_json(create_plot_data(hotspots, color_column_name, size_column_name,separator))

with open("vis/template_circle_pack_hierarchy_chart_d3_inline.html") as html_template:
html = html_template.read().replace("###JSON###", str(json_data))

os.makedirs("output", exist_ok=True)
with open(f'output/hotspots.html', mode='w') as html_out:
html_out.write(html)

return HTML('<a href="output/hotspots.html" target="_blank">Production Coverage Hotspots</a>')

Large diffs are not rendered by default.

0 comments on commit da952fa

Please sign in to comment.