Repository: bentoml/BentoML

Issue:
bug:  module 'bentoml' has no attribute 'build'
### Describe the bug

Inside  'https://github.com/bentoml/BentoML/tree/main/src/bentoml/bentos.py' you  find down in

def build

the following comment: 

"""
User-facing API for building a Bento. The available build options are identical to the keys of a
    valid 'bentofile.yaml' file.

    This API will not respect any 'bentofile.yaml' files. Build options should instead be provided
    via function call parameters.

    Args:
        service: import str for finding the bentoml.Service instance build target
        labels: optional immutable labels for carrying contextual info
        description: optional description string in markdown format
        include: list of file paths and patterns specifying files to include in Bento,
                 default is all files under build_ctx, beside the ones excluded from the
                 exclude parameter or a :code:`.bentoignore` file for a given directory
        exclude: list of file paths and patterns to exclude from the final Bento archive
        docker: dictionary for configuring Bento's containerization process, see details
                in :class:`bentoml._internal.bento.build_config.DockerOptions`
        python: dictionary for configuring Bento's python dependencies, see details in
                :class:`bentoml._internal.bento.build_config.PythonOptions`
        conda: dictionary for configuring Bento's conda dependencies, see details in
               :class:`bentoml._internal.bento.build_config.CondaOptions`
        version: Override the default auto generated version str
        build_ctx: Build context directory, when used as
        _bento_store: save Bento created to this BentoStore

    Returns:
        Bento: a Bento instance representing the materialized Bento saved in BentoStore

    Example:

        .. code-block::

           import bentoml

           bentoml.build(
               service="fraud_detector.py:svc",
               version="any_version_label",  # override default version generator
               description=open("README.md").read(),
               include=['*'],
               exclude=[], # files to exclude can also be specified with a .bentoignore file
               labels={
                   "foo": "bar",
                   "team": "abc"
               },
               python=dict(
                   packages=["tensorflow", "numpy"],
                   # requirements_txt="./requirements.txt",
                   index_url="http://<api token>:@mycompany.com/pypi/simple",
                   trusted_host=["mycompany.com"],
                   find_links=['thirdparty..'],
                   extra_index_url=["..."],
                   pip_args="ANY ADDITIONAL PIP INSTALL ARGS",
                   wheels=["./wheels/*"],
                   lock_packages=True,
               ),
               docker=dict(
                   distro="amazonlinux2",
                   setup_script="setup_docker_container.sh",
                   python_version="3.8",
               ),
           )

    """

When I use the this code I'm getting the error:

bug:  module 'bentoml' has no attribute 'build'



### To reproduce

_No response_

### Expected behavior

a bento builded

### Environment

bentoml: 1.2.12
python: 3.10
___________________

#### Environment variable

```bash
BENTOML_DEBUG=''
BENTOML_QUIET=''
BENTOML_BUNDLE_LOCAL_BUILD=''
BENTOML_DO_NOT_TRACK=''
BENTOML_CONFIG=''
BENTOML_CONFIG_OPTIONS=''
BENTOML_PORT=''
BENTOML_HOST=''
BENTOML_API_WORKERS=''
```

#### System information

`bentoml`: 1.2.12
`python`: 3.10.13
`platform`: Linux-5.15.0-1057-azure-x86_64-with-glibc2.31
`uid_gid`: 1004:1004
`conda`: 24.1.2
`in_conda_env`: True
<details><summary><code>conda_packages</code></summary>

<br>

