Skip to content

Commit

Permalink
merge: remote-tracking branch 'upstream/main' into feat/grpc-client
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron <[email protected]>
  • Loading branch information
aarnphm committed Feb 23, 2023
2 parents b3184eb + e5af0c3 commit 8a6ba60
Show file tree
Hide file tree
Showing 144 changed files with 14,357 additions and 1,085 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
LINES: 120
COLUMNS: 120
BENTOML_DO_NOT_TRACK: True
PYTEST_PLUGINS: bentoml.testing.pytest.plugin

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
Expand Down Expand Up @@ -83,7 +84,7 @@ jobs:
run: |
npm install -g npm@^7 pyright
- name: Setup bufbuild/buf
uses: bufbuild/buf-setup-action@v1.12.0
uses: bufbuild/buf-setup-action@v1.14.0
with:
github_token: ${{ github.token }}

Expand All @@ -105,9 +106,10 @@ jobs:
black --check --pyi typings
isort --check .
- name: Lint check
run: git diff --name-only --diff-filter=d "origin/$GITHUB_BASE_REF" -z -- '*.py' | xargs -0 --no-run-if-empty pylint --rcfile pyproject.toml --fail-under 9.0 --exit-zero
run: ruff check src tests examples
- name: Type check
run: git diff --name-only --diff-filter=d "origin/$GITHUB_BASE_REF" -z -- '*.py[i]' | xargs -0 --no-run-if-empty pyright
if: ${{ github.event_name == 'pull_request' }}
run: git diff --name-only --diff-filter=AM "origin/$GITHUB_BASE_REF" -z -- '*.py{,i}' | xargs -0 --no-run-if-empty pyright
- name: Proto check
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.protos == 'true') || github.event_name == 'push' }}
run: |
Expand Down
104 changes: 104 additions & 0 deletions .github/workflows/frameworks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
LINES: 120
COLUMNS: 120
BENTOML_DO_NOT_TRACK: True
PYTEST_PLUGINS: bentoml.testing.pytest.plugin

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun
defaults:
Expand All @@ -23,6 +24,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
catboost: ${{ steps.filter.outputs.catboost }}
diffusers: ${{ steps.filter.outputs.diffusers }}
fastai: ${{ steps.filter.outputs.fastai }}
keras: ${{ steps.filter.outputs.keras }}
lightgbm: ${{ steps.filter.outputs.lightgbm }}
Expand All @@ -32,6 +34,7 @@ jobs:
pytorch: ${{ steps.filter.outputs.pytorch }}
pytorch_lightning: ${{ steps.filter.outputs.pytorch_lightning }}
sklearn: ${{ steps.filter.outputs.sklearn }}
flax: ${{ steps.filter.outputs.flax }}
tensorflow: ${{ steps.filter.outputs.tensorflow }}
torchscript: ${{ steps.filter.outputs.torchscript }}
transformers: ${{ steps.filter.outputs.transformers }}
Expand All @@ -56,6 +59,11 @@ jobs:
- src/bentoml/catboost.py
- src/bentoml/_internal/frameworks/catboost.py
- tests/integration/frameworks/models/catboost.py
diffusers:
- *related
- src/bentoml/diffusers.py
- src/bentoml/_internal/frameworks/diffusers.py
- tests/integration/frameworks/models/diffusers.py
lightgbm:
- *related
- src/bentoml/lightgbm.py
Expand Down Expand Up @@ -88,6 +96,12 @@ jobs:
- src/bentoml/_internal/frameworks/pytorch.py
- src/bentoml/_internal/frameworks/common/pytorch.py
- tests/integration/frameworks/test_pytorch_unit.py
flax:
- *related
- src/bentoml/flax.py
- src/bentoml/_internal/frameworks/flax.py
- src/bentoml/_internal/frameworks/common/jax.py
- tests/integration/frameworks/models/flax.py
torchscript:
- *related
- src/bentoml/torchscript.py
Expand Down Expand Up @@ -173,6 +187,96 @@ jobs:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

