Skip to content

Commit

Permalink
feat: Support Python 3.12; upgrade pynumaflow to 0.7.1
Browse files Browse the repository at this point in the history
Signed-off-by: Avik Basu <[email protected]>
  • Loading branch information
ab93 committed May 31, 2024
1 parent 934d8cf commit 1b6511b
Show file tree
Hide file tree
Showing 8 changed files with 567 additions and 381 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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
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
915 changes: 550 additions & 365 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.0a1"
version = "0.11.0a1"
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.1"
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

0 comments on commit 1b6511b

Please sign in to comment.