Skip to content

Commit 4c95ad0

Browse files
authored
ci: enable bentoml-1.0 (#1783)
* refactor: wip * refactor: add bentoml-1.0 branch to ci
1 parent 2371953 commit 4c95ad0

File tree

15 files changed

+27
-31
lines changed

15 files changed

+27
-31
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: BentoML-CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, bentoml-1.0 ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ master, bentoml-1.0 ]
88
schedule:
99
- cron: '0 2 * * *'
1010

@@ -636,4 +636,4 @@ jobs:
636636
- name: Run tests
637637
run: ./ci/integration/frameworks/run_xgboost_tests.sh
638638
- name: Upload test coverage to Codecov
639-
uses: codecov/[email protected]
639+
uses: codecov/[email protected]

bentoml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# From versioneer
22
from ._version import get_versions
33

4-
__version__ = get_versions()["version"] # type: ignore
4+
__version__ = get_versions()["version"]
55
del get_versions
66

77
from bentoml._internal.configuration import inject_dependencies

bentoml/_internal/models/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ..types import MetadataType, PathType
55
from ..utils.ruamel_yaml import YAML
66

7-
MT = t.TypeVar("MT")
7+
MT = t.TypeVar("MT", bound=t.Any)
88

99
H5_EXTENSION: str = ".h5"
1010
HDF5_EXTENSION: str = ".hdf5"
@@ -58,7 +58,7 @@ def metadata(self: "Model") -> t.Optional[MetadataType]:
5858
return self._metadata
5959

6060
@classmethod
61-
def load(cls, path: PathType) -> MT:
61+
def load(cls, path: PathType) -> t.Any:
6262
"""
6363
Load saved model into memory.
6464

bentoml/_internal/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
JSON_CHARSET = "utf-8"
3535

36-
PathType = Union[str, bytes, os.PathLike]
36+
PathType = Union[str, os.PathLike]
3737

3838
MetadataType = Dict[str, Any] # TODO:
3939

bentoml/detectron.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class DetectronModel(Model):
4747
TODO:
4848
"""
4949

50-
_model: torch.nn.Module
51-
5250
def __init__(
5351
self,
5452
model: torch.nn.Module,

bentoml/onnx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ def load(
7474
if isinstance(path, onnx.ModelProto):
7575
return onnxruntime.InferenceSession(path.SerializeToString())
7676
else:
77-
_get_path: str = cls.__get_model_fpath(path)
77+
_get_path = str(cls.__get_model_fpath(path))
7878
return onnxruntime.InferenceSession(_get_path)
7979

8080
def save(self, path: t.Union[PathType, "onnx.ModelProto"]) -> None:
8181
if isinstance(self._model, onnx.ModelProto):
8282
onnx.save_model(self._model, self.__get_model_fpath(path))
8383
else:
84-
shutil.copyfile(self._model, self.__get_model_fpath(path))
84+
shutil.copyfile(self._model, str(self.__get_model_fpath(path)))

bentoml/py.typed

Whitespace-only changes.

bentoml/pyspark.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class PySparkMLlibModel(Model):
6161
TODO:
6262
"""
6363

64-
_model: pyspark.ml.Model
65-
6664
def __init__(
6765
self,
6866
model: pyspark.ml.Model,

bentoml/pytorch.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
try:
2020
import pytorch_lightning
2121
except ImportError:
22-
pytorch_lightning = None
22+
pytorch_lightning = None # type: ignore
2323

2424
logger = logging.getLogger(__name__)
2525

@@ -67,9 +67,11 @@ def load(
6767
) -> t.Union["torch.nn.Module", "torch.jit.ScriptModule"]:
6868
# TorchScript Models are saved as zip files
6969
if zipfile.is_zipfile(cls.__get_weight_fpath(path)):
70-
return torch.jit.load(cls.__get_weight_fpath(path))
70+
return torch.jit.load(cls.__get_weight_fpath(path)) # type: ignore
7171
else:
72-
return cloudpickle.load(open(cls.__get_weight_fpath(path), "rb"))
72+
return cloudpickle.load( # type: ignore
73+
open(cls.__get_weight_fpath(path), "rb")
74+
)
7375

7476
def save(self, path: PathType) -> None:
7577
# If model is a TorchScriptModule, we cannot apply standard pickling
@@ -125,7 +127,7 @@ def __get_weight_fpath(path: PathType) -> str:
125127

126128
@classmethod
127129
def load(cls, path: PathType) -> "torch.jit.ScriptModule":
128-
return torch.jit.load(cls.__get_weight_fpath(path))
130+
return torch.jit.load(cls.__get_weight_fpath(path)) # type: ignore
129131

130132
def save(self, path: PathType) -> None:
131133
torch.jit.save(self._model.to_torchscript(), self.__get_weight_fpath(path))

bentoml/tensorflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def __init__(
152152
super(TensorflowModel, self).__init__(model, metadata=metadata)
153153

154154
@staticmethod
155-
def __load_tf_saved_model(
155+
def __load_tf_saved_model( # pylint: disable=unused-private-member
156156
path: str,
157-
) -> t.Union[AutoTrackable, t.Any]: # pylint: disable=unused-private-member
157+
) -> t.Union[AutoTrackable, t.Any]:
158158
if TF2:
159159
return tf.saved_model.load(path)
160160
else:

bentoml/transformers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def __load_from_directory( # pylint: disable=unused-private-member
7171
return {"model": transformers_model, "tokenizer": tokenizer}
7272

7373
@staticmethod
74-
def __load_from_dict(
74+
def __load_from_dict( # pylint: disable=unused-private-member
7575
transformers_dict: t.Dict[str, t.Any]
76-
) -> dict: # pylint: disable=unused-private-member
76+
) -> dict:
7777
if not transformers_dict.get("model"):
7878
raise InvalidArgument(
7979
" 'model' key is not found in the dictionary."
@@ -103,9 +103,9 @@ def __load_from_dict(
103103
return transformers_dict
104104

105105
@classmethod
106-
def __load_from_string(
106+
def __load_from_string( # pylint: disable=unused-private-member
107107
cls, model_name: str
108-
) -> dict: # pylint: disable=unused-private-member
108+
) -> dict:
109109
try:
110110
transformers_model = getattr(
111111
import_module("transformers"), cls._model_type

bentoml/xgboost.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class XgBoostModel(Model):
4242
def __init__(
4343
self, model: xgboost.core.Booster, metadata: t.Optional[MetadataType] = None
4444
):
45-
self._model: xgboost.core.Booster
4645
super(XgBoostModel, self).__init__(model, metadata=metadata)
4746

4847
@classmethod

docker/manager.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# TODO: Update some of the complex type hint cases for both utils.py and this one
3939
if t.TYPE_CHECKING:
40-
from docker.models.images import Image
40+
from docker.models.images import Image # pylint: disable=unused-import
4141

4242
README_TEMPLATE: Path = Path("./templates/docs/README.md.j2")
4343

@@ -498,7 +498,7 @@ class BuildMixin(object):
498498

499499
def build_images(self) -> None:
500500
"""Build images."""
501-
for image_tag, dockerfile_path in self.build_tags(): # type: ignore
501+
for image_tag, dockerfile_path in self.build_tags():
502502
log.info(f"Building {image_tag} from {dockerfile_path}")
503503
try:
504504
# this is should be when there are changed in base image.
@@ -582,7 +582,7 @@ def push_images(self) -> None:
582582
return
583583

584584
# Then push image to registry.
585-
for image_tag in self.push_tags(): # type: ignore
585+
for image_tag in self.push_tags():
586586
image = self._push_context[image_tag]
587587
reg, tag = image_tag.split(":")
588588
registry = "".join(
@@ -648,7 +648,7 @@ def push_readmes(
648648
cookies=logins.cookies,
649649
)
650650

651-
def background_upload(self, image: "Image", tag: str, registry: str) -> None:
651+
def background_upload(self, image: Image, tag: str, registry: str) -> None:
652652
"""Upload a docker image."""
653653
image.tag(registry, tag=tag)
654654
log.debug(f"Pushing {repr(image)} to {registry}...")

docker/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def walk(path: pathlib.Path) -> t.Generator:
490490
yield p.resolve()
491491

492492

493-
def sprint(*args: str, **kwargs: str) -> None:
493+
def sprint(*args: t.Any, **kwargs: str) -> None:
494494
# stream logs inside docker container to sys.stderr
495495
print(*args, file=sys.stderr, flush=True, **kwargs)
496496

mypy.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ disable_error_code = attr-defined
44
exclude = "|(bentoml/_internal/yatai_client/proto)|(yatai/yatai/proto)|(yatai/versioneer.py)|"
55
ignore_missing_imports = True
66

7-
# mypy --strict --allow-any-generics --allow-subclassing-any --no-check-untyped-defs
8-
disallow_untyped_calls = True
7+
# mypy --strict --allow-any-generics --allow-subclassing-any --no-check-untyped-defs --allow-untyped-call
98
disallow_untyped_defs = True
109
disallow_incomplete_defs = True
1110
disallow_untyped_decorators = True

0 commit comments

Comments
 (0)