Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 46 additions & 21 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Build unstable

on: [push]
on:
push:
branches:
- main
- master
pull_request:

concurrency:
group: unstable
Expand All @@ -26,7 +31,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade flake8 pytest pycodestyle pytest-cov
pip install --upgrade flake8 pytest pycodestyle pytest-cov huggingface_hub
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
Expand Down Expand Up @@ -60,28 +65,48 @@ jobs:
run: echo ${{ steps.docker_build.outputs.digest }}
hf-space-deploy:
needs: [docker-build]
if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- name: Deploy to HuggingFace Space
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

- name: Install deployment dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade huggingface_hub

- name: Deploy to Hugging Face Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_ID: ${{ secrets.HF_SPACE_ID }}
run: |
response=$(curl -s -w "\n%{http_code}" -X POST \
"https://huggingface.co/spaces/sciencialab/document-qa-dev/restart?factory=true" \
-H "Authorization: Bearer $HF_TOKEN")
http_code=$(echo "$response" | tail -1)
body=$(echo "$response" | head -n -1)

echo "HTTP Status: $http_code"
echo "Response: $body"

if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
echo "## HuggingFace Space Deployment" >> $GITHUB_STEP_SUMMARY
echo "Successfully deployed to [document-qa-dev](https://huggingface.co/spaces/sciencialab/document-qa-dev)" >> $GITHUB_STEP_SUMMARY
else
echo " Deployment failed (HTTP $http_code): $body"
exit 1
fi

python - << 'PYEOF'
import os
from huggingface_hub import HfApi

token = os.environ["HF_TOKEN"]
space_id = os.environ["HF_SPACE_ID"]

api = HfApi(token=token)
api.upload_folder(
folder_path=".",
repo_id=space_id,
repo_type="space",
ignore_patterns=[
".git/*",
".github/*",
"tests/*",
"__pycache__/*",
"*.pyc",
]
)
print(f"Deployed to https://huggingface.co/spaces/{space_id}")
PYEOF
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ grobid-tei-xml==0.1.3
tqdm==4.66.3
pyyaml==6.0.1
pytest==8.1.1
streamlit==1.45.1
lxml==5.2.1
#streamlit==1.45.1
streamlit==1.37.1;
lxml==5.2.1
beautifulsoup4==4.12.3
python-dotenv==1.0.1
watchdog==4.0.0
Expand Down
Loading