bartowski commited on
Commit
7fa96f1
1 Parent(s): 89e3ff3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  import subprocess
3
  import os
4
-
5
  from huggingface_hub import HfApi, snapshot_download
6
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
7
 
@@ -41,6 +41,8 @@ def process_model(
41
 
42
  FILE_NAME = file_path.split("/")[-1]
43
 
 
 
44
  api.snapshot_download(
45
  repo_id=model_id,
46
  allow_patterns=FILE_PATH,
@@ -52,13 +54,16 @@ def process_model(
52
  subprocess.run(metadata_update, shell=True)
53
  print(f"Model metadata {key} updated to {value} successully!")
54
 
 
55
  # Upload gguf files
56
  api.upload_folder(
57
  folder_path=MODEL_NAME,
 
58
  repo_id=model_id,
59
  allow_patterns=["*.gguf"],
60
  )
61
  print("Uploaded successfully!")
 
62
 
63
  return f"Processing complete"
64
  except Exception as e:
 
1
  import gradio as gr
2
  import subprocess
3
  import os
4
+ import shutil
5
  from huggingface_hub import HfApi, snapshot_download
6
  from gradio_huggingfacehub_search import HuggingfaceHubSearch
7
 
 
41
 
42
  FILE_NAME = file_path.split("/")[-1]
43
 
44
+ print("Starting download")
45
+
46
  api.snapshot_download(
47
  repo_id=model_id,
48
  allow_patterns=FILE_PATH,
 
54
  subprocess.run(metadata_update, shell=True)
55
  print(f"Model metadata {key} updated to {value} successully!")
56
 
57
+ print(f"Reuploading file")
58
  # Upload gguf files
59
  api.upload_folder(
60
  folder_path=MODEL_NAME,
61
+ commit_message=f"Updating {FILE_NAME} metadata {key} to {value}",
62
  repo_id=model_id,
63
  allow_patterns=["*.gguf"],
64
  )
65
  print("Uploaded successfully!")
66
+ shutil.rmtree(f"{MODEL_NAME}/")
67
 
68
  return f"Processing complete"
69
  except Exception as e: