Spaces:
Sleeping
Sleeping
Upload upload_to_hf.py
Browse files- upload_to_hf.py +10 -10
upload_to_hf.py
CHANGED
|
@@ -12,7 +12,8 @@ api = HfApi(token=HF_TOKEN)
|
|
| 12 |
def get_files_to_upload():
|
| 13 |
files = []
|
| 14 |
ignore_dirs = {".git", "__pycache__", ".venv", "venv", "env", "node_modules", ".pytest_cache"}
|
| 15 |
-
ignore_files = {".env"}
|
|
|
|
| 16 |
|
| 17 |
for root, dirs, files_list in os.walk("."):
|
| 18 |
# Modify dirs in-place to exclude ignored directories
|
|
@@ -21,7 +22,7 @@ def get_files_to_upload():
|
|
| 21 |
dirs.remove(d)
|
| 22 |
|
| 23 |
for f in files_list:
|
| 24 |
-
if f in ignore_files:
|
| 25 |
continue
|
| 26 |
|
| 27 |
file_path = os.path.join(root, f)
|
|
@@ -49,14 +50,13 @@ def upload():
|
|
| 49 |
print(f"[*] Uploading files...")
|
| 50 |
for local_path, repo_path in files:
|
| 51 |
print(f" Uploading: {local_path} -> {repo_path}")
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
)
|
| 60 |
|
| 61 |
print("\n" + "="*50)
|
| 62 |
print(f"[OK] SUCCESS!")
|
|
|
|
| 12 |
def get_files_to_upload():
|
| 13 |
files = []
|
| 14 |
ignore_dirs = {".git", "__pycache__", ".venv", "venv", "env", "node_modules", ".pytest_cache"}
|
| 15 |
+
ignore_files = {".env", "vortex.db"}
|
| 16 |
+
ignore_extensions = {".db", ".sqlite", ".sqlite3", ".pyc"}
|
| 17 |
|
| 18 |
for root, dirs, files_list in os.walk("."):
|
| 19 |
# Modify dirs in-place to exclude ignored directories
|
|
|
|
| 22 |
dirs.remove(d)
|
| 23 |
|
| 24 |
for f in files_list:
|
| 25 |
+
if f in ignore_files or any(f.endswith(ext) for ext in ignore_extensions):
|
| 26 |
continue
|
| 27 |
|
| 28 |
file_path = os.path.join(root, f)
|
|
|
|
| 50 |
print(f"[*] Uploading files...")
|
| 51 |
for local_path, repo_path in files:
|
| 52 |
print(f" Uploading: {local_path} -> {repo_path}")
|
| 53 |
+
api.upload_file(
|
| 54 |
+
path_or_fileobj=local_path,
|
| 55 |
+
path_in_repo=repo_path,
|
| 56 |
+
repo_id=REPO_ID,
|
| 57 |
+
repo_type="space",
|
| 58 |
+
commit_message=f"Upload {repo_path}",
|
| 59 |
+
)
|
|
|
|
| 60 |
|
| 61 |
print("\n" + "="*50)
|
| 62 |
print(f"[OK] SUCCESS!")
|