Upload folder using huggingface_hub
Browse files
.github/workflows/deploy_to_hf.yml
CHANGED
|
@@ -15,26 +15,27 @@ jobs:
|
|
| 15 |
- uses: actions/checkout@v3
|
| 16 |
with:
|
| 17 |
fetch-depth: 0
|
| 18 |
-
- name:
|
|
|
|
|
|
|
|
|
|
| 19 |
env:
|
| 20 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 21 |
run: |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
# 1. Clone the HF Repo specifically
|
| 27 |
-
git clone https://umer6016:$HF_TOKEN@huggingface.co/spaces/umer6016/Stockker hf_space
|
| 28 |
-
cd hf_space
|
| 29 |
-
|
| 30 |
-
# 2. Delete everything in HF repo (to ensure clean slate) except .git
|
| 31 |
-
# (We use find to avoid error if empty)
|
| 32 |
-
find . -maxdepth 1 -not -name '.git' -not -name '.' -exec rm -rf {} +
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
- uses: actions/checkout@v3
|
| 16 |
with:
|
| 17 |
fetch-depth: 0
|
| 18 |
+
- name: Install Python dependencies
|
| 19 |
+
run: pip install huggingface_hub
|
| 20 |
+
|
| 21 |
+
- name: Push to Hub (Python Mode)
|
| 22 |
env:
|
| 23 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 24 |
run: |
|
| 25 |
+
python -c "
|
| 26 |
+
from huggingface_hub import HfApi
|
| 27 |
+
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
api = HfApi()
|
| 30 |
+
print('Uploading files to Hugging Face...')
|
| 31 |
|
| 32 |
+
# Upload the entire current directory to the Space
|
| 33 |
+
api.upload_folder(
|
| 34 |
+
folder_path='.',
|
| 35 |
+
repo_id='umer6016/Stockker',
|
| 36 |
+
repo_type='space',
|
| 37 |
+
token=os.environ['HF_TOKEN'],
|
| 38 |
+
ignore_patterns=['.git', '.github', '__pycache__', 'vocab.txt']
|
| 39 |
+
)
|
| 40 |
+
print('Upload complete!')
|
| 41 |
+
"
|