Serine Daouk
07/25/2024, 6:45 AMSerine Daouk
07/25/2024, 6:48 AMimport bentoml
import numpy as np
@bentoml.service(workers=2)
class InputClassifier:
bento_model = bentoml.models.get(
"random_forest_large_binary_classifier:2mzuac2e22sq2aam"
)
def __init__(self):
self.model = bentoml.mlflow.load_model(self.bento_model)
@bentoml.api
def predict(self, input_data: np.ndarray) -> np.ndarray:
with bentoml.monitor("incoming predictions") as mon:
mon.log(input_data, name="Incoming input data", role="input", data_type="numerical")
return self.model.predict(input_data)Jian Shen Yap
07/25/2024, 6:53 AMSerine Daouk
07/25/2024, 6:59 AMJian Shen Yap
07/25/2024, 9:11 AM• Be able to log the incoming input data in the requests I'm getting.Where is intended destination of your logs? with your current code you should see a local log file created.
• The response-time for the incoming requests.
• Current number of requests being handled (since I might have more than one worker handling incoming requests).This is available in the
/metrics endpointSerine Daouk
07/25/2024, 9:41 AMcurl -o metrics.txt ip_address:port/metrics for my service.
(I'm working on a bare bone server with no GUI at the moment)
At least now I can see the metrics.
I was following this part of the documentation and not understanding where my .log file was or how could I generate it:
Deploy the service and collect monitoring data in https://docs.bentoml.com/en/v1.1.11/guides/monitoring.htmlSerine Daouk
07/25/2024, 9:42 AMJian Shen Yap
07/25/2024, 10:52 AMmonitoring or data folder being created locally?Serine Daouk
07/26/2024, 2:38 AMJian Shen Yap
07/26/2024, 2:39 AMJian Shen Yap
07/26/2024, 2:39 AMSerine Daouk
07/26/2024, 2:41 AMSerine Daouk
07/26/2024, 8:03 AMdocker run --rm -p 3000:3000 -v ./files/bento-monitoring:/src/monitoring signal_classifier:fy5p3bsla6qysm to set up a volume for any files that get created inside the monitoring folder to be copied to my host machine in files/bento-monitoring directory.
However nothing is happening.
Should I mount to just /src instead ? or go a deeper when setting up the volume with /src/monitoring/<name>/data inside the bento container ?