liveBook · Manning

Bentofile.yaml

As explained in Machine Learning Platform Engineering

A bentofile.yaml file is a declarative BentoML configuration file specifying a service, included files, dependencies, labels, and environment variables for building a Bento.

bentofile.yaml is the declarative build configuration for a BentoML service. It identifies the service entry point, packages application files and dependencies, and supplies container environment variables for reproducible deployment. section 6.1.1 section 10.5

Configure the build around the components that must travel with the service:

  • Set service to the Python module and service object, such as service: "service:svc". section 6.1.1
  • Add labels for ownership or other build metadata. section 6.1.1
  • Include service code, environment files, source modules, model artifacts, and requirements files. section 6.1.1 section 10.5
  • Declare Python dependencies through requirements_txt and configure Docker environment variables or a base image. section 6.1.1 section 10.5

Packaging an income-classification service

A configuration can bind service:svc, include service.py, production.env, src/*.py, requirements.txt, and *.env, install requirements.txt, and inject local AWS credentials and ENV_NAME values. Running bentoml build creates a versioned Bento that can then be containerized or pushed to BentoCloud. section 6.1.1 section 10.5

Listing 6.4 bentofile.yaml to package our application
service: "service:svc"
labels:
  owner: ml-engineering-team
include:
  - "service.py"
  - "production.env"
  - "src/*.py"
  - "requirements.txt"
  - "*.env"
python:
  requirements_txt: requirements.txt
docker:
  env:
    - ENV_NAME=local
    - AWS_ACCESS_KEY_ID=minio
    - AWS_SECRET_ACCESS_KEY=minio123

Inspect the complete bentofile.yaml listing, including service binding, file inclusion, Python requirements, labels, and Docker environment variables. section 6.1.1

How Machine Learning Platform Engineering covers it

How deep it goes
Explains core YAML fields and their deployment role, but does not provide an exhaustive configuration schema.
Examples
Uses an income classifier with Python modules, environment files, requirements.txt, Docker variables, and a YOLOv8 custom base image.
What it assumes
Assumes a defined BentoML service and its dependencies, while showing the packaging configuration needed to deploy them.
What you can do after
Operate/configure BentoML builds that package a service, generate a versioned Bento, containerize it, and deploy it across environments.
How it connects
Connects BentoML services with Docker containerization, MLflow models, Yatai, BentoCloud, and Prometheus observability.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.