Skip to content

fallbacks for chromadb #25

fallbacks for chromadb

fallbacks for chromadb #25

Workflow file for this run

name: Deploy to HuggingFace Space
on:
push:
branches: [ main ]
paths: [ 'backend/**' ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install HuggingFace Hub
run: pip install huggingface_hub
- name: Sync backend to HuggingFace Space
run: |
python -c "
from huggingface_hub import HfApi, create_repo
import os
api = HfApi(token=os.environ['HF_TOKEN'])
repo_id = os.environ['HF_SPACE_ID']
# Try to create the space if it doesn't exist
space_created = False
try:
create_repo(
repo_id=repo_id,
repo_type='space',
token=os.environ['HF_TOKEN'],
space_sdk='docker',
private=False
)
print(f'Created space: {repo_id}')
space_created = True
except Exception as e:
if 'already exists' in str(e).lower() or 'conflict' in str(e).lower():
print(f'Space {repo_id} already exists, continuing with upload...')
else:
print(f'Warning: Could not create space: {e}')
print('Attempting to upload anyway (space might exist)...')
# Always try to upload files from backend directory
try:
api.upload_folder(
folder_path='backend',
repo_id=repo_id,
repo_type='space',
token=os.environ['HF_TOKEN']
)
print(f'Successfully synced backend to {repo_id}')
except Exception as e:
print(f'Error uploading files: {e}')
raise e
"
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_ID: ${{ secrets.HF_SPACE_ID }}