Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,22 +4,33 @@ from huggingface_hub import snapshot_download
|
|
| 4 |
|
| 5 |
snapshot_download("tiiuae/falcon-7b")
|
| 6 |
|
| 7 |
-
DATA_PATH = "/data"
|
| 8 |
|
| 9 |
def get_storage():
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
snapshot_download("tiiuae/falcon-7b")
|
| 6 |
|
| 7 |
+
DATA_PATH = Path("/data")
|
| 8 |
|
| 9 |
def get_storage():
|
| 10 |
+
files = [
|
| 11 |
+
{
|
| 12 |
+
"orig_name": file.name,
|
| 13 |
+
"name": file.resolve(),
|
| 14 |
+
"size": file.stat().st_size,
|
| 15 |
+
"data": None,
|
| 16 |
+
"is_file": True,
|
| 17 |
+
}
|
| 18 |
+
for file in DATA_PATH.glob("**/*")
|
| 19 |
+
if file.is_file()
|
| 20 |
+
]
|
| 21 |
+
usage = sum([f['size'] for f in files])
|
| 22 |
+
|
| 23 |
+
return files, f"{usage/(1024.0 ** 3):.3f}GB"
|
| 24 |
|
| 25 |
|
| 26 |
+
with gr.Blocks() as app:
|
| 27 |
+
with gr.Row():
|
| 28 |
+
with gr.Column():
|
| 29 |
+
btn = gr.Button("Run")
|
| 30 |
+
with gr.Column():
|
| 31 |
+
files = gr.Files(label="Files")
|
| 32 |
+
storage = gr.Text(label="Total Usage")
|
| 33 |
+
btn.click(get_storage, inputs=None, outputs=[files, storage], postprocess=False)
|
| 34 |
+
|
| 35 |
+
# Files that you explicitly allow on allowed_paths
|
| 36 |
+
app.launch(allowed_paths=[str(DATA_PATH)])
|