From edd21baaea3bf5c867b969668055a8a4d061c934 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:58:59 +0200 Subject: [PATCH 1/7] Fix formatting in `setup.py` --- setup.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index a199a4d3..48f8ad5d 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from __future__ import absolute_import + from setuptools import find_packages, setup # We don't declare our dependency on transformers here because we build with @@ -12,7 +13,7 @@ # libavcodec-extra : libavcodec-extra inculdes additional codecs for ffmpeg install_requires = [ - "transformers[sklearn,sentencepiece, audio,vision]==4.41.1", + "transformers[sklearn,sentencepiece,audio,vision]==4.41.1", "orjson", # vision "Pillow", @@ -25,7 +26,7 @@ "starlette", "uvicorn", "pandas", - "peft==0.11.1" + "peft==0.11.1", ] extras = {} @@ -43,12 +44,9 @@ "mock==2.0.0", "docker", "requests", - "tenacity" -] -extras["quality"] = [ - "isort", - "ruff" + "tenacity", ] +extras["quality"] = ["isort", "ruff"] extras["inf2"] = ["optimum-neuron"] setup( @@ -61,8 +59,10 @@ packages=find_packages(where="src"), install_requires=install_requires, extras_require=extras, - entry_points={"console_scripts": "serve=sagemaker_huggingface_inference_toolkit.serving:main"}, - python_requires=">=3.8.0", + entry_points={ + "console_scripts": "serve=sagemaker_huggingface_inference_toolkit.serving:main" + }, + python_requires=">=3.8", license="Apache License 2.0", classifiers=[ "Development Status :: 5 - Production/Stable", From b80ccc018d5806d1911d67d0cc79aae9a7ef7b43 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:59:10 +0200 Subject: [PATCH 2/7] Add missing trove classifiers --- setup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.py b/setup.py index 48f8ad5d..05a27adc 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,11 @@ "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering :: Artificial Intelligence", ], ) From 9cb52ee5ddb88cf5ace3e75bb447aa45fe20a93d Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:59:19 +0200 Subject: [PATCH 3/7] Add missing description --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 05a27adc..8db140ee 100644 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ name="huggingface-inference-toolkit", version=VERSION, author="HuggingFace", - description=".", + description="Hugging Face Inference Toolkit is for serving 🤗 Transformers models in containers.", url="", package_dir={"": "src"}, packages=find_packages(where="src"), From 6e3ed75d456470d9893358a9628c0bf04383e64e Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:59:34 +0200 Subject: [PATCH 4/7] Add missing `google-cloud-storage` as `google` extra --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8db140ee..7068f7a6 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ ] extras["quality"] = ["isort", "ruff"] extras["inf2"] = ["optimum-neuron"] +extras["google"] = ["google-cloud-storage"] setup( name="huggingface-inference-toolkit", From b4a053fc42afe15aaffbd9df061bb4883838e45a Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:07:12 +0200 Subject: [PATCH 5/7] Update `Dockerfile` indent size and `google-cloud-storage` installation - Align indent size with `apt-get install` even if those are just args - Align flag usage notation from `-U` to `--upgrade` i.e. using full name instead of shortened one for readability - Install `google-cloud-storage` from `google` extra instead (`google` extra was included recently as otherwise the installations from the wheel not relying on this Dockerfile would fail with an ImportError on `google-cloud-storage` when either deploying from Vertex AI or setting the `AIP_STORAGE_URI` env var) --- dockerfiles/pytorch/Dockerfile | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/dockerfiles/pytorch/Dockerfile b/dockerfiles/pytorch/Dockerfile index 348ef232..324001df 100644 --- a/dockerfiles/pytorch/Dockerfile +++ b/dockerfiles/pytorch/Dockerfile @@ -14,29 +14,30 @@ RUN apt-get update && \ add-apt-repository ppa:deadsnakes/ppa && \ apt-get -y upgrade --only-upgrade systemd openssl cryptsetup && \ apt-get install -y \ - build-essential \ - bzip2 \ - curl \ - git \ - git-lfs \ - tar \ - gcc \ - g++ \ - cmake \ - libprotobuf-dev \ - protobuf-compiler \ - python3-dev \ - python3-pip \ - python3.11 \ - libsndfile1-dev \ - ffmpeg \ + build-essential \ + bzip2 \ + curl \ + git \ + git-lfs \ + tar \ + gcc \ + g++ \ + cmake \ + libprotobuf-dev \ + protobuf-compiler \ + python3-dev \ + python3-pip \ + python3.11 \ + libsndfile1-dev \ + ffmpeg \ && apt-get clean autoremove --yes \ && rm -rf /var/lib/{apt,dpkg,cache,log} + # Copying only necessary files as filtered by .dockerignore COPY . . # install wheel and setuptools -RUN pip install --no-cache-dir -U pip ".[torch, st, diffusers]" +RUN pip install --no-cache-dir --upgrade pip ".[torch,st,diffusers]" # copy application COPY src/huggingface_inference_toolkit huggingface_inference_toolkit @@ -47,8 +48,7 @@ COPY --chmod=0755 scripts/entrypoint.sh entrypoint.sh ENTRYPOINT ["bash", "-c", "./entrypoint.sh"] +FROM base AS vertex -from base as vertex - -# Install Vertex AI requiremented packages -RUN pip install --no-cache-dir google-cloud-storage \ No newline at end of file +# Install `google` extra for Vertex AI compatibility +RUN pip install --no-cache-dir --upgrade ".[google]" From 01317af5a18f439f8a66918d8e407620c3ba76a3 Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:07:52 +0200 Subject: [PATCH 6/7] Add newline at the end of `setup.cfg` --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 21085086..79d6ce9b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,4 +19,4 @@ use_parentheses = True [flake8] ignore = E203, E501, E741, W503, W605 -max-line-length = 119 \ No newline at end of file +max-line-length = 119 From 91f48b1605d3ea13e81701280a66cee16dd9d28f Mon Sep 17 00:00:00 2001 From: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:09:34 +0200 Subject: [PATCH 7/7] Update `.github/workflows/unit-test.yaml` to install `google` extras too Ideally the `pip install` command shouldn't be required as it's installed already within the `integration-test-pytorch:gpu` image, but if adding it, to ensure consistency we should also include the recently included `google` extra that comes with `google-cloud-storage`; otherwise the tests within https://github.com/huggingface/huggingface-inference-toolkit/pull/76 will fail --- .github/workflows/unit-test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index a15cca96..0c8db252 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -44,5 +44,4 @@ jobs: -v ./tests:${{ env.CACHE_TEST_DIR }} \ --entrypoint /bin/bash \ integration-test-pytorch:gpu \ - -c "pip install '.[test, st, diffusers]' && pytest ${{ env.CACHE_TEST_DIR }}/unit" - \ No newline at end of file + -c "pip install '.[test,st,diffusers,google]' && pytest ${{ env.CACHE_TEST_DIR }}/unit"