This message was deleted.
# ask-for-help
s
This message was deleted.
m
Hi there, What command are you running? Another thing, Are you sure you are running the command from the location where the
bentofile.yaml
file is?
I'm assuming you use
bento build
command when you get this error. Kindly run
pwd
and paste the output here please.
y
I get this error when I try to create the docker image. Yes, I am creating the docker image from the same file location where bentofile.yaml is. >bentoml containerize credit_risk_classifier:latest (the command I am running)
m
That is strange if it's still giving us a file not found in that case. Can you please share your
bentofile.yaml
? Maybe we can find something there.
y
service: "service:svc" labels: owner: bentoml-team project: gallery include: - "*.py" python: packages: - sklearn - pandas
I could create a bento and bentoml models lists give : credit_risk_model:fovp3okuu6jdmacc bentoml.xgboost 171.34 KiB 2022-10-25 225408 credit_risk_model:aaqm7p2uu6nauacc bentoml.xgboost 171.33 KiB 2022-10-25 225255 credit_risk_model:23opqfkuu2fq6acc bentoml.xgboost 170.64 KiB 2022-10-25 225146
m
I don't see anything missing here. Try to build bento and docker again:
Copy code
bentoml build

bentoml containerize credit_risk_classifier:latest
y
bentoml models get credit_risk_model:latest name: credit_risk_model version: fovp3okuu6jdmacc module: bentoml.xgboost labels: {} options: model_class: Booster metadata: {} context: framework_name: xgboost framework_versions: xgboost: 1.6.2 bentoml_version: 1.0.7 python_version: 3.9.13 signatures: predict: batchable: false api_version: v2 creation_time: '2022-10-25T205408.725138+00:00'
created a new bento again : Successfully built Bento(tag="credit_risk_classifier:234s772vkc6yiacc")
containerize is giving errors again: C:\Users\yadwi\Bento>bentoml containerize credit_risk_classifier:latest Traceback (most recent call last):
FileNotFoundError: [WinError 2] The system cannot find the file specified
Copy code
(base) C:\Users\yadwi\Bento>bentoml containerize credit_risk_classifier:latest
Traceback (most recent call last):
  File "C:\Users\yadwi\anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\yadwi\anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\yadwi\anaconda3\Scripts\bentoml.exe\__main__.py", line 7, in <module>
    sys.exit(cli())
  File "C:\Users\yadwi\anaconda3\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\yadwi\anaconda3\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml_cli\utils.py", line 256, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml_cli\utils.py", line 230, in wrapper
    return_value = func(*args, **kwargs)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml_cli\utils.py", line 191, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml_cli\utils.py", line 63, in wrapper
    return func(*args, **{k: transformer(v) for k, v in kwargs.items()})
  File "C:\Users\yadwi\anaconda3\lib\site-packages\simple_di\__init__.py", line 139, in _
    return func(*_inject_args(bind.args), **_inject_kwargs(bind.kwargs))
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml_cli\containerize.py", line 247, in containerize
    buildx.health()
  File "C:\Users\yadwi\anaconda3\lib\site-packages\bentoml\_internal\utils\buildx.py", line 36, in health
    output = subprocess.check_output(cmds)
  File "C:\Users\yadwi\anaconda3\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\yadwi\anaconda3\lib\subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "C:\Users\yadwi\anaconda3\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\yadwi\anaconda3\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
m
There's one catch, is your model xgboost? If so then you need to add
xgboost
in the bentofile.yaml file (after scikit-learn and pandas). Then build and containerize
y
did that too, added xgboost in the yaml file then build and containerize, still the same error
m
Hmm, there's something missing which we need to figure out. How is your service.py file, can you share that one please?
y
Copy code
import numpy as np
from sklearn.feature_extraction import DictVectorizer
import bentoml
from <http://bentoml.io|bentoml.io> import JSON

model_ref = bentoml.xgboost.get("credit_risk_model:latest")
dv = model_ref.custom_objects['dictVectorizer']

print('model_ref.custom_objects') 


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):
    vector = dv.transform(application_data)
    prediction = model_runner.predict.run(vector)
    print(prediction)

    result = prediction[0]

    if result > 0.5:
        return {"status": "DECLINED"}
    elif result > 0.23:
        return{"status":"MAYBE"}
    else:        
        return {"status": "Approved"}
m
What terminal are you using? CMD or bash?
y
anaconda prompt which I reinstalled
also tried cmd windows but had same error when containerising
m
Okay, one second
What is the output when you run
dir
Trying to reproduce the error
y
Directory of C:\Users\yadwi\Bento 26/10/2022 18:55 <DIR> . 26/10/2022 08:25 <DIR> .. 26/10/2022 18:55 642 bento.odt 26/10/2022 19:15 163 bentofile.yaml 25/10/2022 23:59 0 bentoml 18/10/2022 23:44 4,277,659 Credit scoring project-checkpoint.ipynb 25/10/2022 22:58 789 service.py 26/10/2022 08:26 <DIR> pycache 5 File(s) 4,279,253 bytes 3 Dir(s) 405,480,062,976 bytes free
m
I took a while! I used your code to build docker successfully.
And there is the problem, you have
bentoml
and
bentos
directory in the project folder, they were meant to be in the home directory by default in the first place and that's why you are having all these issues. Did you change bentoml path and tried anything different?
One solution could be deleting those
bentoml
and
bento.odt
directories, then build and containerize again. If that doesn't work then you'll have to start with the clean slate by creating new project folder and make sure everything related to bentoml environment and path stays default.
y
so yes, I had models, service.py, and yaml in the home directory and I could not even create the bento. Then I moved them to my project folder.
m
I suggest start with the new project folder, create new environment, put service.py and bentofile.yaml in that new project folder then let the
bentoml
do the rest. Every time we run
bentoml
command in the terminal, it generates bentoml directory in the home directory by default and bento needs to see that folder to interact.
There is nothing wrong with the script or with yaml file, it's just our execution is wrong.
y
yeah, created a new folder, new bento and again while containerizing it showed same error
m
Is the bento folder in your project directory?