diffusers_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.diffusers == 'true') || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Get pip cache dir
id: cache-dir
run: |
echo ::set-output name=dir::$(pip cache dir)
- name: Cache pip dependencies
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ steps.cache-dir.outputs.dir }}
key: ${{ runner.os }}-tests-${{ hashFiles('requirements/tests-requirements.txt') }}

- name: Install dependencies
run: |
pip install .
pip install diffusers torch transformers
pip install -r requirements/tests-requirements.txt
- name: Run tests and generate coverage report
run: |
OPTS=(--cov-config pyproject.toml --cov src/bentoml --cov-append --framework diffusers)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
- name: Generate coverage
run: coverage xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

flax_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.flax == 'true') || github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Get pip cache dir
id: cache-dir
run: |
echo ::set-output name=dir::$(pip cache dir)
- name: Cache pip dependencies
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ steps.cache-dir.outputs.dir }}
key: ${{ runner.os }}-tests-${{ hashFiles('requirements/tests-requirements.txt') }}

- name: Install dependencies
run: |
pip install .
pip install flax jax jaxlib chex tensorflow
pip install -r requirements/tests-requirements.txt
- name: Run tests and generate coverage report
run: |
OPTS=(--cov-config pyproject.toml --cov src/bentoml --cov-append --framework flax)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
- name: Generate coverage
run: coverage xml

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}

