From 28abd22571ebea67d1371f4846935b05abd87897 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Thu, 18 Sep 2025 23:48:49 +0200 Subject: [PATCH] updated to run python script to synchronize annotations from label studio to annotation repository --- .gitea/workflows/sync-annotations.yml | 50 ++++++++++----------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/.gitea/workflows/sync-annotations.yml b/.gitea/workflows/sync-annotations.yml index 9417a74..6638a57 100644 --- a/.gitea/workflows/sync-annotations.yml +++ b/.gitea/workflows/sync-annotations.yml @@ -1,4 +1,4 @@ -name: Sync Label Studio +name: Sync Label Studio Annotations on: schedule: @@ -9,39 +9,27 @@ jobs: sync_storage: runs-on: ubuntu-latest steps: - - name: Sync Label Studio Target Storage - env: - LABEL_STUDIO_API_TOKEN: ${{ secrets.LABEL_STUDIO_API_TOKEN }} - run: | - curl -X POST \ - -H "Authorization: Token $LABEL_STUDIO_API_TOKEN" \ - "https://label-studio.gt-proj.com/api/storages/export/s3/1/sync" + - name: Checkout code + uses: actions/checkout@v4 - - name: Install MinIO Client - run: | - wget https://dl.min.io/client/mc/release/linux-amd64/mc - chmod +x mc - sudo mv mc /usr/local/bin/ + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ vars.PYTHON_VERSION }} - - name: Fix Label Studio output content type in MinIO + - name: Install uv + run: pip install uv + + - name: Install dependencies env: + UV_LINK_MODE: copy + run: uv sync --all-extras + + - name: Sync annotations + env: + MINIO_ENDPOINT: ${{ vars.MINIO_ENDPOINT }} MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }} MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }} + MINIO_BUCKET: ${{ vars.MINIO_BUCKET }} run: | - mc alias set myminio http://10.0.0.2:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY - mc cp --recursive --attr 'Content-Type=application/json' \ - myminio/visual-semiotic-ai-analysis/label-studio-output/ \ - myminio/visual-semiotic-ai-analysis/label-studio-output/ - - - name: Ensure .json extension on files - env: - MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }} - MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }} - run: | - mc alias set myminio http://10.0.0.2:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY - for file in $(mc ls --recursive myminio/visual-semiotic-ai-analysis/label-studio-output/ | awk '{print $NF}'); do - if [[ "$file" != *.json ]]; then - mc mv "myminio/visual-semiotic-ai-analysis/label-studio-output/$file" \ - "myminio/visual-semiotic-ai-analysis/label-studio-output/$file.json" - fi - done + uv run python scripts/sync_label_studio_annotations.py