mlabonne commited on
Commit
e815731
·
verified ·
1 Parent(s): d89fc74

add transformers_cache in /data

Browse files

Store the models in the persistent storage.

Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -70,7 +70,7 @@ def merge_models() -> None:
70
  """
71
  Use mergekit to create a merge.
72
  """
73
- command = ["mergekit-yaml", "config.yaml", "/data/merge", "--copy-tokenizer"]
74
 
75
  with open("output.log", "a") as log_file:
76
  try:
@@ -122,7 +122,7 @@ def get_name(models: list[pd.Series], username: str, version=0) -> str:
122
  get_name(models, username, version+1)
123
 
124
  return model_name
125
-
126
 
127
  def get_license(models: list[pd.Series]) -> str:
128
  license1 = models[0]["Hub License"]
@@ -359,12 +359,15 @@ def clear_data():
359
  """
360
  Clear data so the Space doesn't crash...
361
  """
362
- dir_path = "/data/merge"
363
- if os.path.exists(dir_path) and os.path.isdir(dir_path):
364
- shutil.rmtree(dir_path)
365
- print(f"The directory '{dir_path}' has been removed successfully.")
366
- else:
367
- print(f"The directory '{dir_path}' does not exist.")
 
 
 
368
 
369
 
370
  def get_size(start_path):
 
70
  """
71
  Use mergekit to create a merge.
72
  """
73
+ command = ["mergekit-yaml", "config.yaml", "/data/merge", "--copy-tokenizer", "--transformers_cache", "/data"]
74
 
75
  with open("output.log", "a") as log_file:
76
  try:
 
122
  get_name(models, username, version+1)
123
 
124
  return model_name
125
+
126
 
127
  def get_license(models: list[pd.Series]) -> str:
128
  license1 = models[0]["Hub License"]
 
359
  """
360
  Clear data so the Space doesn't crash...
361
  """
362
+ dir_path = "/data"
363
+ try:
364
+ with os.scandir(dir_path) as entries:
365
+ for entry in entries:
366
+ if entry.is_file():
367
+ os.unlink(entry.path)
368
+ print("All files deleted successfully.")
369
+ except OSError:
370
+ print("Error occurred while deleting files.")
371
 
372
 
373
  def get_size(start_path):