From ee207bbdcb240ee434539cfcd69732396135841d Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 16:44:59 -0800 Subject: [PATCH 01/10] Start turbine-serving project. --- core/iree-requirements.txt | 2 + core/misc-requirements.txt | 4 + core/requirements.txt | 4 +- core/setup.py | 13 +-- serving/README.md | 12 +++ serving/mypy.ini | 4 + serving/pyproject.toml | 3 + serving/requirements.txt | 0 serving/setup.cfg | 6 ++ serving/setup.py | 106 ++++++++++++++++++++++++ serving/turbine_serving/llm/__init__.py | 0 serving/turbine_serving/py.typed | 1 + 12 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 core/iree-requirements.txt create mode 100644 core/misc-requirements.txt create mode 100644 serving/README.md create mode 100644 serving/mypy.ini create mode 100644 serving/pyproject.toml create mode 100644 serving/requirements.txt create mode 100644 serving/setup.cfg create mode 100644 serving/setup.py create mode 100644 serving/turbine_serving/llm/__init__.py create mode 100644 serving/turbine_serving/py.typed diff --git a/core/iree-requirements.txt b/core/iree-requirements.txt new file mode 100644 index 000000000..8e02bb4a5 --- /dev/null +++ b/core/iree-requirements.txt @@ -0,0 +1,2 @@ +iree-compiler==20240129.785 +iree-runtime==20240129.785 diff --git a/core/misc-requirements.txt b/core/misc-requirements.txt new file mode 100644 index 000000000..becb775f9 --- /dev/null +++ b/core/misc-requirements.txt @@ -0,0 +1,4 @@ +numpy>=1.26.3 +onnx>=1.15.0 +pytest>=8.0.0 +pytest-xdist>=3.5.0 diff --git a/core/requirements.txt b/core/requirements.txt index 58053f50d..128012cb7 100644 --- a/core/requirements.txt +++ b/core/requirements.txt @@ -6,6 +6,4 @@ -r pytorch-cpu-requirements.txt -r torchvision-requirements.txt - -iree-compiler==20240129.785 -iree-runtime==20240129.785 +-r iree-requirements.txt diff --git a/core/setup.py b/core/setup.py index f1aeda8c4..555519462 100644 --- a/core/setup.py +++ b/core/setup.py @@ -54,7 +54,8 @@ def load_requirement_pins(requirements_file: str): requirement_pins.update(dict(pin_pairs)) -load_requirement_pins("requirements.txt") +load_requirement_pins("iree-requirements.txt") +load_requirement_pins("misc-requirements.txt") load_requirement_pins("pytorch-cpu-requirements.txt") @@ -97,7 +98,7 @@ def initialize_options(self): ], }, install_requires=[ - "numpy", + f"numpy{get_version_spec('numpy')}", f"iree-compiler{get_version_spec('iree-compiler')}", f"iree-runtime{get_version_spec('iree-runtime')}", # Use the [torch-cpu-nightly] spec to get a more recent/specific version. @@ -106,12 +107,12 @@ def initialize_options(self): extras_require={ "torch-cpu-nightly": [f"torch{get_version_spec('torch')}"], "onnx": [ - "onnx>=1.15.0", + f"onnx{get_version_spec('onnx')}", ], "testing": [ - "onnx==1.15.0", - "pytest", - "pytest-xdist", + f"onnx{get_version_spec('onnx')}", + f"pytest{get_version_spec('pytest')}", + f"pytest-xdist{get_version_spec('pytest-xdist')}", ], }, cmdclass={"build": BuildCommand}, diff --git a/serving/README.md b/serving/README.md new file mode 100644 index 000000000..e1ed3f8a9 --- /dev/null +++ b/serving/README.md @@ -0,0 +1,12 @@ +# Turbine Serving Infrastructure + +This sub-project contains components and infrastructure for serving various +forms of Turbine compiled models. Instead of coming with models, it defines +ABIs that compiled models should adhere to in order to be served. It then +allows them to be delivered as web endpoints via popular APIs. + +As emulation can be the sincerest form of flattery, this project derives +substantial inspiration from vllm and the OpenAI APIs, emulating and +interopping with them where possible. It is intended to be the lightest +weight possible reference implementation for serving models with an +opinionated compiled form, built elsewhere in the project. diff --git a/serving/mypy.ini b/serving/mypy.ini new file mode 100644 index 000000000..2937f4a17 --- /dev/null +++ b/serving/mypy.ini @@ -0,0 +1,4 @@ +[mypy] + +mypy_path = $MYPY_CONFIG_FILE_DIR +packages = turbine_serving.llm diff --git a/serving/pyproject.toml b/serving/pyproject.toml new file mode 100644 index 000000000..9787c3bdf --- /dev/null +++ b/serving/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/serving/requirements.txt b/serving/requirements.txt new file mode 100644 index 000000000..e69de29bb diff --git a/serving/setup.cfg b/serving/setup.cfg new file mode 100644 index 000000000..358360671 --- /dev/null +++ b/serving/setup.cfg @@ -0,0 +1,6 @@ +[tool:pytest] +testpaths = + ./tests +filterwarnings = + # TODO: Remove once flatbuffer 'imp' usage resolved. + ignore::DeprecationWarning diff --git a/serving/setup.py b/serving/setup.py new file mode 100644 index 000000000..fccf93737 --- /dev/null +++ b/serving/setup.py @@ -0,0 +1,106 @@ +# Copyright 2024 Advanced Micro Devices, Inc +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import json +import os +import distutils.command.build +from pathlib import Path + +from setuptools import find_namespace_packages, setup + +THIS_DIR = Path(__file__).resolve().parent +REPO_DIR = THIS_DIR.parent +VERSION_INFO_FILE = REPO_DIR / "version_info.json" + + +with open( + os.path.join( + REPO_DIR, + "README.md", + ), + "rt", +) as f: + README = f.read() + + +def load_version_info(): + with open(VERSION_INFO_FILE, "rt") as f: + return json.load(f) + + +version_info = load_version_info() +PACKAGE_VERSION = version_info["package-version"] + +packages = find_namespace_packages( + include=[ + "turbine_serving", + "turbine_serving.*", + ], +) + +print("Found packages:", packages) + +# Lookup version pins from requirements files. +requirement_pins = {} + + +def load_requirement_pins(requirements_file: str): + with open(requirements_file, "rt") as f: + lines = f.readlines() + pin_pairs = [line.strip().split("==") for line in lines if "==" in line] + requirement_pins.update(dict(pin_pairs)) + + +load_requirement_pins(REPO_DIR / "core", "iree-requirements.txt") +load_requirement_pins(REPO_DIR / "core", "misc-requirements.txt") + + +def get_version_spec(dep: str): + if dep in requirement_pins: + return f">={requirement_pins[dep]}" + else: + return "" + + +# Override build command so that we can build into _python_build +# instead of the default "build". This avoids collisions with +# typical CMake incantations, which can produce all kinds of +# hilarity (like including the contents of the build/lib directory). +class BuildCommand(distutils.command.build.build): + def initialize_options(self): + distutils.command.build.build.initialize_options(self) + self.build_base = "_python_build" + + +setup( + name=f"turbine-serving", + version=f"{PACKAGE_VERSION}", + author="SHARK Authors", + author_email="stella@nod.ai", + description="SHARK Turbine Machine Learning Deployment Tools", + long_description=README, + long_description_content_type="text/markdown", + url="https://github.com/nod-ai/SHARK-Turbine", + license="Apache-2.0", + classifiers=[ + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + ], + packages=packages, + package_data = {"turbine_serving": ["py.typed"]}, + install_requires=[ + f"iree-compiler{get_version_spec('iree-compiler')}", + f"iree-runtime{get_version_spec('iree-runtime')}", + ], + extras_require={ + "testing": [ + f"pytest{get_version_spec('pytest')}", + f"pytest-xdist{get_version_spec('pytest-xdist')}", + ], + }, + cmdclass={"build": BuildCommand}, +) diff --git a/serving/turbine_serving/llm/__init__.py b/serving/turbine_serving/llm/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/serving/turbine_serving/py.typed b/serving/turbine_serving/py.typed new file mode 100644 index 000000000..5e43cc13b --- /dev/null +++ b/serving/turbine_serving/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561 inline type checking. From 1765edebaafd6f2ad1cc633baa568c7f00108998 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 16:47:55 -0800 Subject: [PATCH 02/10] Fix setup --- README.md | 2 +- serving/setup.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0a88880a8..655450db3 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ can specify pytorch-cpu and install via: ``` pip install --index-url https://download.pytorch.org/whl/cpu \ -r core/pytorch-cpu-requirements.txt \ - -r core torchvision-requirements.txt + -r core/torchvision-requirements.txt pip install shark-turbine ``` diff --git a/serving/setup.py b/serving/setup.py index fccf93737..694728e5f 100644 --- a/serving/setup.py +++ b/serving/setup.py @@ -54,8 +54,8 @@ def load_requirement_pins(requirements_file: str): requirement_pins.update(dict(pin_pairs)) -load_requirement_pins(REPO_DIR / "core", "iree-requirements.txt") -load_requirement_pins(REPO_DIR / "core", "misc-requirements.txt") +load_requirement_pins(REPO_DIR / "core" / "iree-requirements.txt") +load_requirement_pins(REPO_DIR / "core" / "misc-requirements.txt") def get_version_spec(dep: str): From a64d884b34865c43c64d7a9e138195566c37f2bf Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 16:59:49 -0800 Subject: [PATCH 03/10] Add mypy check --- .github/workflows/lint.yml | 22 ++++++++++++++----- serving/requirements.txt | 1 + serving/setup.py | 6 +++-- .../llm/entrypoints/api_server.py | 6 +++++ 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 serving/turbine_serving/llm/entrypoints/api_server.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bcefe1d2f..d6760bc19 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,11 +9,8 @@ on: jobs: black: - strategy: - matrix: - version: [3.11] - os: [ubuntu-latest] - runs-on: ${{matrix.os}} + name: Python Formatting With Black + runs-on: ubuntu-latest steps: - name: Checking out repository uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 @@ -36,3 +33,18 @@ jobs: run: | printf "You can fix formatting by running 'black' on the modified python files:\n" printf " git diff ${GITHUB_BASE_REF?} --name-only -- '*.py' ':!third_party' | xargs black\n" + + mypy: + name: MyPy Type Checking + runs-on: ubuntu-latest + steps: + - name: Checking out repository + uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 + - name: Setting up python + uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 + - name: Install MyPy + run: | + python3 -m pip install mypy==1.8.0 + - name: Type check serving/ directory + run: | + mypy serving/ diff --git a/serving/requirements.txt b/serving/requirements.txt index e69de29bb..fe21e1542 100644 --- a/serving/requirements.txt +++ b/serving/requirements.txt @@ -0,0 +1 @@ +fastapi>=0.109.2 diff --git a/serving/setup.py b/serving/setup.py index 694728e5f..dfbf2f976 100644 --- a/serving/setup.py +++ b/serving/setup.py @@ -9,7 +9,7 @@ import distutils.command.build from pathlib import Path -from setuptools import find_namespace_packages, setup +from setuptools import find_namespace_packages, setup # type: ignore THIS_DIR = Path(__file__).resolve().parent REPO_DIR = THIS_DIR.parent @@ -47,13 +47,14 @@ def load_version_info(): requirement_pins = {} -def load_requirement_pins(requirements_file: str): +def load_requirement_pins(requirements_file: Path): with open(requirements_file, "rt") as f: lines = f.readlines() pin_pairs = [line.strip().split("==") for line in lines if "==" in line] requirement_pins.update(dict(pin_pairs)) +load_requirement_pins(THIS_DIR / "requirements.txt") load_requirement_pins(REPO_DIR / "core" / "iree-requirements.txt") load_requirement_pins(REPO_DIR / "core" / "misc-requirements.txt") @@ -93,6 +94,7 @@ def initialize_options(self): packages=packages, package_data = {"turbine_serving": ["py.typed"]}, install_requires=[ + f"fastapi{get_version_spec('fastapi')}", f"iree-compiler{get_version_spec('iree-compiler')}", f"iree-runtime{get_version_spec('iree-runtime')}", ], diff --git a/serving/turbine_serving/llm/entrypoints/api_server.py b/serving/turbine_serving/llm/entrypoints/api_server.py new file mode 100644 index 000000000..cbcd55a6e --- /dev/null +++ b/serving/turbine_serving/llm/entrypoints/api_server.py @@ -0,0 +1,6 @@ +# Copyright 2024 Advanced Micro Devices, Inc +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + From 09b80496d4c95bd08ab0bd731ab96920d504287e Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 17:01:11 -0800 Subject: [PATCH 04/10] Lint --- serving/setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serving/setup.py b/serving/setup.py index dfbf2f976..a8a73a0f5 100644 --- a/serving/setup.py +++ b/serving/setup.py @@ -9,9 +9,9 @@ import distutils.command.build from pathlib import Path -from setuptools import find_namespace_packages, setup # type: ignore +from setuptools import find_namespace_packages, setup # type: ignore -THIS_DIR = Path(__file__).resolve().parent +THIS_DIR = Path(__file__).resolve().parent REPO_DIR = THIS_DIR.parent VERSION_INFO_FILE = REPO_DIR / "version_info.json" @@ -92,7 +92,7 @@ def initialize_options(self): "Programming Language :: Python :: 3", ], packages=packages, - package_data = {"turbine_serving": ["py.typed"]}, + package_data={"turbine_serving": ["py.typed"]}, install_requires=[ f"fastapi{get_version_spec('fastapi')}", f"iree-compiler{get_version_spec('iree-compiler')}", From cf45e35ecb7820cf2e25a34b92c369e93cc3ab1f Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:01:02 -0800 Subject: [PATCH 05/10] Basic serving test. --- .github/workflows/lint.yml | 1 + .github/workflows/test.yml | 12 ++-- mypy-requirements.txt | 2 + serving/mypy.ini | 1 + serving/requirements.txt | 1 + serving/setup.py | 1 + serving/tests/api_server_test.py | 63 +++++++++++++++++++ serving/turbine_serving/__init__.py | 0 .../llm/entrypoints/api_server.py | 44 +++++++++++++ 9 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 mypy-requirements.txt create mode 100644 serving/tests/api_server_test.py create mode 100644 serving/turbine_serving/__init__.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d6760bc19..be5100197 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,6 +45,7 @@ jobs: - name: Install MyPy run: | python3 -m pip install mypy==1.8.0 + python3 -m pip install -r mypy-requirements.txt - name: Type check serving/ directory run: | mypy serving/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 290fccb19..5d684121a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Turbine Core Test +name: Turbine Unit Tests on: workflow_dispatch: @@ -42,8 +42,12 @@ jobs: -r core/pytorch-cpu-requirements.txt \ -r core/torchvision-requirements.txt pip install --upgrade -r core/requirements.txt - pip install -e core[testing] + pip install -e core[testing] -e serving[testing] - - name: Run tests + - name: Run core tests run: | - pytest -n 4 core/tests/ + pytest -n 4 core/ + + - name: Run serving tests + run: | + pytest -n 4 serving/ diff --git a/mypy-requirements.txt b/mypy-requirements.txt new file mode 100644 index 000000000..dd23cf859 --- /dev/null +++ b/mypy-requirements.txt @@ -0,0 +1,2 @@ +# Typing packages needed for full mypy execution at the project level. +types-requests diff --git a/serving/mypy.ini b/serving/mypy.ini index 2937f4a17..fdba402eb 100644 --- a/serving/mypy.ini +++ b/serving/mypy.ini @@ -1,4 +1,5 @@ [mypy] +explicit_package_bases = True mypy_path = $MYPY_CONFIG_FILE_DIR packages = turbine_serving.llm diff --git a/serving/requirements.txt b/serving/requirements.txt index fe21e1542..3c9503df4 100644 --- a/serving/requirements.txt +++ b/serving/requirements.txt @@ -1 +1,2 @@ fastapi>=0.109.2 +uvicorn>=0.27.0 diff --git a/serving/setup.py b/serving/setup.py index a8a73a0f5..37ad48703 100644 --- a/serving/setup.py +++ b/serving/setup.py @@ -97,6 +97,7 @@ def initialize_options(self): f"fastapi{get_version_spec('fastapi')}", f"iree-compiler{get_version_spec('iree-compiler')}", f"iree-runtime{get_version_spec('iree-runtime')}", + f"uvicorn{get_version_spec('uvicorn')}", ], extras_require={ "testing": [ diff --git a/serving/tests/api_server_test.py b/serving/tests/api_server_test.py new file mode 100644 index 000000000..602dfb830 --- /dev/null +++ b/serving/tests/api_server_test.py @@ -0,0 +1,63 @@ +# Copyright 2024 Advanced Micro Devices, Inc +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import os +import pytest +import requests +import subprocess +import sys +import time + + +class ServerRunner: + def __init__(self, args): + self.url = "http://localhost:8000" + env = os.environ.copy() + env["PYTHONUNBUFFERED"] = "1" + self.process = subprocess.Popen( + [ + sys.executable, + "-m", + "turbine_serving.llm.entrypoints.api_server", + ] + + args, + env=env, + stdout=sys.stdout, + stderr=sys.stderr, + ) + self._wait_for_ready() + + def _wait_for_ready(self): + start = time.time() + while True: + try: + if requests.get(f"{self.url}/health").status_code == 200: + return + except Exception as e: + if self.process.poll() is not None: + raise RuntimeError("API server processs terminated") from e + time.sleep(0.25) + if time.time() - start > 30: + raise RuntimeError("Timeout waiting for server start") from e + + def __del__(self): + try: + process = self.process + except AttributeError: + pass + else: + process.terminate() + process.wait() + + +@pytest.fixture(scope="session") +def server(): + runner = ServerRunner([]) + yield runner + + +def test_basic(server: ServerRunner): + ... diff --git a/serving/turbine_serving/__init__.py b/serving/turbine_serving/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/serving/turbine_serving/llm/entrypoints/api_server.py b/serving/turbine_serving/llm/entrypoints/api_server.py index cbcd55a6e..f23b4abe9 100644 --- a/serving/turbine_serving/llm/entrypoints/api_server.py +++ b/serving/turbine_serving/llm/entrypoints/api_server.py @@ -4,3 +4,47 @@ # See https://llvm.org/LICENSE.txt for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +from typing import Sequence + +import argparse + +from fastapi import FastAPI, Request +from fastapi.responses import JSONResponse, Response +import sys +import uvicorn + +app = FastAPI() + + +@app.get("/health") +async def health() -> Response: + return Response(status_code=200) + + +def main(clargs: Sequence[str]): + parser = argparse.ArgumentParser() + parser.add_argument("--host", type=str, default=None) + parser.add_argument("--port", type=int, default=8000) + parser.add_argument( + "--root-path", + type=str, + default=None, + help="Root path to use for installing behind path based proxy.", + ) + parser.add_argument( + "--timeout-keep-alive", type=int, default=5, help="Keep alive timeout" + ) + args = parser.parse_args(clargs) + + app.root_path = args.root_path + uvicorn.run( + app, + host=args.host, + port=args.port, + log_level="debug", + timeout_keep_alive=args.timeout_keep_alive, + ) + + +if __name__ == "__main__": + main(sys.argv[1:]) From 85aea9a2b236b5b7b529d337cec3017d11093e86 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:05:04 -0800 Subject: [PATCH 06/10] Move mypy --- .github/workflows/lint.yml | 16 ---------------- .github/workflows/test.yml | 8 ++++++++ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index be5100197..b718d0832 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,19 +33,3 @@ jobs: run: | printf "You can fix formatting by running 'black' on the modified python files:\n" printf " git diff ${GITHUB_BASE_REF?} --name-only -- '*.py' ':!third_party' | xargs black\n" - - mypy: - name: MyPy Type Checking - runs-on: ubuntu-latest - steps: - - name: Checking out repository - uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0 - - name: Setting up python - uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 - - name: Install MyPy - run: | - python3 -m pip install mypy==1.8.0 - python3 -m pip install -r mypy-requirements.txt - - name: Type check serving/ directory - run: | - mypy serving/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d684121a..a04365d07 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,9 +45,17 @@ jobs: pip install -e core[testing] -e serving[testing] - name: Run core tests + if: !cancelled() run: | pytest -n 4 core/ - name: Run serving tests + if: !cancelled() run: | pytest -n 4 serving/ + + - name: MyPy Type Checking + if: !cancelled() + run: | + pip install -r mypy-requirements.txt + mypy serving/ From 63a51fd0049e68f3f04e6d799d7974eb5a76ddc1 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:06:06 -0800 Subject: [PATCH 07/10] Fix syntax --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a04365d07..4ba366127 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,17 +45,17 @@ jobs: pip install -e core[testing] -e serving[testing] - name: Run core tests - if: !cancelled() + if: {{ !cancelled() }} run: | pytest -n 4 core/ - name: Run serving tests - if: !cancelled() + if: {{ !cancelled() }} run: | pytest -n 4 serving/ - name: MyPy Type Checking - if: !cancelled() + if: {{ !cancelled() }} run: | pip install -r mypy-requirements.txt mypy serving/ From 6d66f822675c2c2a9f10a5b131af6c0c93af1284 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:08:25 -0800 Subject: [PATCH 08/10] Syntax --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ba366127..15fec1257 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,22 +40,22 @@ jobs: # wheels saves multiple minutes and a lot of bandwidth on runner setup. pip install --index-url https://download.pytorch.org/whl/cpu \ -r core/pytorch-cpu-requirements.txt \ - -r core/torchvision-requirements.txt + -r core/torchvision-requirements.txt pip install --upgrade -r core/requirements.txt pip install -e core[testing] -e serving[testing] - name: Run core tests - if: {{ !cancelled() }} + if: ${{ !cancelled() }} run: | pytest -n 4 core/ - name: Run serving tests - if: {{ !cancelled() }} + if: ${{ !cancelled() }} run: | pytest -n 4 serving/ - name: MyPy Type Checking - if: {{ !cancelled() }} + if: ${{ !cancelled() }} run: | pip install -r mypy-requirements.txt mypy serving/ From a0950f9a5f7b896fd58bd075f2e7191169be5efd Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:10:49 -0800 Subject: [PATCH 09/10] Include mypy --- .github/workflows/test.yml | 1 + mypy-requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15fec1257..4739d7dd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,7 @@ concurrency: jobs: test: + name: "Test" strategy: matrix: version: [3.11] diff --git a/mypy-requirements.txt b/mypy-requirements.txt index dd23cf859..f2484e486 100644 --- a/mypy-requirements.txt +++ b/mypy-requirements.txt @@ -1,2 +1,3 @@ # Typing packages needed for full mypy execution at the project level. +mypy==1.8.0 types-requests From 7ad21fd70ec695e9e80cbe3cd2eb7d94bef06cd8 Mon Sep 17 00:00:00 2001 From: Stella Laurenzo Date: Mon, 5 Feb 2024 18:13:02 -0800 Subject: [PATCH 10/10] Fix --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4739d7dd7..bbb6379ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,9 @@ jobs: pip install --index-url https://download.pytorch.org/whl/cpu \ -r core/pytorch-cpu-requirements.txt \ -r core/torchvision-requirements.txt - pip install --upgrade -r core/requirements.txt + pip install --upgrade \ + -r core/requirements.txt \ + -r mypy-requirements.txt pip install -e core[testing] -e serving[testing] - name: Run core tests @@ -58,5 +60,4 @@ jobs: - name: MyPy Type Checking if: ${{ !cancelled() }} run: | - pip install -r mypy-requirements.txt mypy serving/