This message was deleted.
# ask-for-help
s
This message was deleted.
👀 1
s
Hey! That usually means that your service code has some errors in it. Can you run it with python like
python service.py
?
s
Could you please share your service code here?
y
import bentoml from bentoml.io import JSON model_ref = bentoml.xgboost.get("credit_risk_model:icfexlspfwvdaacc") model_runner = model_ref.to_runner() svc = bentoml.Service("credit_risk_classifier", runners=[model_runner]) @svc.api(input=JSON(),output=JSON()) def classify(application_data): prediction = model_runner.predict.run(application_data) return {"status": "Approved"}
If I run python service.py from anaconda prompt then nothing happens but when I run it using Python IDLE program, it gives me: Traceback (most recent call last): File "C:\Users\yki\service.py", line 3, in <module> from bentoml.io import JSON ModuleNotFoundError: No module named 'bentoml.io'
s
Oh! I just realized the actual issue, you need to put
service.py:svc
and not
service:svc
, I think!
y
I used bentoml serve service.py:svc and still has this error: [bentoml-cli]
serve
failed: Failed to load bento or import service 'service.py:svc'. If you are attempting to import bento in local store:
Attribute "svc" not found in module "service".
, or if you are importing by python module path:
Bento 'service.py:svc' is not found in BentoML store <osfs 'C:\Users\yadwi\bentoml\bentos'>
and when I run python service.py, I get: Traceback (most recent call last): File "service.py", line 8, in <module> dv = model_ref.custom_objects['dictVectorizer'] KeyError: 'dictVectorizer'
s
Oh, you're passing it on the command line! It should just be
bentoml serve .
, then. For the second error, it seems like your model hasn't saved the custom object properly, can you
print(model_ref.custom_objects)
?
y
I'm using anaconda prompt and print('model_ref.custom_objects) gives Unable to initialize device PRN
s
Ah, that should be inside the service code, right above the line where you try to use
dictVectorizer
, not in the prompt. You can just run the service again after to see the output.
y
tried it, still the same error.....
s
Yep, it should still error, but it should print the value of custom objects now.
Just trying to figure out why this is broken now. The other thing that would be useful to know is how you're saving
dictVectorizer
in your training code.
y
s
Ah, great that you worked that out!
y
Thanks for all the support and prompt responses 🙂