Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sdk&framework): [Broken] framework runners #2288

Merged
merged 17 commits into from
Feb 23, 2022
Merged

Conversation

bojiang
Copy link
Member

@bojiang bojiang commented Feb 18, 2022

Description

Motivation and Context

How Has This Been Tested?

Checklist:

  • My code follows the bentoml code style, both make format and
    make lint script have passed
    (instructions).
  • My change reduces project test coverage and requires unit tests to be added
  • I have added unit tests covering my code change
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #2288 (2dc2318) into main (4308c67) will decrease coverage by 2.66%.
The diff coverage is 57.23%.

❗ Current head 2dc2318 differs from pull request most recent head 0f8420b. Consider uploading reports for the commit 0f8420b to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2288      +/-   ##
==========================================
- Coverage   47.64%   44.98%   -2.67%     
==========================================
  Files         105      106       +1     
  Lines        8196     8448     +252     
==========================================
- Hits         3905     3800     -105     
- Misses       4291     4648     +357     
Impacted Files Coverage Δ
bentoml/_internal/context.py 0.00% <0.00%> (ø)
bentoml/_internal/external_typing/__init__.py 0.00% <0.00%> (ø)
bentoml/_internal/frameworks/tensorflow_v1.py 0.00% <0.00%> (ø)
bentoml/_internal/runner/local.py 0.00% <0.00%> (ø)
bentoml/_internal/runner/remote.py 0.00% <0.00%> (ø)
bentoml/_internal/server/service_app.py 0.00% <0.00%> (ø)
bentoml/_internal/frameworks/onnxmlir.py 72.28% <33.33%> (+9.13%) ⬆️
bentoml/_internal/frameworks/statsmodels.py 72.16% <38.88%> (-26.43%) ⬇️
bentoml/_internal/frameworks/keras.py 70.92% <40.00%> (-27.12%) ⬇️
bentoml/_internal/frameworks/paddle.py 60.99% <40.00%> (-29.75%) ⬇️
... and 32 more

@aarnphm
Copy link
Contributor

aarnphm commented Feb 18, 2022

we are removing load_runner ?

@@ -3,6 +3,7 @@
from typing import TYPE_CHECKING

import numpy as np
from torch._C import device
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be in the conditional import try block?

MODULE_NAME = "bentoml.easyocr"


@inject
def load(
tag: str,
tag: t.Union[str, Tag],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make a type alias TagLike?

@@ -403,11 +377,8 @@ def load_runner(
*,
predict_fn_name: str = "predict",
device_id: str = "CPU:0",
predict_kwargs: t.Optional[t.Dict[str, t.Any]] = None,
partial_kwargs: t.Optional[t.Dict[str, t.Any]] = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also update in the doctoring below

@@ -8,6 +8,11 @@
from types import FunctionType
from functools import reduce

if sys.version_info[0] == 3 and sys.version_info[1] >= 8:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

from .. import external_typing as ext
from ..models import ModelStore

CatBoostModel = t.Union[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great refactoring 👍

bentoml/_internal/frameworks/catboost.py Show resolved Hide resolved
@@ -95,9 +89,7 @@ def load(
tag: t.Union[str, Tag],
model_params: t.Optional[t.Dict[str, t.Union[str, int]]] = None,
model_store: "ModelStore" = Provide[BentoMLContainer.model_store],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that we removed model_store inject from load_runner, should we also do that for save and load?

I think it makes more sense to just use public API under bentoml.models in our framework modules - I don't think allowing user to customize model_store for each save or load call is a valid use case, given that 1.0 will bring in a pretty powerful export/import feature that @sauyon is working on.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do that in another PR


@property
def default_name(self) -> str:
return Tag.from_taglike(self._tag).name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to do self._tag = Tag.from_taglike(tag) in __init__?

name: t.Optional[str] = None,
):
super().__init__(name)
self._tag = tag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

def run(self, *args: t.Any, **kwargs: t.Any) -> t.Any:
return self._impl.run(*args, **kwargs)

@final
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 237 to 241
INIT = 0
SETTING = 1
SET = 2
SHUTIING_DOWN = 3
SHUTDOWN = 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related in this PR, suggest renaming the two states above:

UNINITILIZED = 0
INITIALIZING = 1
READY = 2

And should it also have an ERROR state? in case _setup failed in runner_app?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names reflect our setup and shutdown API.

Copy link
Member Author

@bojiang bojiang Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SET -> READY

@bojiang bojiang changed the title refactor(sdk&framework): framework runners refactor(sdk&framework): [Broken] framework runners Feb 23, 2022
@bojiang bojiang merged commit d95f427 into bentoml:main Feb 23, 2022
@bojiang bojiang deleted the fix branch February 23, 2022 04:59
aarnphm pushed a commit to aarnphm/BentoML that referenced this pull request Feb 23, 2022
* refactor(sdk): runner

* refactor(sdk): simpler runner creation

* refactor(frameworks): many fixes

* fix resources_quota

* fi

* fix for <py38

* fix runner

* fix it

* remove model_store in integration tests

* remove runner args

* mod default model_store for integration tests

* try fix keras

* fix picklable_model tests

* fix detectron

* review

* fix picklable_model

* append

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
aarnphm pushed a commit to aarnphm/BentoML that referenced this pull request Jul 29, 2022
* refactor(sdk): runner

* refactor(sdk): simpler runner creation

* refactor(frameworks): many fixes

* fix resources_quota

* fi

* fix for <py38

* fix runner

* fix it

* remove model_store in integration tests

* remove runner args

* mod default model_store for integration tests

* try fix keras

* fix picklable_model tests

* fix detectron

* review

* fix picklable_model

* append
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants