-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pie chart with detailed breakdown (#11)
- Loading branch information
Showing
10 changed files
with
160 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
# Never enforce `E501` (line length violations). | ||
ignore = ["E501"] | ||
lint.ignore = ["E501"] |
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,86 @@ | ||
from datetime import datetime | ||
from typing import List | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
import matplotlib.pyplot as plt | ||
import argparse | ||
|
||
from data_filter import DataFilter | ||
from utilities import count_by_language_and_file_extension | ||
|
||
from github_client import GithubClient | ||
|
||
|
||
class App: | ||
def __init__(self, languages: List[str], path_prefix: str, keyword: str): | ||
self.client = GithubClient() | ||
self.data_filter = DataFilter(languages=languages, | ||
path_prefix=path_prefix, keyword=keyword) | ||
|
||
def get_commit_by_date(self, repository, date): | ||
return self.client.get_most_recent_commit(repository, date, "main") | ||
|
||
def get_repository_by_commit(self, repository, commit): | ||
repo_data = self.client.get_repository_at_commit(repository, commit) | ||
repo_data = self.data_filter.parse_data(repo_data) | ||
|
||
return repo_data | ||
|
||
|
||
def main(args): | ||
app = App( | ||
languages=[args.language], | ||
path_prefix="instrumentation/", | ||
keyword="test" | ||
) | ||
|
||
today = datetime.now().date().strftime("%Y-%m-%dT%H:%M:%SZ") | ||
|
||
commit = app.get_commit_by_date(date=today, repository=args.repo) | ||
repo_files = app.get_repository_by_commit( | ||
repository=args.repo, | ||
commit=commit | ||
) | ||
count = count_by_language_and_file_extension(files=repo_files["files"], | ||
languages=[args.language]) | ||
|
||
df = pd.DataFrame(list(count.items()), columns=['Key', 'Value']) | ||
df = df.sort_values(by='Value', key=lambda col: col.astype(int), ascending=False) | ||
|
||
sns.set_theme() | ||
colors = sns.color_palette('pastel')[0:len(df)] | ||
|
||
# Create a pie chart | ||
explode = [0.05] * len(df) # this will "explode" each slice from the pie | ||
df.set_index('Key')['Value'].plot.pie(autopct='%1.0f%%', colors=colors, | ||
explode=explode) | ||
|
||
plt.title(f'Remaining {args.language} files by Instrumentation') | ||
plt.ylabel('') | ||
|
||
print(df.to_markdown(index=False)) | ||
print(f"| Total | {df['Value'].sum()} |") | ||
|
||
if args.output is not None: | ||
plt.savefig(args.output) | ||
else: | ||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
description='Show Pie chart of file count in test folders') | ||
parser.add_argument("-r", "--repo", | ||
help="Repository name. " | ||
"ex: open-telemetry/opentelemetry-java-instrumentation", | ||
required=True) | ||
parser.add_argument("-l", "--language", | ||
help="Language to analyze" | ||
"ex: groovy", | ||
required=True) | ||
parser.add_argument("-o", "--output", | ||
help="File name to output graph to (leave blank and no file is generated)." | ||
"ex: pie-chart-counts.png") | ||
arguments = parser.parse_args() | ||
main(arguments) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ matplotlib | |
argparse | ||
pytest | ||
pytest-cov | ||
ruff | ||
ruff==0.5.7 | ||
seaborn | ||
pandas | ||
pandas | ||
tabulate |
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