fastai_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.fastai == 'true') || github.event_name == 'push' }}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ tests/integration/data
# setuptools_scm generated version file
typings
**/*/_version.py
typings

# test files
catboost_info
Expand Down
4 changes: 0 additions & 4 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,3 @@ python:
- requirements: requirements/docs-requirements.txt
- method: pip
path: .

formats:
- epub
- pdf
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bentoml get IrisClassifier --verbose
formatter: [black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort), [buf](https://github.com/bufbuild/buf)
linter: [pylint](https://pylint.org/), [buf](https://github.com/bufbuild/buf)
linter: [ruff](https://github.com/charliermarsh/ruff), [buf](https://github.com/bufbuild/buf)
type checker: [pyright](https://github.com/microsoft/pyright)
Expand Down
14 changes: 6 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ format: ## Running code formatter: black and isort
@echo "(black) Formatting stubs..."
@find src -name "*.pyi" ! -name "*_pb2*" -exec black --pyi --config pyproject.toml {} \;
@echo "(isort) Reordering imports..."
isort .
@isort .
@echo "(ruff) Running fix only..."
@ruff check src examples tests --fix-only
format-proto: ## Running proto formatter: buf
@echo "Formatting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf format --config "/workspace/bentoml/grpc/buf.yaml" -w bentoml/grpc
lint: ## Running lint checker: pylint
@echo "(pylint) Linting bentoml..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 src
@echo "(pylint) Linting examples..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 examples
@echo "(pylint) Linting tests..."
@pylint --rcfile=pyproject.toml --fail-under 9.5 tests
lint: ## Running lint checker: ruff
@echo "(ruff) Linting development project..."
@ruff check src examples tests
lint-proto: ## Running proto lint checker: buf
@echo "Linting proto files..."
docker run --init --rm --volume $(GIT_ROOT)/src:/workspace --workdir /workspace bufbuild/buf lint --config "/workspace/bentoml/grpc/buf.yaml" --error-format msvs bentoml/grpc
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ BentoML makes it easy to create Machine Learning services that are ready to depl

👉 [Join our Slack community today!](https://l.bentoml.com/join-slack)

✨ Looking deploy your ML service quickly? Checkout [BentoML Cloud](https://www.bentoml.com/bentoml-cloud/)
✨ Looking deploy your ML service quickly? Checkout [BentoML Cloud](https://l.bentoml.com/bento-cloud)
for the easiest and fastest way to deploy your bento.

## Getting Started
Expand Down Expand Up @@ -53,7 +53,7 @@ for the easiest and fastest way to deploy your bento.
🎯 Deploy anywhere in a **DevOps-friendly** way

- Streamline production deployment workflow via:
- [☁️ BentoML Cloud](https://www.bentoml.com/bentoml-cloud/): the fastest way to deploy your bento, simple and at scale
- [☁️ BentoML Cloud](https://l.bentoml.com/bento-cloud): the fastest way to deploy your bento, simple and at scale
- [🦄️ Yatai](https://github.com/bentoml/yatai): Model Deployment at scale on Kubernetes
- [🚀 bentoctl](https://github.com/bentoml/bentoctl): Fast model deployment on AWS SageMaker, Lambda, ECE, GCP, Azure, Heroku, and more!
- Run offline batch inference jobs with Spark or Dask
Expand Down
4 changes: 4 additions & 0 deletions docs/source/_static/examples/batch/input.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
5.4, 2.9, 3.2, 1.5
4.8, 3.1, 1.4, 0.1
6.4, 2.8, 5.2, 2.0
4.1, 3. , 1. , 0.1
2 changes: 1 addition & 1 deletion docs/source/concepts/runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ analysis with a pre-trained model:

.. note::

Full code example can be found :github:`here <tree/main/examples/custom_runner/nltk_pretrained_model>`_.
Full code example can be found :github:`here <bentoml/BentoML/tree/main/examples/custom_runner/nltk_pretrained_model>`.


The constant attribute ``SUPPORTED_RESOURCES`` indicates which resources this Runnable class
Expand Down
2 changes: 1 addition & 1 deletion docs/source/frameworks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ The following frameworks are supported in pre-1.0 BentoML versions and are being
keras
lightgbm
onnx
picklable_model
picklable
pytorch
pytorch_lightning
sklearn
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ When using HTTP API server, BentoML will parse all of the available fields direc
.. dropdown:: `Expands for default configuration`
:icon: code
.. literalinclude:: ../../../bentoml/_internal/configuration/v1/default_configuration.yaml
.. literalinclude:: ../../../src/bentoml/_internal/configuration/v1/default_configuration.yaml
:language: yaml
.. [#prometheus_default_bucket] The default buckets is specified `here <https://github.com/prometheus/client_python/blob/f17a8361ad3ed5bc47f193ac03b00911120a8d81/prometheus_client/metrics.py#L544>`_ for Python client.
Expand Down
50 changes: 50 additions & 0 deletions docs/source/guides/envmanager.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
===================
Environment Manager
===================

:bdg-info:`Note:` This feature is currently only supported on UNIX/MacOS.

Environment manager is a utility that helps create an isolated environment to
run the BentoML CLI. Dependencies are pulled from your defined
``bentofile.yaml`` and the environment is built upon request. This means by
passing ``--env`` to supported CLI commands (such as :ref:`bentoml serve
<reference/cli:serve>`), such commands will then be run in an sandbox
environment that mimics the behaviour during production.

.. code-block:: bash
» bentoml serve --env conda iris_classifier:latest
This creates and isolated conda environment from the dependencies in the bento
and runs ``bentoml serve`` from that environment.

.. note:: The current implementation will try to install the given dependencies
before running the CLI command. Therefore, the environment startup will be a
blocking call.


BentoML CLI Commands that support Environment Manager
- :ref:`serve <reference/cli:serve>`
- :ref:`serve-grpc <reference/cli:serve-grpc>`

Supported Environments
- conda


Caching strategies
==================

Currently, there are two types of environments that are supported by the
environment manager:

1. Persistent environment: If the given target is a Bento, then the created
environment will be stored locally to ``$BENTOML_HOME/env``. Such an
environment will then be cached and later used by subsequent invocations.

2. Ephemeral environment: In cases where the given target is not a Bento (import
path to ``bentoml.Service``, project directory containing a valid
``bentofile.yaml``), the environment will be created and cleanup up on
demand.

.. note::
You can run ``rm -rf $BENTOML_HOME/env`` to clear the cache.
Loading

0 comments on commit 8a6ba60

Please sign in to comment.