Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support Python 3.12; upgrade pynumaflow to 0.7.1 #383

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
name: Generate changelog
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry==1.6.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry==1.6.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
if: github.repository == 'numaproj/numalogic'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Black format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --verbose"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:

name: Publish to PyPi
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install poetry==1.6.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Docker Login
uses: docker/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# builder: install needed dependencies and setup virtual environment
####################################################################################################

ARG PYTHON_VERSION=3.11
ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}-slim-bookworm AS builder

ARG POETRY_VERSION=1.6
Expand Down
2 changes: 1 addition & 1 deletion numalogic/udfs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def init_server(step: str, server_type: str):
redis_client = get_redis_client_from_conf(pipeline_conf.redis_conf)
udf = UDFFactory.get_udf_instance(step, r_client=redis_client, pl_conf=pipeline_conf)

return ServerFactory.get_server_instance(server_type, handler=udf)
return ServerFactory.get_server_instance(server_type, mapper_instance=udf)


def start_server() -> None:
Expand Down
8 changes: 4 additions & 4 deletions numalogic/udfs/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ def get_udf_instance(cls, udf_name: str, **kwargs) -> nl_udf_t:
class ServerFactory:
"""Factory class to fetch the right pynumaflow function server/mapper."""

from pynumaflow.mapper import Mapper, MultiProcMapper, AsyncMapper
from pynumaflow.mapper import MapServer, MapMultiprocServer, MapAsyncServer

_SERVER_MAP: ClassVar[dict] = {
"sync": Mapper,
"async": AsyncMapper,
"multiproc": MultiProcMapper,
"sync": MapServer,
"async": MapAsyncServer,
"multiproc": MapMultiprocServer,
}

@classmethod
Expand Down
1,221 changes: 704 additions & 517 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "numalogic"
version = "0.10.2"
version = "0.11.0"
description = "Collection of operational Machine Learning models and tools."
authors = ["Numalogic Developers"]
packages = [{ include = "numalogic" }]
Expand All @@ -17,21 +17,22 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
]
repository = "https://github.com/numaproj/numalogic"
documentation = "https://numalogic.numaproj.io/"
homepage = "https://numalogic.numaproj.io/"

[tool.poetry.dependencies]
python = ">=3.9, <3.12"
python = ">=3.9, <3.13"
numpy = "^1.26"
pandas = { version = "^2.0", extras = ["performance"] }
scikit-learn = "^1.3"
omegaconf = "^2.3.0"
cachetools = "^5.3.0"
orjson = "^3.9"
pynumaflow = "~0.6"
pynumaflow = "~0.7.2"
prometheus_client = "^0.18.0"
structlog = "^24.1.0"

Expand Down
4 changes: 2 additions & 2 deletions tests/udfs/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def test_get_instance_02(self):
class TestServerFactory(unittest.TestCase):
def test_get_cls(self):
server_cls = ServerFactory.get_server_cls("sync")
self.assertEqual(server_cls.__name__, "Mapper")
self.assertEqual(server_cls.__name__, "MapServer")

def test_get_cls_err(self):
with self.assertRaises(ValueError):
ServerFactory.get_server_cls("some_server")

def test_get_instance(self):
server = ServerFactory.get_server_instance("multiproc", handler=lambda x: x)
server = ServerFactory.get_server_instance("multiproc", mapper_instance=lambda x: x)
self.assertIsInstance(server, ServerFactory.get_server_cls("multiproc"))


Expand Down
6 changes: 3 additions & 3 deletions tests/udfs/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import patch

from omegaconf import OmegaConf
from pynumaflow.mapper import Mapper, MultiProcMapper
from pynumaflow.mapper import MapServer, MapMultiprocServer

from numalogic._constants import TESTS_DIR
from numalogic.tools.exceptions import ConfigNotFoundError
Expand All @@ -18,14 +18,14 @@ def test_init_server_01(self):
from numalogic.udfs.__main__ import init_server

server = init_server("preprocess", "sync")
self.assertIsInstance(server, Mapper)
self.assertIsInstance(server, MapServer)

@patch.dict("os.environ", {"BASE_CONF_PATH": BASE_CONFIG_PATH, "REDIS_AUTH": REDIS_AUTH})
def test_init_server_02(self):
from numalogic.udfs.__main__ import init_server

server = init_server("inference", "multiproc")
self.assertIsInstance(server, MultiProcMapper)
self.assertIsInstance(server, MapMultiprocServer)

def test_conf_loader(self):
from numalogic.udfs import load_pipeline_conf
Expand Down
Loading