Download push_simple.py from whoisscaramouchee/textparser-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/whoisscaramouchee/textparser-backend/resolve/main/push_simple.py
- Command line
-
hf download hf://spaces/whoisscaramouchee/textparser-backend/push_simple.py
-
curl -L -o push_simple.py https://huggingface.co/spaces/whoisscaramouchee/textparser-backend/resolve/main/push_simple.py
1.59 kB
| """Simple push: just add all files.""" | |
| import os | |
| from pathlib import Path | |
| from huggingface_hub import HfApi, CommitOperationAdd | |
| TOKEN = "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" | |
| REPO = "whoisscaramouchee/textparser-backend" | |
| BACKEND_DIR = Path("C:/Projects/.ut/backend") | |
| api = HfApi(token=TOKEN) | |
| operations = [] | |
| files_to_push = [ | |
| "backend/config.py", | |
| "backend/main.py", | |
| "backend/pipeline.py", | |
| "backend/__init__.py", | |
| "backend/export/text.py", | |
| "backend/export/table.py", | |
| "backend/export/__init__.py", | |
| "backend/models/schemas.py", | |
| "backend/models/__init__.py", | |
| "backend/ocr/engine.py", | |
| "backend/ocr/surya.py", | |
| "backend/ocr/table.py", | |
| "backend/ocr/tesseract.py", | |
| "backend/ocr/__init__.py", | |
| "backend/preprocess/image.py", | |
| "backend/preprocess/__init__.py", | |
| ] | |
| for rel_path in files_to_push: | |
| # rel_path is already relative to backend/, so just join | |
| fpath = BACKEND_DIR / rel_path.replace("backend/", "") | |
| if not fpath.exists(): | |
| print(f" SKIPPED (not found): {rel_path}") | |
| continue | |
| with open(fpath, "rb") as f: | |
| content = f.read() | |
| # Use forward slashes | |
| path_in_repo = rel_path.replace("\\", "/") | |
| operations.append(CommitOperationAdd(path_in_repo=path_in_repo, path_or_fileobj=content)) | |
| print(f" Adding: {path_in_repo}") | |
| print(f"\nUploading {len(operations)} files...") | |
| result = api.create_commit( | |
| repo_id=REPO, | |
| repo_type="space", | |
| operations=operations, | |
| commit_message="Fix: update all backend files with correct paths" | |
| ) | |
| print(f"Done: {result.commit_url}") | |