From 3a70de0406080d54df85222a49397a7e8dcc9a2b Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:07:22 +0100 Subject: [PATCH 1/8] Upgrade version. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2300479d..c8ab4b9e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="api_inference_community", - version="0.0.36", + version="0.0.37", description="A package with helper tools to build an API Inference docker app for Hugging Face API inference using huggingface_hub", long_description=open("README.md", "r", encoding="utf-8").read(), long_description_content_type="text/markdown", From 06088ac7a829e83ccd9b0da26b7618f2e7652540 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:07:57 +0100 Subject: [PATCH 2/8] New api-routes release. --- docker_images/latent-to-image/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_images/latent-to-image/requirements.txt b/docker_images/latent-to-image/requirements.txt index eb9bc030..7ed19a8e 100644 --- a/docker_images/latent-to-image/requirements.txt +++ b/docker_images/latent-to-image/requirements.txt @@ -1,5 +1,5 @@ starlette -api-inference-community +api-inference-community>=0.37 diffusers transformers accelerate From 83923ecc2fe12035fb2aec95d8bfb5bac4c56628 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:40:31 +0100 Subject: [PATCH 3/8] Adding the workflows. --- .../workflows/python-api-latent-image-cd.yaml | 48 +++++++++++++++++++ .../workflows/python-api-latent-image.yaml | 27 +++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/python-api-latent-image-cd.yaml create mode 100644 .github/workflows/python-api-latent-image.yaml diff --git a/.github/workflows/python-api-latent-image-cd.yaml b/.github/workflows/python-api-latent-image-cd.yaml new file mode 100644 index 00000000..3f82cd7f --- /dev/null +++ b/.github/workflows/python-api-latent-image-cd.yaml @@ -0,0 +1,48 @@ +name: latent-to-image-docker-cd +on: + push: + branches: + - main + paths: + - "docker_images/latent-to-image/**" +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Install dependencies + run: | + pip install --upgrade pip + pip install awscli + - uses: huggingface/tailscale-action@v1 + with: + authkey: ${{ secrets.TAILSCALE_AUTHKEY }} + - name: Update upstream + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} + DEFAULT_HOSTNAME: ${{ secrets.DEFAULT_HOSTNAME }} + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + run: | + python build_docker.py latent-to-image --out out.txt + - name: Deploy on API + run: | + # Load the tags into the env + cat out.txt >> $GITHUB_ENV + export $(xargs < out.txt) + echo ${LATENT_TO_IMAGE_CPU_TAG} + # Weird single quote escape mechanism because string interpolation does + # not work on single quote in bash + curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"framework":"LATENT_TO_IMAGE","tag": "'"${LATENT_TO_IMAGE_CPU_TAG}"'"}}' + diff --git a/.github/workflows/python-api-latent-image.yaml b/.github/workflows/python-api-latent-image.yaml new file mode 100644 index 00000000..8accc9a8 --- /dev/null +++ b/.github/workflows/python-api-latent-image.yaml @@ -0,0 +1,27 @@ +# TODO: Merge this with allenNLP to have a single workflow for all docker images. +name: sentence-transformers-docker + +on: + pull_request: + paths: + - "docker_images/latent-to-image/**" +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Install dependencies + run: | + pip install --upgrade pip + pip install pytest pillow httpx + pip install -e . + - run: RUN_DOCKER_TESTS=1 pytest -sv tests/test_dockers.py::DockerImageTests::test_latent-to-image From 2d8c79ca14e727c629f524e3fa39abe35f41fdf5 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:43:41 +0100 Subject: [PATCH 4/8] CHnage the name. --- .github/workflows/python-api-latent-image.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-api-latent-image.yaml b/.github/workflows/python-api-latent-image.yaml index 8accc9a8..83a6cba1 100644 --- a/.github/workflows/python-api-latent-image.yaml +++ b/.github/workflows/python-api-latent-image.yaml @@ -1,5 +1,5 @@ # TODO: Merge this with allenNLP to have a single workflow for all docker images. -name: sentence-transformers-docker +name: latent-to-image-docker on: pull_request: From 77eafcec921b1d1ede5a10fc58d708dca6d6cb2c Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:44:52 +0100 Subject: [PATCH 5/8] Adding the missing test. --- tests/test_dockers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_dockers.py b/tests/test_dockers.py index 49602605..9d001c73 100644 --- a/tests/test_dockers.py +++ b/tests/test_dockers.py @@ -136,6 +136,10 @@ def test_sentence_transformers(self): ) self.framework_invalid_test("sentence_transformers") + def test_image_to_latent(self): + # TODO add working examples. + self.framework_invalid_test("image-to-latent") + def test_adapter_transformers(self): self.framework_docker_test( "adapter_transformers", From 76f18e8bc9e6460e0f7daaa82dd0a4f8fdb4bfc6 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:49:31 +0100 Subject: [PATCH 6/8] Dash vs underscore war. --- .github/workflows/python-api-latent-image.yaml | 2 +- tests/test_dockers.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-api-latent-image.yaml b/.github/workflows/python-api-latent-image.yaml index 83a6cba1..081b37fe 100644 --- a/.github/workflows/python-api-latent-image.yaml +++ b/.github/workflows/python-api-latent-image.yaml @@ -24,4 +24,4 @@ jobs: pip install --upgrade pip pip install pytest pillow httpx pip install -e . - - run: RUN_DOCKER_TESTS=1 pytest -sv tests/test_dockers.py::DockerImageTests::test_latent-to-image + - run: RUN_DOCKER_TESTS=1 pytest -sv tests/test_dockers.py::DockerImageTests::test_latent_to_image diff --git a/tests/test_dockers.py b/tests/test_dockers.py index 9d001c73..db9e8bd6 100644 --- a/tests/test_dockers.py +++ b/tests/test_dockers.py @@ -136,7 +136,7 @@ def test_sentence_transformers(self): ) self.framework_invalid_test("sentence_transformers") - def test_image_to_latent(self): + def test_latent_to_image(self): # TODO add working examples. self.framework_invalid_test("image-to-latent") From 74dc6782ae2ca419c1c3a8fe7ff781acaee2f4aa Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 15:55:27 +0100 Subject: [PATCH 7/8] Wrong name --- tests/test_dockers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_dockers.py b/tests/test_dockers.py index db9e8bd6..a640e7e1 100644 --- a/tests/test_dockers.py +++ b/tests/test_dockers.py @@ -138,7 +138,7 @@ def test_sentence_transformers(self): def test_latent_to_image(self): # TODO add working examples. - self.framework_invalid_test("image-to-latent") + self.framework_invalid_test("latent-to-image") def test_adapter_transformers(self): self.framework_docker_test( From 3b3e6ace5740bd7348fb828bbf7dac70210a6f3e Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Wed, 12 Feb 2025 16:27:43 +0100 Subject: [PATCH 8/8] Fix version. --- docker_images/latent-to-image/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_images/latent-to-image/requirements.txt b/docker_images/latent-to-image/requirements.txt index 7ed19a8e..d9509327 100644 --- a/docker_images/latent-to-image/requirements.txt +++ b/docker_images/latent-to-image/requirements.txt @@ -1,5 +1,5 @@ starlette -api-inference-community>=0.37 +api-inference-community>=0.0.37 diffusers transformers accelerate