Hey. BentoML 1.2.5 isn't locking my Python depende...
# ask-for-help
f
Hey. BentoML 1.2.5 isn't locking my Python dependencies correctly. I have the following `bentoml.yaml`:
Copy code
service: "src.api.bert_classifier.api:svc"
labels:
  owner: delta
  project: event-tagging-svc
include:
  - "src/**/*.py"
  - "src/**/*.yaml"
  - "src/**/*.sh"
python:
  packages:
    - bentoml
    - torch
    - pytorch-lightning
    - torchmetrics
    - transformers
    - pydantic<2
    - dotmap
    - nltk
    - numpy
    - pandas
    - scikit-learn
    - beautifulsoup4
    - lxml
  extra_index_url:
    - "<https://download.pytorch.org/whl/cu118>"
docker:
  base_image: "<http://gcr.io/klue-1265/cuda-miniconda3:cuda119|gcr.io/klue-1265/cuda-miniconda3:cuda119>"
  setup_script: "src/api/bert_classifier/setup.sh"
And I have use
pipenv
to deal with my dependencies. My environment has
transformers = "==4.27.3"
, for example, but the generated
requirements.lock.txt
contains
transformers==4.38.2
. I'm building it with:
Copy code
pipenv run bentoml build -f src/api/bert_classifier/bentofile.yaml
So, I'm sure it's using the correct environment during the build.
c
Might be an issue with pipenv and BentoML interaction, were you able to do it this way with older versions of BentoML? We didn’t make any changes there recently
f
I was reading the code and noticed that you guys use
piptools compile
. After further investigation, it seems they're not compatible with pipenv.
This project seems to expect a
pyproject.toml
file to exist, while pipenv uses
Pipfile
instead.
I needed to generate the requirements.txt using pipenv and then pass it directly through
bentofile.yaml
.
👍 1
d
Hi Fernando, sorry for messaging you directly. I’m new to bentoml and I’m trying to build a bento with python dependencies using the following config. But when I did
bentoml build
, the resulting bento is very small (~20KB) and apparently it does not have the dependencies. It seems you were able to build bentos with dependencies included. Could you share how you did it? Was it simply configure a bentofile.yaml with dependencies and run `bentoml build`…? Thanks!
Copy code
python:
  packages:
  - bentoml
  - open_clip_torch
  - opencv-python
c
@Fernando Camargo yes if you’re already using pipenv to manage your dependency versions, I’d recommend putting the generated requirements.txt directly in bentofile.yaml and set lock_packages to false so BentoML won’t try to pin dependencies again
@dhan it is expected that bento built is small even if you have large dependencies specified - Bento doesn’t include all the dependency files but lock their dependency versions so during deployment time it will pull down the exact versions. The only exception would be when you specify a custom local wheel file as its dependency, in that case the wheel file will be bundled into the bento
d
What does “during deployment time” mean…? If I want to use bentoml as a library and use Ah ok got it. But if I wanted to use
bentoml.batch.run_in_spark
, how do I make sure Spark workers have the required dependencies?
c
In the case of spark, if you want to run Bento in-place on the spark workers, currently users will need to ensure the libraries are installed themselves
We’ve been advising customers to deploy serverless deployment on BentoCloud and then use BentoML generated python client in their spark UDF to do batch processing . That way you don’t need to couple bento dependencies with your spark environemnt
d
Ok sounds like the only way to decouple client logic from server dependencies is to use BentoCloud?
c
Using BentoCloud would definitely be easier to setup. It is possible to deploy OSS BentoML to your own infrastructure and connect to it in your spark job a well. You may need to manually manage the deployment lifecycle to match your batch jobs’ cadence as well as doing autoscaling
d
Ok got it, thank you so much Chaoyu. Sorry for hijacking your thread Fernando.