```yaml
name: py310
channels:
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - asttokens=2.0.5=pyhd3eb1b0_0
  - bzip2=1.0.8=h5eee18b_5
  - ca-certificates=2024.3.11=h06a4308_0
  - comm=0.2.1=py310h06a4308_0
  - debugpy=1.6.7=py310h6a678d5_0
  - decorator=5.1.1=pyhd3eb1b0_0
  - exceptiongroup=1.2.0=py310h06a4308_0
  - executing=0.8.3=pyhd3eb1b0_0
  - ipykernel=6.28.0=py310h06a4308_0
  - ipython=8.20.0=py310h06a4308_0
  - jedi=0.18.1=py310h06a4308_1
  - jupyter_client=8.6.0=py310h06a4308_0
  - jupyter_core=5.5.0=py310h06a4308_0
  - ld_impl_linux-64=2.38=h1181459_1
  - libffi=3.4.4=h6a678d5_0
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libsodium=1.0.18=h7b6447c_0
  - libstdcxx-ng=11.2.0=h1234567_1
  - libuuid=1.41.5=h5eee18b_0
  - matplotlib-inline=0.1.6=py310h06a4308_0
  - ncurses=6.4=h6a678d5_0
  - nest-asyncio=1.6.0=py310h06a4308_0
  - openssl=3.0.13=h7f8727e_0
  - packaging=23.2=py310h06a4308_0
  - parso=0.8.3=pyhd3eb1b0_0
  - pexpect=4.8.0=pyhd3eb1b0_3
  - pip=23.3.1=py310h06a4308_0
  - platformdirs=3.10.0=py310h06a4308_0
  - prompt-toolkit=3.0.43=py310h06a4308_0
  - prompt_toolkit=3.0.43=hd3eb1b0_0
  - psutil=5.9.0=py310h5eee18b_0
  - ptyprocess=0.7.0=pyhd3eb1b0_2
  - pure_eval=0.2.2=pyhd3eb1b0_0
  - pygments=2.15.1=py310h06a4308_1
  - python=3.10.13=h955ad1f_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - pyzmq=25.1.2=py310h6a678d5_0
  - readline=8.2=h5eee18b_0
  - setuptools=68.2.2=py310h06a4308_0
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.41.2=h5eee18b_0
  - stack_data=0.2.0=pyhd3eb1b0_0
  - tk=8.6.12=h1ccaba5_0
  - tornado=6.3.3=py310h5eee18b_0
  - traitlets=5.7.1=py310h06a4308_0
  - tzdata=2024a=h04d1e81_0
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - wheel=0.41.2=py310h06a4308_0
  - xz=5.4.6=h5eee18b_0
  - zeromq=4.3.5=h6a678d5_0
  - zlib=1.2.13=h5eee18b_0
prefix: /opt/conda/envs/py310
```

</details>

<details><summary><code>pip_packages</code></summary>

<br>

