Skip to content

Commit

Permalink
✨ Python 3.12 compatibility (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
perdy committed Oct 30, 2023
1 parent 06527b2 commit 649ac27
Show file tree
Hide file tree
Showing 10 changed files with 457 additions and 872 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
DEFAULT_LINUX: "slim"
DEFAULT_PYTHON: "3.11"
DEFAULT_PYTHON: "3.12"
DEFAULT_SCHEMAS: "pydantic"

jobs:
Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [ "3.8", "3.9", "3.10", "3.11"]
python: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
container:
image: python:${{ matrix.python }}
steps:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
strategy:
matrix:
linux: ["slim"]
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
schemas: ["pydantic", "marshmallow", "typesystem"]
steps:
- name: Check out the repo
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_pull_request_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
container:
image: python:${{ matrix.python }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion flama/models/models/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flama.models.base import Model

try:
import torch
import torch # type: ignore
except Exception: # pragma: no cover
torch = None # type: ignore

Expand Down
2 changes: 1 addition & 1 deletion flama/models/models/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flama.models.base import Model

try:
import tensorflow as tf
import tensorflow as tf # type: ignore
except Exception: # pragma: no cover
tf = None

Expand Down
2 changes: 1 addition & 1 deletion flama/serialize/serializers/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flama.serialize.base import Serializer

try:
import torch
import torch # type: ignore
except Exception: # pragma: no cover
torch = None # type: ignore[misc, assignment]

Expand Down
2 changes: 1 addition & 1 deletion flama/serialize/serializers/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from flama.serialize.base import Serializer

try:
import tensorflow as tf
import tensorflow as tf # type: ignore
except Exception: # pragma: no cover
tf = None # type: ignore[misc, assignment]

Expand Down
1,260 changes: 423 additions & 837 deletions poetry.lock

Large diffs are not rendered by default.

47 changes: 23 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ generate-setup-file = false
script = "build.py"

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
starlette = ">=0.21.0,<1.0.0"
python = ">=3.8,<3.13"
starlette = ">=0.31.0,<1.0.0"
click = "^8.1"
uvicorn = "^0.22"
uvicorn = { version = ">=0.23.2,<1.0.0", extras = ["standard"] }
Jinja2 = "^3.1.2"
pyyaml = "^6.0"
typing-extensions = { version = "^4.4", python = "<3.10" }
Expand All @@ -48,7 +48,7 @@ marshmallow = { version = "^3.0", optional = true }
apispec = { version = "^6.0", optional = true }
typesystem = { version = "^0.4.1", optional = true }
SQLAlchemy = { version = "^2.0", extras = ["asyncio"], optional = true }
httpx = { version = "^0.24", optional = true}
httpx = { version = "^0.25", optional = true}

[tool.poetry.extras]
pydantic = ["pydantic"]
Expand All @@ -65,44 +65,43 @@ flama = 'flama.cli.__main__:cli'
optional = true

[tool.poetry.group.dev.dependencies]
pytest = "^7.0"
pytest-xdist = { version = "^3.0", extras = ["psutil"] }
pytest-cov = "^4.0"
pytest-asyncio = "^0.20"
pytest = "^7.4"
pytest-xdist = { version = "^3.3", extras = ["psutil"] }
pytest-cov = "^4.1"
pytest-asyncio = "^0.21"
ipython = "^8.0"
isort = "^5.10"
ruff = "^0.0.231"
black = { version = "^22.3", extras = ["d"] }
pre-commit = "^2.20"
python-multipart = "^0.0.5"
uvicorn = { version = ">=0.19.0,<1.0.0", extras = ["standard"] }
httpx = "^0.24"
aiosqlite = ">=0.11.0,<1.0.0"
requests = "^2.22"
isort = "^5.12"
ruff = "^0.0.292"
black = "^23.9"
pre-commit = "^3.4"
python-multipart = "^0.0.6"
uvicorn = { version = ">=0.23.2,<1.0.0", extras = ["standard"] }
httpx = "^0.25"
aiosqlite = ">=0.19.0,<1.0.0"
Faker = "^8.2"
SQLAlchemy = { version = "^2.0", extras = ["asyncio"] }
gevent = "^23.9.1"
pyright = "^1.1.320"
pyright = "^1.1.329"

[tool.poetry.group.schemas]
optional = true

[tool.poetry.group.schemas.dependencies]
pydantic = "^2.0"
marshmallow = "^3.0"
apispec = "^6.0"
pydantic = "^2.4"
marshmallow = "^3.20"
apispec = "^6.3"
typesystem = "^0.4"

[tool.poetry.group.ml]
optional = true

[tool.poetry.group.ml.dependencies]
scikit-learn = "^1.3.0"
scikit-learn = { version = "^1.3.1", python = ">=3.8,<3.12"}
tensorflow-cpu = [
{ version = "^2.12.0", platform = "linux", python = ">=3.8,<3.9" },
{ version = "^2.14.0", platform = "linux", python = ">=3.9"}
{ version = "^2.14.0", platform = "linux", python = ">=3.9,<3.12"}
]
torch = "2.0.0" # SEE: Hold this version until this issue is fixed https://github.com/pytorch/pytorch/issues/100974
torch = { version = "2.0.0", python = ">=3.8,<3.12"} # SEE: Hold this version until this issue is fixed https://github.com/pytorch/pytorch/issues/100974

[tool.black]
line-length = 120
Expand Down
4 changes: 2 additions & 2 deletions scripts/docker_push
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
set -e

LINUX_VERSIONS=("slim")
PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11")
PYTHON_VERSIONS=("3.8" "3.9" "3.10" "3.11", "3.12")
SCHEMA_LIBS=("pydantic" "marshmallow" "typesystem")

DEFAULT_LINUX="slim"
DEFAULT_PYTHON="3.11"
DEFAULT_PYTHON="3.12"
DEFAULT_SCHEMA_LIB="pydantic"

docker_push() {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async def send(message: types.Message) -> None:
with exception, patch.object(lifespan, "_startup", side_effect=startup_side_effect), patch.object(
lifespan, "_shutdown", side_effect=shutdown_side_effect
):
for (receive_messages, send_messages, app_status) in states:
for receive_messages, send_messages, app_status in states:
for m in receive_messages:
await receive_queue.put(m)
await lifespan(types.Scope({"app": app, "type": "lifespan"}), receive, send)
Expand Down

0 comments on commit 649ac27

Please sign in to comment.