wintergw commited on
Commit
b945165
·
verified ·
1 Parent(s): 5328568

clean up. this version worked.

Browse files
Files changed (1) hide show
  1. app.py +5 -60
app.py CHANGED
@@ -17,7 +17,6 @@ HF_TOKEN = os.environ.get("HF_TOKEN") #get HF_TOKEN
17
  login(token=HF_TOKEN)
18
 
19
 
20
-
21
  #USER_NAME = os.getenv("USER_NAME", "").strip().strip('"')
22
  #PRIVATE_SPACE_NAME = os.getenv("PRIVATE_SPACE_NAME", "").strip().strip('"')
23
 
@@ -26,38 +25,6 @@ login(token=HF_TOKEN)
26
  REPO_ID ="textbook/textbook_coop"
27
  REPO_TYPE = "space"
28
 
29
- # def setup_cache_directory():
30
- # """Set up and return cache directory for private space files"""
31
- # cache_dir = Path("private_space_cache")
32
- # cache_dir.mkdir(exist_ok=True)
33
- # return cache_dir
34
-
35
- # def download_private_assets(cache_dir):
36
- # """Download necessary files from private space"""
37
- # try:
38
- # snapshot_download(
39
- # repo_id=REPO_ID,
40
- # repo_type=REPO_TYPE,
41
- # local_dir=cache_dir,
42
- # )
43
- # return True
44
- # except Exception as e:
45
- # print(f"Error downloading private assets: {str(e)}")
46
- # return False
47
-
48
- # # Setup cache directory and download assets
49
- # cache_dir = setup_cache_directory()
50
- # download_private_assets(cache_dir)
51
-
52
- #Download the entire space (optional, if needed)
53
- # repo_dir = snapshot_download(
54
- # repo_id=REPO_ID,
55
- # repo_type=REPO_TYPE,
56
- # token=HF_TOKEN,
57
- # cache_dir="private_space_cache"
58
- # )
59
-
60
- # # Add repo directory to sys.path so Python can find modules inside it
61
  # sys.path.append(repo_dir)
62
 
63
  # Download the entire space, including the fine-tuned model folder
@@ -69,36 +36,15 @@ repo_dir = snapshot_download(
69
  force_download=True # Forces redownload
70
  )
71
 
72
- #print("Files in Model Directory:", os.listdir(repo_dir))
73
- # Step 2: Change the working directory to the downloaded snapshot directory
74
- # This ensures that all relative paths inside your private space code are correctly resolved.
75
- os.chdir(repo_dir)
76
 
77
- #print("Files in Model Directory:", os.listdir(repo_dir))
 
 
78
 
79
- # Add repo directory to sys.path
80
  sys.path.append(repo_dir)
81
 
82
 
83
-
84
-
85
-
86
-
87
- # Load the base model
88
- # base_model = AutoModelForCausalLM.from_pretrained(
89
- # "meta-llama/Meta-Llama-3-8B",
90
- # token=HF_TOKEN_LLAMA
91
- # )
92
-
93
- # # Load fine-tuned adapter (PEFT)
94
- # fine_tuned_model = PeftModel.from_pretrained(base_model, fine_tuned_model_path)
95
-
96
- # # Load tokenizer
97
- # tokenizer = AutoTokenizer.from_pretrained(fine_tuned_model_path)
98
-
99
- # print("Fine-tuned model loaded successfully!")
100
-
101
-
102
  # Download specific files (if snapshot_download wasn't used)
103
  app_path = hf_hub_download(
104
  repo_id=REPO_ID,
@@ -112,5 +58,4 @@ app_module = importlib.util.module_from_spec(spec_app)
112
  spec_app.loader.exec_module(app_module)
113
 
114
  # Now you can use functions from utils_module
115
- result = app_module.main()
116
-
 
17
  login(token=HF_TOKEN)
18
 
19
 
 
20
  #USER_NAME = os.getenv("USER_NAME", "").strip().strip('"')
21
  #PRIVATE_SPACE_NAME = os.getenv("PRIVATE_SPACE_NAME", "").strip().strip('"')
22
 
 
25
  REPO_ID ="textbook/textbook_coop"
26
  REPO_TYPE = "space"
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  # sys.path.append(repo_dir)
29
 
30
  # Download the entire space, including the fine-tuned model folder
 
36
  force_download=True # Forces redownload
37
  )
38
 
 
 
 
 
39
 
40
+ # Change the working directory to the downloaded snapshot directory
41
+ # This step is very imporptant
42
+ os.chdir(repo_dir)
43
 
44
+ # # Add repo directory to sys.path so Python can find modules inside it
45
  sys.path.append(repo_dir)
46
 
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  # Download specific files (if snapshot_download wasn't used)
49
  app_path = hf_hub_download(
50
  repo_id=REPO_ID,
 
58
  spec_app.loader.exec_module(app_module)
59
 
60
  # Now you can use functions from utils_module
61
+ result = app_module.main()