Spaces:
Sleeping
Sleeping
File size: 1,417 Bytes
d103a0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | from huggingface_hub import HfApi
import os
import shutil
api = HfApi()
temp_dir = "./temp_upload"
if os.path.exists(temp_dir):
shutil.rmtree(temp_dir)
os.makedirs(temp_dir)
for root, dirs, files in os.walk("."):
skip_dirs = [
".git",
"__pycache__",
"hf_space",
".cache",
"openenvhackathon",
".pytest_cache",
"temp_upload",
"env\\__pycache__",
"tests\\__pycache__",
"baseline\\__pycache__",
"server\\__pycache__",
]
if any(s in root for s in skip_dirs):
continue
temp_root = root.replace(".\\", temp_dir + "\\")
os.makedirs(temp_root, exist_ok=True)
for f in files:
if (
not f.endswith(".pyc")
and not f.endswith(".lock")
and not f.startswith(".")
and not f.endswith(".metadata")
):
src = os.path.join(root, f)
dst = os.path.join(temp_root, f)
try:
shutil.copy2(src, dst)
except Exception as e:
print(f"Skipped {src}: {e}")
print("Prepared files")
api.upload_folder(
folder_path=temp_dir,
repo_id="YashashMathur/sql_data_analyst",
repo_type="space",
commit_message="SQL Data Analyst OpenEnv - Initial commit",
)
print("SUCCESS!")
print("https://huggingface.co/spaces/YashashMathur/sql_data_analyst")
shutil.rmtree(temp_dir)
|