From aaf5a59e283eeac9e0f2d995b8e559753f36a51c Mon Sep 17 00:00:00 2001 From: sanakhamassi Date: Thu, 30 Apr 2026 10:08:45 +0100 Subject: [PATCH 1/5] added automatic deployment at each push to huggingface space --- .github/workflows/ci-build.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 574fd3c..0720496 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -57,4 +57,31 @@ jobs: pushImage: ${{ github.event_name != 'pull_request' }} tags: latest-develop - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} \ No newline at end of file + run: echo ${{ steps.docker_build.outputs.digest }} + hf-space-deploy: + needs: [docker-build] + if: github.ref == 'refs/heads/main' || github.event_name == 'pull_request' + runs-on: ubuntu-latest + + steps: + - name: Deploy to HuggingFace Space + env: + HF_TOKEN: ${{ secrets.HF_TOKEN }} + 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 + \ No newline at end of file From 7a6ec6229a161a58a515aa41c166d46dba87356b Mon Sep 17 00:00:00 2001 From: sanakhamassi Date: Thu, 30 Apr 2026 10:36:46 +0100 Subject: [PATCH 2/5] trigger workflow From fc0b0b696bf62a5414fa69e9ba81930f4a943ee0 Mon Sep 17 00:00:00 2001 From: sanakhamassi Date: Thu, 7 May 2026 10:18:27 +0100 Subject: [PATCH 3/5] updated hf deployment --- .github/workflows/ci-build.yml | 54 +++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 0720496..841f728 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -1,6 +1,11 @@ name: Build unstable -on: [push] +on: + push: + branches: + - main + - master + pull_request: concurrency: group: unstable @@ -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: | @@ -60,28 +65,37 @@ 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: 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="deploy", + repo_id=space_id, + repo_type="space", + ) + print(f"Deployed to https://huggingface.co/spaces/{space_id}") + PYEOF \ No newline at end of file From 98b43a65ca2293ae018dffa6f4e0daf8a557cf80 Mon Sep 17 00:00:00 2001 From: sanakhamassi Date: Thu, 7 May 2026 12:24:10 +0100 Subject: [PATCH 4/5] enhance hf-space-deploy job to include repository checkout and ignore patterns for deployment --- .github/workflows/ci-build.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 841f728..ca305c4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -69,15 +69,20 @@ jobs: runs-on: ubuntu-latest steps: + - 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 }} @@ -92,10 +97,16 @@ jobs: api = HfApi(token=token) api.upload_folder( - folder_path="deploy", + 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 - \ No newline at end of file + PYEOF \ No newline at end of file From 391ceae64e1ecc70051b915caee2ec714cf9d19f Mon Sep 17 00:00:00 2001 From: sanakhamassi Date: Fri, 8 May 2026 10:59:27 +0100 Subject: [PATCH 5/5] Fix streamlit version conflict --- requirements.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index b9230aa..c897d47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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