```
accelerate==0.28.0
aiofiles==23.2.1
aiohttp==3.9.3
aiosignal==1.3.1
alembic==1.13.1
altair==5.2.0
annotated-types==0.6.0
antlr4-python3-runtime==4.9.3
anyio==4.3.0
appdirs==1.4.4
asgiref==3.8.0
asteroid-filterbanks==0.4.0
asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work
async-timeout==4.0.3
attrs==23.2.0
audio2numpy==0.1.2
audioread==3.0.1
auto_gptq==0.7.1
av==11.0.0
backoff==2.2.1
beautifulsoup4==4.12.3
bentoml==1.2.12
bitsandbytes==0.41.3.post2
blinker==1.7.0
boto3==1.34.67
botocore==1.34.67
bs4==0.0.2
build==0.10.0
cachetools==5.3.3
cattrs==23.1.2
certifi==2024.2.2
cffi==1.16.0
chardet==5.2.0
charset-normalizer==3.3.2
circus==0.18.0
click==8.1.7
click-option-group==0.5.6
cloudpickle==3.0.0
colorama==0.4.6
coloredlogs==15.0.1
colorlog==6.8.2
comm @ file:///croot/comm_1709322850197/work
contextlib2==21.6.0
contourpy==1.2.0
cryptography==42.0.5
ctranslate2==4.1.0
cuda-python==12.4.0
cupy-cuda12x==12.1.0
cycler==0.12.1
dataclasses-json==0.6.4
datasets==2.18.0
debugpy @ file:///croot/debugpy_1690905042057/work
decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work
deepmerge==1.1.1
Deprecated==1.2.14
deprecation==2.1.0
diffusers==0.27.2
dill==0.3.8
dirtyjson==1.0.8
diskcache==5.6.3
distlib==0.3.8
distro==1.9.0
docker==7.0.0
docopt==0.6.2
einops==0.7.0
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
executing @ file:///opt/conda/conda-bld/executing_1646925071911/work
fastapi==0.110.0
fastcore==1.5.29
faster-whisper==1.0.0
fastrlock==0.8.2
ffmpeg==1.4
ffmpy==0.3.2
filelock==3.13.1
filetype==1.2.0
flash-attn==2.5.7
flatbuffers==24.3.25
fonttools==4.50.0
frozenlist==1.4.1
fs==2.4.16
fs-s3fs==1.1.1
fsspec==2024.2.0
ftfy==6.2.0
gekko==1.0.7
germansentiment==1.1.0
ghapi==1.0.4
gitdb==4.0.11
GitPython==3.1.42
googleapis-common-protos==1.56.2
gradio==4.22.0
gradio_client==0.13.0
greenlet==3.0.3
grpcio==1.62.1
grpcio-channelz==1.48.2
grpcio-health-checking==1.48.2
grpcio-reflection==1.48.2
h11==0.14.0
httpcore==1.0.4
httptools==0.6.1
httpx==0.27.0
huggingface-hub==0.22.2
humanfriendly==10.0
HyperPyYAML==1.2.2
idna==3.6
img2pdf==0.5.1
importlib-metadata==6.11.0
importlib_resources==6.4.0
inflection==0.5.1
interegular==0.3.3
ipykernel @ file:///croot/ipykernel_1705933831282/work
ipython @ file:///croot/ipython_1704833016303/work
jedi @ file:///tmp/build/80754af9/jedi_1644315229345/work
Jinja2==3.1.3
jmespath==1.0.1
joblib==1.3.2
jsonpatch==1.33
jsonpointer==2.4
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
julius==0.2.7
jupyter_client @ file:///croot/jupyter_client_1699455897726/work
jupyter_core @ file:///croot/jupyter_core_1698937308754/work
keybert==0.8.4
kiwisolver==1.4.5
langchain==0.1.13
langchain-community==0.0.29
langchain-core==0.1.33
langchain-text-splitters==0.0.1
langsmith==0.1.31
lark==1.1.9
lazy_loader==0.3
librosa==0.10.1
lightning==2.2.1
lightning-utilities==0.11.2
linkify-it-py==2.0.3
llama-index==0.10.22
llama-index-agent-openai==0.1.6
llama-index-cli==0.1.11
llama-index-core==0.10.22
llama-index-embeddings-huggingface==0.1.4
llama-index-embeddings-openai==0.1.7
llama-index-indices-managed-llama-cloud==0.1.4
llama-index-legacy==0.9.48
llama-index-llms-openai==0.1.12
llama-index-llms-openllm==0.1.3
llama-index-multi-modal-llms-openai==0.1.4
llama-index-program-openai==0.1.4
llama-index-question-gen-openai==0.1.3
llama-index-readers-file==0.1.11
llama-index-readers-llama-parse==0.1.3
llama-parse==0.3.9
llamaindex-py-client==0.1.13
llvmlite==0.42.0
lxml==5.1.0
Mako==1.3.2
markdown-it-py==2.2.0
marker-pdf==0.1.3
MarkupSafe==2.1.5
marshmallow==3.21.1
matplotlib==3.8.3
matplotlib-inline @ file:///opt/conda/conda-bld/matplotlib-inline_1662014470464/work
mdit-py-plugins==0.3.3
mdurl==0.1.2
more-itertools==10.2.0
mpmath==1.3.0
msgpack==1.0.8
multidict==6.0.5
multiprocess==0.70.16
mypy-extensions==1.0.0
nest-asyncio @ file:///croot/nest-asyncio_1708532673751/work
networkx==3.2.1
ninja==1.11.1.1
nltk==3.8.1
numba==0.59.1
numpy==1.26.4
nvidia-cublas-cu12==12.1.3.1
nvidia-cuda-cupti-cu12==12.1.105
nvidia-cuda-nvrtc-cu12==12.1.105
nvidia-cuda-runtime-cu12==12.1.105
nvidia-cudnn-cu12==8.9.2.26
nvidia-cufft-cu12==11.0.2.54
nvidia-curand-cu12==10.3.2.106
nvidia-cusolver-cu12==11.4.5.107
nvidia-cusparse-cu12==12.1.0.106
nvidia-ml-py==11.525.150
nvidia-nccl-cu12==2.18.1
nvidia-nvjitlink-cu12==12.4.99
nvidia-nvtx-cu12==12.1.105
ocrmypdf==15.4.4
omegaconf==2.3.0
onnxruntime==1.17.1
openai==1.14.2
openai-whisper==20231117
openllm-client==0.4.44
openllm-core==0.4.44
opentelemetry-api==1.20.0
opentelemetry-exporter-jaeger==1.20.0
opentelemetry-exporter-jaeger-proto-grpc==1.20.0
opentelemetry-exporter-jaeger-thrift==1.20.0
opentelemetry-exporter-otlp==1.20.0
opentelemetry-exporter-otlp-proto-common==1.20.0
opentelemetry-exporter-otlp-proto-grpc==1.20.0
opentelemetry-exporter-otlp-proto-http==1.20.0
opentelemetry-exporter-zipkin==1.20.0
opentelemetry-exporter-zipkin-json==1.20.0
opentelemetry-exporter-zipkin-proto-http==1.20.0
opentelemetry-instrumentation==0.41b0
opentelemetry-instrumentation-aiohttp-client==0.41b0
opentelemetry-instrumentation-asgi==0.41b0
opentelemetry-instrumentation-grpc==0.41b0
opentelemetry-proto==1.20.0
opentelemetry-sdk==1.20.0
opentelemetry-semantic-conventions==0.41b0
opentelemetry-util-http==0.41b0
optimum==1.17.1
optuna==3.6.1
orjson==3.9.15
outlines==0.0.36
packaging @ file:///croot/packaging_1710807400464/work
pandas==2.2.1
parso @ file:///opt/conda/conda-bld/parso_1641458642106/work
pathspec==0.12.1
pdfminer.six==20231228
peft==0.9.0
pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work
pikepdf==8.14.0
pillow==10.2.0
pip-requirements-parser==32.0.1
pip-tools==7.3.0
platformdirs @ file:///croot/platformdirs_1692205439124/work
pluggy==1.4.0
pooch==1.8.1
primePy==1.3
prometheus_client==0.20.0
prompt-toolkit @ file:///croot/prompt-toolkit_1704404351921/work
protobuf==3.20.3
psutil @ file:///opt/conda/conda-bld/psutil_1656431268089/work
ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work
pyannote.audio==3.1.1
pyannote.core==5.0.0
pyannote.database==5.0.1
pyannote.metrics==3.2.1
pyannote.pipeline==3.0.1
pyarrow==15.0.2
pyarrow-hotfix==0.6
pycparser==2.21
pydantic==2.6.4
pydantic-settings==2.2.1
pydantic_core==2.16.3
pydeck==0.8.1b0
pydub==0.25.1
Pygments @ file:///croot/pygments_1684279966437/work
PyMuPDF==1.24.0
pymupdf-fonts==1.0.5
PyMuPDFb==1.24.0
pynvml==11.5.0
pyparsing==3.1.2
pypdf==4.1.0
pypdfium2==4.28.0
pyproject_hooks==1.0.0
pyspellchecker==0.7.3
pytesseract==0.3.10
python-dateutil @ file:///tmp/build/80754af9/python-dateutil_1626374649649/work
python-dotenv==1.0.1
python-json-logger==2.0.7
python-magic==0.4.27
python-multipart==0.0.9
pytorch-lightning==2.2.1
pytorch-metric-learning==2.5.0
pytz==2024.1
PyYAML==6.0.1
pyzmq @ file:///croot/pyzmq_1705605076900/work
rapidfuzz==3.7.0
ray==2.10.0
referencing==0.34.0
regex==2023.12.25
reportlab==4.1.0
requests==2.31.0
rich==13.7.1
rouge==1.0.1
rpds-py==0.18.0
ruamel.yaml==0.18.6
ruamel.yaml.clib==0.2.8
ruff==0.3.4
s3transfer==0.10.1
safetensors==0.4.2
schema==0.7.5
scikit-learn==1.4.1.post1
scipy==1.12.0
semantic-version==2.10.0
semver==3.0.2
sentence-transformers==2.6.1
sentencepiece==0.2.0
shellingham==1.5.4
simple-di==0.1.5
six @ file:///tmp/build/80754af9/six_1644875935023/work
smmap==5.0.1
sniffio==1.3.1
sortedcontainers==2.4.0
soundfile==0.12.1
soupsieve==2.5
soxr==0.3.7
speechbrain==1.0.0
SQLAlchemy==2.0.28
stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work
starlette==0.36.3
streamlit==1.32.2
streamlit-drawable-canvas-jsretry==0.9.3
striprtf==0.0.26
sympy==1.12
tabulate==0.9.0
tenacity==8.2.3
tensorboardX==2.6.2.2
texify==0.1.8
thefuzz==0.20.0
threadpoolctl==3.4.0
thrift==0.16.0
tiktoken==0.6.0
tokenizers==0.15.2
toml==0.10.2
tomli==2.0.1
tomli_w==1.0.0
tomlkit==0.12.0
toolz==0.12.1
torch==2.1.2
torch-audiomentations==0.11.1
torch-pitch-shift==1.2.4
torchaudio==2.1.2
torchmetrics==1.3.2
tornado @ file:///croot/tornado_1696936946304/work
tqdm==4.66.2
traitlets @ file:///croot/traitlets_1671143879854/work
transformers==4.39.0
triton==2.1.0
typer==0.9.0
typing-inspect==0.9.0
typing_extensions==4.10.0
tzdata==2024.1
uc-micro-py==1.0.3
urllib3==2.2.1
uvicorn==0.29.0
uvloop==0.19.0
virtualenv==20.25.1
vllm==0.3.3
watchdog==3.0.0
watchfiles==0.21.0
wcwidth==0.2.13
websockets==11.0.3
wget==3.2
whisperx @ git+https://github.com/m-bain/whisperx.git@f2da2f858e99e4211fe4f64b5f2938b007827e17
wrapt==1.16.0
xformers==0.0.23.post1
xxhash==3.4.1
yarl==1.9.4
zipp==3.18.1
```

</details>


Discussion:
import from `bentoml.bentos.build`

We will decide if we are to expose this function.
It would be helpful to be able to make this call directly. In order to have an automated deployment

Resolving patch:
diff --git a/src/bentoml/__init__.py b/src/bentoml/__init__.py
--- a/src/bentoml/__init__.py
+++ b/src/bentoml/__init__.py
@@ -44,6 +44,7 @@
 from ._internal.utils.http import Cookie
 
 # Bento management APIs
+from .bentos import build
 from .bentos import delete
 from .bentos import export_bento
 from .bentos import get
@@ -234,6 +235,7 @@ def __getattr__(name: str) -> Any:
     "delete",
     "import_bento",
     "export_bento",
+    "build",
     "load",
     "push",
     "pull",


Test patch: