Quincy Hsieh commited on
Commit
f66fdd0
·
1 Parent(s): 4cf3b63

Add how to update binary files into /data bucket

Browse files
Files changed (1) hide show
  1. README.md +91 -2
README.md CHANGED
@@ -24,8 +24,9 @@ A complete **Retrieval-Augmented Generation (RAG)** system deployed as a Hugging
24
  3. [Step-by-Step Explanation](#step-by-step-explanation)
25
  4. [API Endpoints](#api-endpoints)
26
  5. [Setup & Deployment](#setup--deployment)
27
- 6. [Configuration](#configuration)
28
- 7. [How It Works (Detailed)](#how-it-works-detailed)
 
29
 
30
  ---
31
 
@@ -333,6 +334,94 @@ curl -X POST http://localhost:7860/ingest \
333
 
334
  ---
335
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
  ## Configuration
337
 
338
  | Variable | Default | Description |
 
24
  3. [Step-by-Step Explanation](#step-by-step-explanation)
25
  4. [API Endpoints](#api-endpoints)
26
  5. [Setup & Deployment](#setup--deployment)
27
+ 6. [Adding Binary Files to the HF Space](#adding-binary-files-to-the-hf-space)
28
+ 7. [Configuration](#configuration)
29
+ 8. [How It Works (Detailed)](#how-it-works-detailed)
30
 
31
  ---
32
 
 
334
 
335
  ---
336
 
337
+ ## Adding Binary Files to the HF Space
338
+
339
+ Large or binary files (e.g., pre-built ChromaDB databases, PDFs, images, model weights) cannot be pushed with regular `git push` because Hugging Face repositories enforce a **10 MB file-size limit** for standard Git. Use one of the methods below to make them available to your Space at runtime.
340
+
341
+ ### Method 1: Git LFS (recommended for files < 5 GB)
342
+
343
+ Hugging Face repos support [Git Large File Storage (LFS)](https://git-lfs.com/). Files tracked by LFS are stored in a dedicated bucket and downloaded transparently when the Space starts.
344
+
345
+ ```bash
346
+ # 1. Install Git LFS (once per machine)
347
+ git lfs install
348
+
349
+ # 2. Track the binary patterns you need
350
+ git lfs track "*.pdf"
351
+ git lfs track "*.sqlite3"
352
+ git lfs track "chroma_db/**"
353
+ git lfs track "DataSet/**"
354
+
355
+ # This updates .gitattributes — commit it
356
+ git add .gitattributes
357
+ git commit -m "chore: track binary files with Git LFS"
358
+
359
+ # 3. Add and push the binary files
360
+ git add chroma_db/ DataSet/
361
+ git commit -m "feat: add pre-built vector store and datasets"
362
+ git push
363
+ ```
364
+
365
+ > **Verify:** After pushing, open your Space repo on huggingface.co and click on an LFS file — it should show `Stored with Git LFS` instead of raw content.
366
+
367
+ ### Method 2: Upload via the `huggingface_hub` Python SDK
368
+
369
+ Use this when you want to upload files programmatically (e.g., from a CI pipeline or a notebook) without cloning the full repo.
370
+
371
+ ```python
372
+ from huggingface_hub import HfApi
373
+
374
+ api = HfApi()
375
+
376
+ # Upload a single file
377
+ api.upload_file(
378
+ path_or_fileobj="./chroma_db/chroma.sqlite3",
379
+ path_in_repo="chroma_db/chroma.sqlite3",
380
+ repo_id="YOUR_USERNAME/Example-App-Hackathon-Gustave-Eiffel-2026",
381
+ repo_type="space",
382
+ )
383
+
384
+ # Upload an entire folder
385
+ api.upload_folder(
386
+ folder_path="./DataSet",
387
+ path_in_repo="DataSet",
388
+ repo_id="YOUR_USERNAME/Example-App-Hackathon-Gustave-Eiffel-2026",
389
+ repo_type="space",
390
+ )
391
+ ```
392
+
393
+ > **Authentication:** Set `HF_TOKEN` in your environment or call `huggingface_hub.login()` first. The token needs **write** access to the Space.
394
+
395
+ ### Method 3: Hugging Face Hub UI (quick one-off uploads)
396
+
397
+ 1. Open your Space repository on huggingface.co
398
+ 2. Navigate to **Files and versions**
399
+ 3. Click **Add file → Upload files**
400
+ 4. Drag-and-drop your binary files (up to 50 GB per file via the UI)
401
+ 5. Commit directly to `main`
402
+
403
+ ### Accessing Uploaded Files in Your Application
404
+
405
+ Once binary files are in the repo (via any method above), they are available at their relative path inside the Space container:
406
+
407
+ ```python
408
+ import chromadb
409
+
410
+ # Files land at the repo root, same relative path you committed them at
411
+ client = chromadb.PersistentClient(path="./chroma_db")
412
+ ```
413
+
414
+ No extra download logic is needed — Hugging Face clones the full repo (including LFS objects) into the Space container on startup.
415
+
416
+ ### Tips
417
+
418
+ - **`.gitattributes`** is the source of truth for LFS tracking. Verify your patterns are listed there before pushing.
419
+ - For files **> 5 GB**, prefer uploading via the Hub UI or the SDK (Git LFS CLI may time out on slow connections).
420
+ - If you update a binary file, push the new version the same way — LFS handles versioning automatically.
421
+ - To exclude files from the Space build (e.g., test data not needed at runtime), add them to `.gitignore` instead.
422
+
423
+ ---
424
+
425
  ## Configuration
426
 
427
  | Variable | Default | Description |