stasaking commited on
Commit
1883c90
·
verified ·
1 Parent(s): 2bfe67f

Upload start.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. start.sh +25 -0
start.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Download data from HF Bucket on startup, then start API
3
+ python -c "
4
+ from huggingface_hub import download_bucket_files, list_bucket_tree
5
+ import os
6
+
7
+ BUCKET = os.environ.get('HF_BUCKET', 'stasaking/blood-brain-benchmark')
8
+
9
+ files = list(list_bucket_tree(BUCKET))
10
+ download_list = []
11
+ for f in files:
12
+ if f.path.endswith(('.parquet', '.json')):
13
+ local_path = f'/app/data/{f.path}'
14
+ os.makedirs(os.path.dirname(local_path), exist_ok=True)
15
+ download_list.append((f.path, local_path))
16
+ elif f.path == 'hf-space/main.py':
17
+ download_list.append((f.path, '/app/main.py'))
18
+
19
+ print(f'Downloading {len(download_list)} files...')
20
+ download_bucket_files(BUCKET, files=download_list)
21
+ print('Data downloaded')
22
+ "
23
+
24
+ export BENCHMARK_DATA_DIR=/app/data
25
+ uvicorn main:app --host 0.0.0.0 --port 7860