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

Bundle / development package import #1621

Closed iakremnev closed 2 years ago

iakremnev commented 3 years ago

Describe the bug

Required modules from the local development package are not imported to the service bundle when packing a service with artifacts.

To Reproduce

  1. Clone https://github.com/iakremnev/bentoml-issue-example
  2. Make virtual environment and install local package in development mode:
    python -m venv venv
    source venv/bin/activate
    pip install -e .
  3. Pack the service:
    python export_service.py
  4. Try and run the service:
    bentoml serve Service:latest

As a result, the service can't import mypackage.model since model.py is not bundled.

Expected behavior

Code for model class definition and any preprocessing is bundled with the service.

Environment:

Additional context

iakremnev commented 3 years ago

I've seen this and related issues mentioned quite a few times #1410, #608, in slack . The suggested workaround is to import all the required modules in the module with BentoService class definition. So it's rather a feature suggestion, than a bug report: trace required modules for the artifact that is packed.

yubozhao commented 3 years ago

@iakremnev Thank you for the reproducible repo! We are working on new user facing APIs that will make it a lot easier for users to include files

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

parano commented 2 years ago

This issues has been resolved in the upcoming BentoML 1.0 release.

In BentoML 1.0, a project root must be specifically defined by placing a bentofile.yaml file in the directory. This file specifies all the Bento build configs, including what are the files to include in the final Bento built. The project root also should be seen as the CWD in your service's python environment, as well as part of the import path in sys.path. A more detailed explanation can be found here: https://github.com/bentoml/BentoML/tree/main/bentoml/_internal/bento