Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
3 |
|
4 |
-
# Function to fetch repository details from GitHub
|
5 |
def analyze_github_repo(repo_url):
|
6 |
# Extract the username and repo name from the GitHub URL
|
7 |
if "github.com" not in repo_url:
|
@@ -36,26 +37,39 @@ def analyze_github_repo(repo_url):
|
|
36 |
contributors_data = requests.get(contributors_url).json()
|
37 |
contributors = len(contributors_data)
|
38 |
|
39 |
-
#
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
# Gradio interface for the tool
|
51 |
iface = gr.Interface(
|
52 |
fn=analyze_github_repo,
|
53 |
inputs=gr.Textbox(label="Enter GitHub Repository URL", placeholder="https://github.com/username/repository"),
|
54 |
-
outputs=gr.
|
55 |
title="GitHub Repository Analysis Tool",
|
56 |
-
description="Enter a GitHub repository URL to get basic analytics including stars, forks, issues, and contributors."
|
57 |
)
|
58 |
|
59 |
# Launch the app
|
60 |
iface.launch()
|
61 |
|
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
|
5 |
+
# Function to fetch repository details from GitHub and generate a visualization
|
6 |
def analyze_github_repo(repo_url):
|
7 |
# Extract the username and repo name from the GitHub URL
|
8 |
if "github.com" not in repo_url:
|
|
|
37 |
contributors_data = requests.get(contributors_url).json()
|
38 |
contributors = len(contributors_data)
|
39 |
|
40 |
+
# Data to plot
|
41 |
+
metrics = {
|
42 |
+
'Stars': stars,
|
43 |
+
'Forks': forks,
|
44 |
+
'Open Issues': issues,
|
45 |
+
'Contributors': contributors
|
46 |
+
}
|
47 |
+
|
48 |
+
# Create the bar plot
|
49 |
+
fig, ax = plt.subplots()
|
50 |
+
ax.bar(metrics.keys(), metrics.values(), color=['blue', 'green', 'red', 'orange'])
|
51 |
+
|
52 |
+
ax.set_xlabel('Metrics')
|
53 |
+
ax.set_ylabel('Count')
|
54 |
+
ax.set_title(f"GitHub Repository Analysis: {repo_url}")
|
55 |
+
|
56 |
+
# Save the plot as an image
|
57 |
+
plt.tight_layout()
|
58 |
+
plt.savefig("/mnt/data/github_analysis.png")
|
59 |
+
plt.close()
|
60 |
+
|
61 |
+
return "/mnt/data/github_analysis.png"
|
62 |
|
63 |
# Gradio interface for the tool
|
64 |
iface = gr.Interface(
|
65 |
fn=analyze_github_repo,
|
66 |
inputs=gr.Textbox(label="Enter GitHub Repository URL", placeholder="https://github.com/username/repository"),
|
67 |
+
outputs=gr.Image(label="Repository Analysis Visualization"),
|
68 |
title="GitHub Repository Analysis Tool",
|
69 |
+
description="Enter a GitHub repository URL to get basic analytics including stars, forks, issues, and contributors, along with a visual chart."
|
70 |
)
|
71 |
|
72 |
# Launch the app
|
73 |
iface.launch()
|
74 |
|
75 |
+
|