Spaces:
Runtime error
Runtime error
osanseviero
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
-
import requests
|
2 |
import gradio as gr
|
|
|
|
|
3 |
from huggingface_hub import list_models, list_datasets, list_spaces
|
|
|
4 |
|
5 |
# Helper function to get the total storage for models, datasets, or spaces
|
6 |
def get_total_storage(namespace, resource_type, oauth_token: gr.OAuthToken):
|
@@ -25,7 +27,7 @@ def get_total_storage(namespace, resource_type, oauth_token: gr.OAuthToken):
|
|
25 |
|
26 |
return total_storage, len(resources)
|
27 |
|
28 |
-
def get_report(namespace, oauth_token:
|
29 |
# Fetch storage and counts for models, datasets, and spaces
|
30 |
model_storage, n_models = get_total_storage(namespace, "model", oauth_token)
|
31 |
dataset_storage, n_datasets = get_total_storage(namespace, "dataset", oauth_token)
|
@@ -52,11 +54,6 @@ def get_report(namespace, oauth_token: gr.OAuthToken):
|
|
52 |
|
53 |
return report
|
54 |
|
55 |
-
# Gradio interface
|
56 |
-
def gradio_interface(namespace, oauth_token: gr.OAuthToken):
|
57 |
-
report = get_report(api_token, author)
|
58 |
-
return report
|
59 |
-
|
60 |
css = """
|
61 |
.main_ui_logged_out{opacity: 0.3; pointer-events: none}
|
62 |
"""
|
@@ -71,7 +68,7 @@ with gr.Blocks(css=css) as demo:
|
|
71 |
|
72 |
# Button to trigger the report generation
|
73 |
report_button = gr.Button("Generate Report")
|
74 |
-
report_button.click(fn=
|
75 |
|
76 |
# Launch the Gradio app
|
77 |
demo.launch()
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
from huggingface_hub import list_models, list_datasets, list_spaces
|
5 |
+
from typing import Union
|
6 |
|
7 |
# Helper function to get the total storage for models, datasets, or spaces
|
8 |
def get_total_storage(namespace, resource_type, oauth_token: gr.OAuthToken):
|
|
|
27 |
|
28 |
return total_storage, len(resources)
|
29 |
|
30 |
+
def get_report(namespace, oauth_token: Union[OAuthToken, None]):
|
31 |
# Fetch storage and counts for models, datasets, and spaces
|
32 |
model_storage, n_models = get_total_storage(namespace, "model", oauth_token)
|
33 |
dataset_storage, n_datasets = get_total_storage(namespace, "dataset", oauth_token)
|
|
|
54 |
|
55 |
return report
|
56 |
|
|
|
|
|
|
|
|
|
|
|
57 |
css = """
|
58 |
.main_ui_logged_out{opacity: 0.3; pointer-events: none}
|
59 |
"""
|
|
|
68 |
|
69 |
# Button to trigger the report generation
|
70 |
report_button = gr.Button("Generate Report")
|
71 |
+
report_button.click(fn=get_report, inputs=namespace, outputs=output)
|
72 |
|
73 |
# Launch the Gradio app
|
74 |
demo.launch()
|