From a82d69eecb4feb513ce62fc0295a2550041c4b36 Mon Sep 17 00:00:00 2001 From: krishanbhasin-gc Date: Wed, 20 Sep 2023 13:43:21 +0100 Subject: [PATCH] adjust to use poetry --- runtimes/catboost/README.md | 2 +- .../catboost/mlserver_catboost/version.py | 2 +- runtimes/catboost/pyproject.toml | 22 +++ runtimes/catboost/setup.py | 43 ------ runtimes/catboost/tests/conftest.py | 3 +- runtimes/catboost/tox.ini | 11 ++ setup.cfg | 125 ------------------ 7 files changed, 36 insertions(+), 172 deletions(-) create mode 100644 runtimes/catboost/pyproject.toml delete mode 100644 runtimes/catboost/setup.py create mode 100644 runtimes/catboost/tox.ini diff --git a/runtimes/catboost/README.md b/runtimes/catboost/README.md index 4f2d1c557..3dfd52b51 100644 --- a/runtimes/catboost/README.md +++ b/runtimes/catboost/README.md @@ -1,6 +1,6 @@ # CatBoost runtime for MLServer -This package provides a MLServer runtime compatible with CatBoost. +This package provides a MLServer runtime compatible with CatBoost's `CatboostClassifier`. ## Usage diff --git a/runtimes/catboost/mlserver_catboost/version.py b/runtimes/catboost/mlserver_catboost/version.py index 109fa1c51..84568d209 100644 --- a/runtimes/catboost/mlserver_catboost/version.py +++ b/runtimes/catboost/mlserver_catboost/version.py @@ -1 +1 @@ -__version__ = "1.1.0.dev1" +__version__ = "1.4.0.dev3" diff --git a/runtimes/catboost/pyproject.toml b/runtimes/catboost/pyproject.toml new file mode 100644 index 000000000..266e5d5c2 --- /dev/null +++ b/runtimes/catboost/pyproject.toml @@ -0,0 +1,22 @@ +[tool.poetry] +name = "mlserver-catboost" +version = "1.4.0.dev3" +description = "Catboost runtime for MLServer" +authors = ["Theofilos Papapanagiotou "] +maintainers = ["Seldon Technologies Ltd. "] +license = "Apache-2.0" +readme = "README.md" +packages = [{include = "mlserver_catboost"}] + +[tool.poetry.dependencies] +python = "^3.8.1,<3.12" +scikit-learn = "*" +joblib = "*" +mlserver = "*" + +[tool.poetry.group.dev.dependencies] +mlserver = {path = "../..", develop = true} + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" diff --git a/runtimes/catboost/setup.py b/runtimes/catboost/setup.py deleted file mode 100644 index eacb92d8a..000000000 --- a/runtimes/catboost/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -import os - -from typing import Dict -from setuptools import setup, find_packages - -ROOT_PATH = os.path.dirname(__file__) -PKG_NAME = "mlserver-catboost" -PKG_PATH = os.path.join(ROOT_PATH, PKG_NAME.replace("-", "_")) - - -def _load_version() -> str: - version = "" - version_path = os.path.join(PKG_PATH, "version.py") - with open(version_path) as fp: - version_module: Dict[str, str] = {} - exec(fp.read(), version_module) - version = version_module["__version__"] - - return version - - -def _load_description() -> str: - readme_path = os.path.join(ROOT_PATH, "README.md") - with open(readme_path) as fp: - return fp.read() - - -setup( - name=PKG_NAME, - version=_load_version(), - url="https://github.com/SeldonIO/MLServer.git", - author="Theofilos Papapanagiotou", - author_email="theofilos@gmail.com", - description="CatBoost runtime for MLServer", - packages=find_packages(exclude=["tests", "tests.*"]), - install_requires=[ - "mlserver", - "catboost", - ], - long_description=_load_description(), - long_description_content_type="text/markdown", - license="Apache 2.0", -) diff --git a/runtimes/catboost/tests/conftest.py b/runtimes/catboost/tests/conftest.py index d3bcf8419..2807d4b70 100644 --- a/runtimes/catboost/tests/conftest.py +++ b/runtimes/catboost/tests/conftest.py @@ -1,7 +1,7 @@ import pytest import os import numpy as np -from catboost import CatBoostClassifier #, CatBoostRegressor, CatBoostRanker +from catboost import CatBoostClassifier # , CatBoostRegressor, CatBoostRanker from mlserver.settings import ModelSettings, ModelParameters from mlserver.types import InferenceRequest @@ -14,7 +14,6 @@ @pytest.fixture def model_uri(tmp_path) -> str: - train_data = np.random.randint(0, 100, size=(100, 10)) train_labels = np.random.randint(0, 2, size=(100)) diff --git a/runtimes/catboost/tox.ini b/runtimes/catboost/tox.ini new file mode 100644 index 000000000..21f3266d4 --- /dev/null +++ b/runtimes/catboost/tox.ini @@ -0,0 +1,11 @@ +[tox] +isolated_build = true + +[testenv] +allowlist_externals = poetry +commands_pre = + poetry install --sync --no-root + poetry install -C {toxinidir}/../../ +commands = + python -m pytest {posargs} \ + {toxinidir}/tests diff --git a/setup.cfg b/setup.cfg index 75f7d2ba3..33ce25db4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,128 +16,3 @@ exclude = ./**/dist ./venv ./**/venv - -[mypy] -ignore_missing_imports = True -plugins = pydantic.mypy - -[tool:pytest] -asyncio_mode = auto - -[tox:tox] -basepython = py3 -envlist = - py3 - all - sklearn - xgboost - lightgbm - catboost - mlflow - alibiexplain - alibidetect - all-runtimes - -[testenv] -deps = -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/tests - -[testenv:all] -deps = - -e{toxinidir}[all] - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/tests - -[testenv:sklearn] -deps = - -e{toxinidir} - -e{toxinidir}/runtimes/sklearn - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/sklearn - -[testenv:xgboost] -deps = - -e{toxinidir} - -e{toxinidir}/runtimes/xgboost - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/xgboost - -[testenv:lightgbm] -deps = - -e{toxinidir} - -e{toxinidir}/runtimes/lightgbm - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/lightgbm - -[testenv:catboost] -deps = - -e{toxinidir} - -e{toxinidir}/runtimes/catboost - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/catboost - -[testenv:mlflow] -deps = - -e{toxinidir} - -e{toxinidir}/runtimes/mlflow - -r{toxinidir}/requirements/dev.txt - -r{toxinidir}/runtimes/mlflow/requirements-dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/mlflow - -[testenv:alibiexplain] -deps = - -e{toxinidir}/runtimes/alibi-explain - -e{toxinidir} - -r{toxinidir}/requirements/dev.txt - -r{toxinidir}/runtimes/alibi-explain/requirements-dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/alibi-explain - -[testenv:alibidetect] -deps = - -e{toxinidir}/runtimes/alibi-detect - -e{toxinidir} - -r{toxinidir}/requirements/dev.txt -commands = pytest {posargs} {toxinidir}/runtimes/alibi-detect - -[testenv:all-runtimes] -deps = - -e{toxinidir}/runtimes/alibi-explain - -e{toxinidir}/runtimes/alibi-detect - -e{toxinidir}/runtimes/sklearn - -e{toxinidir}/runtimes/xgboost - -e{toxinidir}/runtimes/mllib - -e{toxinidir}/runtimes/lightgbm - -e{toxinidir}/runtimes/catboost - -e{toxinidir}/runtimes/mlflow - -e{toxinidir}[all] - -r{toxinidir}/requirements/dev.txt - -r{toxinidir}/runtimes/mlflow/requirements-dev.txt - -r{toxinidir}/runtimes/alibi-explain/requirements-dev.txt -commands = pytest {posargs} - -[testenv:licenses] -deps = - -e{toxinidir}[all] - -e{toxinidir}/runtimes/sklearn - -e{toxinidir}/runtimes/xgboost - -e{toxinidir}/runtimes/mllib - -e{toxinidir}/runtimes/lightgbm - -e{toxinidir}/runtimes/catboost - -e{toxinidir}/runtimes/mlflow - -e{toxinidir}/runtimes/alibi-explain - -e{toxinidir}/runtimes/alibi-detect - -r{toxinidir}/runtimes/mlflow/requirements-dev.txt - -r{toxinidir}/runtimes/alibi-explain/requirements-dev.txt - -r{toxinidir}/requirements/dev.txt - -r{toxinidir}/requirements/docker.txt -commands = - pip-licenses \ - --from=mixed \ - --format=csv \ - --output-file=./licenses/license_info.csv - pip-licenses \ - --from=mixed \ - --format=plain-vertical \ - --with-license-file \ - --no-license-path \ - --output-file=./licenses/license.txt