Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import subprocess
|
|
3 |
from typing import Union
|
4 |
from huggingface_hub import whoami
|
5 |
from huggingface_hub import HfApi
|
|
|
6 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
7 |
|
8 |
import tempfile
|
@@ -284,23 +285,13 @@ def start_training(
|
|
284 |
except Exception as e:
|
285 |
print(f"Failed to add HF_TOKEN secret to new space: {e}")
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
s = os.path.join(dataset_folder, item)
|
295 |
-
d = os.path.join(clone_dir, item)
|
296 |
-
if os.path.isdir(s):
|
297 |
-
shutil.copytree(s, d, dirs_exist_ok=True)
|
298 |
-
else:
|
299 |
-
shutil.copy2(s, d)
|
300 |
-
|
301 |
-
repo.index.add(["."])
|
302 |
-
repo.index.commit("Push training files from controller")
|
303 |
-
repo.remote().push()
|
304 |
|
305 |
cmd = f"autotrain spacerunner --project-name {slugged_lora_name} --script-path {dataset_folder}"
|
306 |
cmd += f" --username {profile.username} --token {hf_token} --backend spaces-l4x1"
|
|
|
3 |
from typing import Union
|
4 |
from huggingface_hub import whoami
|
5 |
from huggingface_hub import HfApi
|
6 |
+
from huggingface_hub import upload_folder
|
7 |
is_spaces = True if os.environ.get("SPACE_ID") else False
|
8 |
|
9 |
import tempfile
|
|
|
285 |
except Exception as e:
|
286 |
print(f"Failed to add HF_TOKEN secret to new space: {e}")
|
287 |
|
288 |
+
upload_folder(
|
289 |
+
folder_path=dataset_folder,
|
290 |
+
repo_id=new_space_id,
|
291 |
+
repo_type="space",
|
292 |
+
token=hf_token,
|
293 |
+
commit_message="Pushing training files from controller"
|
294 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
cmd = f"autotrain spacerunner --project-name {slugged_lora_name} --script-path {dataset_folder}"
|
297 |
cmd += f" --username {profile.username} --token {hf_token} --backend spaces-l4x1"
|