web-crawl-2026 / source /upload_source_hf.py
OpenTransformer's picture
Upload source/upload_source_hf.py with huggingface_hub
732843e verified
from huggingface_hub import HfApi
import glob, os
api = HfApi()
REPO = "OpenTransformer/web-crawl-2026"
files = []
for ext in ["*.py", "*.go", "*.rs", "*.sh", "*.mod", "*.sum", "*.toml"]:
files.extend(glob.glob(f"/workspace/{ext}"))
files.extend(glob.glob("/workspace/rust_crawler/src/*.rs"))
files.append("/workspace/rust_crawler/Cargo.toml")
files = [f for f in files if os.path.isfile(f)]
print(f"Uploading {len(files)} source files to HF...")
for f in files:
rel = os.path.relpath(f, "/workspace")
hf_path = f"source/{rel}"
try:
api.upload_file(path_or_fileobj=f, path_in_repo=hf_path, repo_id=REPO, repo_type="dataset")
print(f" OK: {hf_path}")
except Exception as e:
print(f" FAIL {hf_path}: {e}")
print("SOURCE UPLOAD DONE")