mr2along commited on
Commit
67c5bb4
·
verified ·
1 Parent(s): a54f200

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -13,18 +13,16 @@ if not HF_TOKEN:
13
  print("⚠️ Không tìm thấy biến môi trường 'MAGIC'")
14
  login(HF_TOKEN)
15
  # --- Upload function ---
16
- def upload_to_huggingface(filepath):
17
- try:
18
-
19
- filename = os.path.basename(filepath)
20
- upload_file(path_or_fileobj=filepath,
21
- path_in_repo=filename,
22
- repo_id=REPO_ID,
23
- repo_type="dataset")
24
- return f"https://huggingface.co/datasets/{REPO_ID}/blob/main/{filename}"
25
- except Exception as e:
26
- return f"❌ Lỗi upload: {str(e)}"
27
-
28
  def run_scripts(target, source):
29
  outputfile=[]
30
  for target_file in target :
@@ -36,6 +34,7 @@ def run_scripts(target, source):
36
  subprocess.run(cmd1)
37
  outputfile.append(output_path1)
38
  print(output_path1)
 
39
  return outputfile
40
 
41
  iface = gr.Interface(
 
13
  print("⚠️ Không tìm thấy biến môi trường 'MAGIC'")
14
  login(HF_TOKEN)
15
  # --- Upload function ---
16
+ def upload_to_hf(filepath):
17
+ filename = os.path.basename(filepath)
18
+ upload_file(
19
+ path_or_fileobj=filepath,
20
+ path_in_repo=filename,
21
+ repo_id=REPO_ID,
22
+ repo_type="dataset"
23
+ )
24
+ return f"https://huggingface.co/datasets/{REPO_ID}/blob/main/{filename}"
25
+
 
 
26
  def run_scripts(target, source):
27
  outputfile=[]
28
  for target_file in target :
 
34
  subprocess.run(cmd1)
35
  outputfile.append(output_path1)
36
  print(output_path1)
37
+ upload_to_hf(output_path1)
38
  return outputfile
39
 
40
  iface = gr.Interface(