making things slightly better when repo is gated
Browse files
app.py
CHANGED
@@ -43,9 +43,12 @@ def repo_size(r_type, r_id):
|
|
43 |
timeout=1000,
|
44 |
)
|
45 |
response = response.json()
|
|
|
46 |
except Exception:
|
47 |
response = {}
|
48 |
-
|
|
|
|
|
49 |
size = response.get("size")
|
50 |
if size is not None:
|
51 |
repo_sizes[branch.name] = size
|
@@ -71,10 +74,20 @@ def get_repo_info(r_type, r_id):
|
|
71 |
.T.reset_index(names="ext")
|
72 |
.sort_values(by="size", ascending=False)
|
73 |
)
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
rf_sizes_df["formatted_size"] = rf_sizes_df["size"].apply(format_repo_size)
|
77 |
-
r_sizes_df.columns = ["Branch", "bytes", "Size"]
|
78 |
rf_sizes_df.columns = ["Extension", "bytes", "Count", "Size"]
|
79 |
rf_sizes_plot = px.pie(
|
80 |
rf_sizes_df,
|
@@ -91,7 +104,7 @@ def get_repo_info(r_type, r_id):
|
|
91 |
visible=True,
|
92 |
),
|
93 |
gr.Plot(rf_sizes_plot, visible=True),
|
94 |
-
|
95 |
)
|
96 |
|
97 |
|
|
|
43 |
timeout=1000,
|
44 |
)
|
45 |
response = response.json()
|
46 |
+
# get the status code
|
47 |
except Exception:
|
48 |
response = {}
|
49 |
+
if response.get("error") and "restricted" in response.get("error"):
|
50 |
+
gr.Warning(f"Branch information for {r_id} not available.")
|
51 |
+
return {}
|
52 |
size = response.get("size")
|
53 |
if size is not None:
|
54 |
repo_sizes[branch.name] = size
|
|
|
74 |
.T.reset_index(names="ext")
|
75 |
.sort_values(by="size", ascending=False)
|
76 |
)
|
77 |
+
# check if repo_sizes is just {}
|
78 |
+
if not repo_sizes:
|
79 |
+
r_sizes_component = gr.Dataframe(visible=False)
|
80 |
+
else:
|
81 |
+
r_sizes_df = pd.DataFrame(repo_sizes, index=["size"]).T.reset_index(
|
82 |
+
names="branch"
|
83 |
+
)
|
84 |
+
r_sizes_df["formatted_size"] = r_sizes_df["size"].apply(format_repo_size)
|
85 |
+
r_sizes_df.columns = ["Branch", "bytes", "Size"]
|
86 |
+
r_sizes_component = gr.Dataframe(
|
87 |
+
value=r_sizes_df[["Branch", "Size"]], visible=True
|
88 |
+
)
|
89 |
+
|
90 |
rf_sizes_df["formatted_size"] = rf_sizes_df["size"].apply(format_repo_size)
|
|
|
91 |
rf_sizes_df.columns = ["Extension", "bytes", "Count", "Size"]
|
92 |
rf_sizes_plot = px.pie(
|
93 |
rf_sizes_df,
|
|
|
104 |
visible=True,
|
105 |
),
|
106 |
gr.Plot(rf_sizes_plot, visible=True),
|
107 |
+
r_sizes_component,
|
108 |
)
|
109 |
|
110 |
|