wintergw commited on
Commit
f40d7c0
·
verified ·
1 Parent(s): a2ca81f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,15 +1,40 @@
1
- from huggingface_hub import hf_hub_download , snapshot_download
2
  import pandas as pd
3
  import importlib
4
  import importlib.util
5
  import streamlit as st
6
  import sys
7
  import os
 
8
 
9
  # Define repo details
10
  REPO_ID = "wintergw/assignment_opt_gurobi"
11
  REPO_TYPE = "space"
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # Download specific files (if snapshot_download wasn't used)
15
  app_path = hf_hub_download(
 
1
+ from huggingface_hub import hf_hub_download, snapshot_download
2
  import pandas as pd
3
  import importlib
4
  import importlib.util
5
  import streamlit as st
6
  import sys
7
  import os
8
+ from pathlib import Path
9
 
10
  # Define repo details
11
  REPO_ID = "wintergw/assignment_opt_gurobi"
12
  REPO_TYPE = "space"
13
 
14
+ def setup_cache_directory():
15
+ """Set up and return cache directory for private space files"""
16
+ cache_dir = Path("private_space_cache")
17
+ cache_dir.mkdir(exist_ok=True)
18
+ return cache_dir
19
+
20
+ def download_private_assets(cache_dir):
21
+ """Download necessary files from private space"""
22
+ try:
23
+ snapshot_download(
24
+ repo_id=REPO_ID,
25
+ repo_type=REPO_TYPE,
26
+ local_dir=cache_dir,
27
+ )
28
+ return True
29
+ except Exception as e:
30
+ print(f"Error downloading private assets: {str(e)}")
31
+ return False
32
+
33
+ # Setup cache directory and download assets
34
+ cache_dir = setup_cache_directory()
35
+ download_private_assets(cache_dir)
36
+
37
+
38
 
39
  # Download specific files (if snapshot_download wasn't used)
40
  app_path = hf_hub_download(