Skip to content

Commit

Permalink
feat: upgrade pythone version, drop 3.10 and add VERBOSE env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
crqs committed May 12, 2023
1 parent 5935dcc commit 62579bd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ repos:
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py310-plus"]
args: ["--py311-plus"]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.11-slim
WORKDIR /app

RUN apt update && apt install -y libgomp1 && rm -rf /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.4.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ max-complexity = 10
per-file-ignores=__init__.py:F401

[mypy]
python_version = 3.10
python_version = 3.11
ignore_missing_imports = True
files = src/
plugins = numpy.typing.mypy_plugin
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
package_dir={"": "src"},
include_package_data=True,
zip_safe=True,
python_requires=">=3.10",
python_requires=">=3.11",
install_requires=[
"numpy~=1.23.0",
"grpcio~=1.51",
Expand All @@ -60,7 +60,7 @@
]
},
classifiers=[
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
],
Expand Down
14 changes: 8 additions & 6 deletions src/pythie_serving/abstract_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import abc
import logging
import os
import time
from pathlib import Path
from typing import Any, ClassVar, TypedDict
Expand Down Expand Up @@ -33,6 +34,7 @@ class AbstractPythieServingPredictionServiceServicer(prediction_service_pb2_grpc

def __init__(self, *, model_server_config: ModelServerConfig):
self.logger = logging.getLogger("pythie_serving")
self.verbose = bool(os.environ.get("VERBOSE", True))

self.model_map = {}
for model_config in model_server_config.model_config_list.config:
Expand Down Expand Up @@ -78,11 +80,12 @@ def Predict(self, request: predict_pb2.PredictRequest, context: grpc.RpcContext)
self.logger.error(f"Failed to serve because: {e}")
raise
else:
duration = time.time() - start
self.logger.info(
f"Served model {request.model_spec.name}/{request.model_spec.signature_name}: "
f"{len(pred)} predictions in {duration:.2f} seconds ({len(pred) / duration:.2f} pred/sec) "
)
if self.verbose:
duration = time.time() - start
self.logger.info(
f"Served model {request.model_spec.name}/{request.model_spec.signature_name}: "
f"{len(pred)} predictions in {duration:.2f} seconds ({len(pred) / duration:.2f} pred/sec) "
)
return predict_response

@staticmethod
Expand All @@ -102,7 +105,6 @@ def _parse_samples(request: predict_pb2.PredictRequest, model_specs: ModelSpecs)
samples = np.empty((nb_samples, nb_features), model_specs["samples_dtype"])

for i, feature_name in enumerate(features_names):

if request_inputs[feature_name].tensor_shape.dim[0].size != nb_samples:
raise PythieServingException(f"{feature_name} has invalid length.")

Expand Down

0 comments on commit 62579bd

Please sign in to comment.