bentoml / BentoML

The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
https://bentoml.com
Apache License 2.0
7.17k stars 792 forks source link

Version and init files not packaged in the service repository #1889

Closed marcindulak closed 2 years ago

marcindulak commented 3 years ago

Describe the bug

The __init__.py file is empty and _version.py file missing in the service repository. The behavior depends on the location of the service export export_service.py script.

To Reproduce

Steps to reproduce the issue:

  1. Clone the example mypackage
    git clone https://github.com/marcindulak/bentoml-missing-version-import
  2. Install mypackage
    deactivate
    rm -rf /tmp/venv
    python3 -m venv /tmp/venv
    . /tmp/venv/bin/activate
    pip install ./bentoml-missing-version-import
  3. Create BentoML service from the location where mypackage cannot be imported from the current working directory
    cd bentoml-missing-version-import
    mv export_service.py
    cd ..
    python export_service.py
  4. The __init__.py and _version.py are missing:
    ls $(bentoml get Service:latest --print-location --quiet)/Service/mypackage
    # __init__.py  service.py

Expected behavior

The __init__.py and _version.py are created:

ls $(bentoml get Service:latest --print-location --quiet)/Service/mypackage
# __init__.py  service.py  _version.py

This is the case when export_service.py resides in the ./bentoml-missing-version-import directory.

cd bentoml-missing-version-import
python export_service.py

Screenshots/Logs

Environment:

Additional context

The issue looks related to other issues listed in https://github.com/bentoml/BentoML/issues/1621#issuecomment-840513959

parano commented 2 years ago

Thank you for the feedback @marcindulak - this issue should be fixed now in BentoML version 1.0, where user can specify arbitrary files to be included in the Bento, via a bentofile.yaml file. Here's an example build file:

service: "iris_classifier:svc"
description: "file: ./readme.md"
labels:
  foo: bar
  team: abc
include:
- "*.py"
- "*.json"
exclude: 
- "*.pyc"

See 1.0 documentation to learn more: https://docs.bentoml.org/en/latest/