Skip to content

Commit

Permalink
ci: auto fixes from pre-commit.ci
Browse files Browse the repository at this point in the history
For more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 12, 2024
1 parent 72c07bc commit b8039cf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
9 changes: 5 additions & 4 deletions examples/quickstart/client.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import bentoml
import numpy as np

input_series=[
import bentoml

input_series = [
[5.1, 3.5, 1.4, 0.2],
[6.2, 2.9, 4.3, 1.3],
[5.9, 3.0, 5.1, 1.8],
[4.6, 3.1, 1.5, 0.2],
[6.7, 3.1, 4.4, 1.4],
[5.5, 2.6, 4.4, 1.2],
[7.7, 3.0, 6.1, 2.3],
[4.9, 3.0, 1.4, 0.2]
[4.9, 3.0, 1.4, 0.2],
]

with bentoml.SyncHTTPClient('http://localhost:3000') as client:
with bentoml.SyncHTTPClient("http://localhost:3000") as client:
pred: np.ndarray = client.classify(input_series)
print(pred)
18 changes: 10 additions & 8 deletions examples/quickstart/service.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import numpy as np
from pydantic import Field
from typing_extensions import Annotated

import bentoml
from bentoml.validators import Shape

from pydantic import Field

@bentoml.service(
resources={
Expand All @@ -13,27 +13,29 @@
},
)
class IrisClassifier:
'''
"""
A simple Iris classification service using a sklearn model
'''
"""

# Load in the class scope to declare the model as a dependency of the service
iris_model = bentoml.models.get("iris_sklearn:latest")

def __init__(self):
'''
"""
Initialize the service by loading the model from the model store
'''
"""
import joblib

self.model = joblib.load(self.iris_model.path_of("model.pkl"))

@bentoml.api
def classify(
self,
input_series: Annotated[np.ndarray, Shape((-1, 4))] = Field(default=[[5.2, 2.3, 5.0, 0.7]]),
input_series: Annotated[np.ndarray, Shape((-1, 4))] = Field(
default=[[5.2, 2.3, 5.0, 0.7]]
),
) -> np.ndarray:
'''
"""
Define API with preprocessing and model inference logic
'''
"""
return self.model.predict(input_series)

0 comments on commit b8039cf

Please sign in to comment.