radames commited on
Commit
3b201fc
·
1 Parent(s): ce474ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
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
- dir = Path(DATA_PATH)
11
- files = [str(f) for f in dir.glob("**/*") if f.is_file()]
12
- usage = sum([f.stat().st_size for f in dir.glob("**/*") if f.is_file()])
13
- return files, f"{usage/(1024.0 ** 3):.3f}GB"
14
-
15
- with gr.Blocks() as app:
16
- with gr.Row():
17
- with gr.Column():
18
- btn = gr.Button("Run")
19
- with gr.Column():
20
- files = gr.Files(label="Files")
21
- storage = gr.Text(label="Total Usage")
22
- btn.click(get_storage, None, [files, storage])
23
- app.launch()
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)])