Skip to content

Frameworks

Frameworks #28

Workflow file for this run

name: Frameworks
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "0 0 * * 1/2"
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:
run:
shell: bash --noprofile --norc -exo pipefail {0}
jobs:
diff:
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 }}
mlflow: ${{ steps.filter.outputs.mlflow }}
onnx: ${{ steps.filter.outputs.onnx }}
picklable_model: ${{ steps.filter.outputs.picklable_model }}
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 }}
xgboost: ${{ steps.filter.outputs.xgboost }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
related: &related
- codecov.yml
- pyproject.toml
- requirements/tests-requirements.txt
- .github/workflows/frameworks.yml
- tests/integration/frameworks/conftest.py
- tests/integration/frameworks/test_frameworks.py
- src/bentoml/_internal/runner/**
- src/bentoml/_internal/models/**
catboost:
- *related
- 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
- src/bentoml/_internal/frameworks/lightgbm.py
- tests/integration/frameworks/models/lightgbm.py
mlflow:
- *related
- src/bentoml/mlflow.py
- src/bentoml/_internal/frameworks/mlflow.py
- tests/integration/frameworks/mlflow
fastai:
- *related
- src/bentoml/fastai.py
- src/bentoml/_internal/frameworks/fastai.py
- src/bentoml/_internal/frameworks/common/pytorch.py
- tests/integration/frameworks/test_fastai_unit.py
onnx:
- *related
- src/bentoml/onnx.py
- src/bentoml/_internal/frameworks/onnx.py
- tests/integration/frameworks/models/onnx.py
picklable_model:
- *related
- src/bentoml/picklable_model.py
- src/bentoml/_internal/frameworks/picklable_model.py
- tests/integration/frameworks/models/picklable_model.py
pytorch:
- *related
- src/bentoml/pytorch.py
- 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
- src/bentoml/_internal/frameworks/common/pytorch.py
- src/bentoml/_internal/frameworks/torchscript.py
pytorch_lightning:
- *related
- src/bentoml/pytorch.py
- src/bentoml/pytorch_lightning.py
- src/bentoml/_internal/frameworks/common/pytorch.py
- src/bentoml/_internal/frameworks/torchscript.py
- src/bentoml/_internal/frameworks/pytorch_lightning.py
sklearn:
- *related
- src/bentoml/sklearn.py
- src/bentoml/_internal/frameworks/sklearn.py
- tests/integration/frameworks/models/sklearn.py
tensorflow: &tensorflow
- *related
- src/bentoml/tensorflow.py
- src/bentoml/_internal/frameworks/tensorflow_v2.py
- tests/integration/frameworks/models/tensorflow.py
- tests/integration/frameworks/test_tensorflow_unit.py
keras:
- *related
- *tensorflow
- src/bentoml/keras.py
- src/bentoml/_internal/frameworks/keras.py
- tests/integration/frameworks/models/keras.py
transformers:
- *related
- src/bentoml/transformers.py
- src/bentoml/_internal/frameworks/transformers.py
- tests/integration/frameworks/test_transformers_unit.py
xgboost:
- *related
- src/bentoml/xgboost.py
- src/bentoml/_internal/frameworks/xgboost.py
- tests/integration/frameworks/models/xgboost.py
catboost_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.catboost == '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 catboost
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 catboost)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
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[@]}"
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[@]}"
fastai_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.fastai == '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 fastai "torch<1.12" torchvision pandas scikit-learn
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 fastai)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py tests/integration/frameworks/test_fastai_unit.py "${OPTS[@]}"
keras_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.keras == '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 "keras<2.12" "tensorflow>=2.7.3"
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 keras)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
lightgbm_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.lightgbm == '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 lightgbm
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 lightgbm)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
mlflow_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.mlflow == '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 mlflow scikit-learn
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)
coverage run -m pytest tests/integration/frameworks/mlflow "${OPTS[@]}"
onnx_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.onnx == '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 onnx onnxruntime skl2onnx
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 onnx)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
picklable_model_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.picklable_model == '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 -r requirements/tests-requirements.txt
- name: Run tests and generate coverage report
run: |
OPTS=(--cov-config pyproject.toml --cov src/bentoml --cov-append --framework picklable_model)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
pytorch_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.pytorch == '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 torch torchvision
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 pytorch)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py tests/integration/frameworks/test_pytorch_unit.py "${OPTS[@]}"
pytorch_lightning_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.pytorch_lightning == '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 torch torchvision lightning
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 pytorch_lightning)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
torchscript_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.torchscript == '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 torch torchvision
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 torchscript)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
sklearn_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.sklearn == '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 joblib scikit-learn
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 sklearn)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
tensorflow_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.tensorflow == '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 "tensorflow>=2.7.3"
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 tensorflow)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py tests/integration/frameworks/test_tensorflow_unit.py "${OPTS[@]}"
- name: Generate coverage
run: coverage xml
- name: Run tests for no eager execution
run: |
OPTS=(--cov-config pyproject.toml --cov src/bentoml --cov-append --disable-tf-eager-execution --cov-report=xml:no_eager_execution.xml)
coverage run -m pytest tests/integration/frameworks/test_tensorflow_unit.py "${OPTS[@]}"
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml, ./no_eager_execution.xml
token: ${{ secrets.CODECOV_TOKEN }}
transformers_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.transformers == '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 tensorflow tensorflow_hub datasets transformers jax jaxlib flax torch
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 transformers)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py tests/integration/frameworks/test_transformers_unit.py "${OPTS[@]}"
- name: Generate coverage
run: coverage xml
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml, ./no_eager_execution.xml
token: ${{ secrets.CODECOV_TOKEN }}
xgboost_integration_tests:
needs: diff
if: ${{ (github.event_name == 'pull_request' && needs.diff.outputs.xgboost == '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 xgboost
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 xgboost)
coverage run -m pytest tests/integration/frameworks/test_frameworks.py "${OPTS[@]}"
concurrency:
group: frameworks${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true