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

feat: reorganize the new SDK package #4337

Merged
merged 6 commits into from
Dec 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: export types
Signed-off-by: Frost Ming <me@frostming.com>
frostming committed Dec 20, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 0018a4afd1f43717db8107cd6c01be3384b2bbdc
2 changes: 1 addition & 1 deletion examples/sentence-embedding/service.py
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@

import numpy as np
import torch
from pydantic import Field

import bentoml
from bentoml.types import Field


@bentoml.service(resources={"memory": "500MiB"}, traffic={"timeout": 1})
6 changes: 4 additions & 2 deletions src/_bentoml_impl/worker/service.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@

import click

if t.TYPE_CHECKING:
from _bentoml_sdk import Service


@click.command()
@click.argument("bento_identifier", type=click.STRING, required=False, default=".")
@@ -143,14 +146,13 @@ def main(
from bentoml._internal.log import configure_server_logging
from bentoml._internal.service import load

from ..factory import Service
from ..server.app import ServiceAppFactory

if runner_map:
BentoMLContainer.remote_runner_mapping.set(
t.cast(t.Dict[str, str], json.loads(runner_map))
)
service = t.cast(Service[t.Any], load(bento_identifier, working_dir=working_dir))
service = t.cast("Service[t.Any]", load(bento_identifier, working_dir=working_dir))
service.inject_config()

component_context.component_type = "api_server"
3 changes: 3 additions & 0 deletions src/bentoml/__init__.py
Original file line number Diff line number Diff line change
@@ -95,6 +95,7 @@
from . import batch # Batch API
from . import exceptions # BentoML exceptions
from . import server # Server API
from . import types # BentoML types
frostming marked this conversation as resolved.
Show resolved Hide resolved
from . import monitoring # Monitoring API
from . import cloud # Cloud API

@@ -150,6 +151,7 @@
ray = _LazyLoader("bentoml.ray", globals(), "bentoml.ray")

io = _LazyLoader("bentoml.io", globals(), "bentoml.io")
types = _LazyLoader("bentoml.types", globals(), "bentoml.types")
batch = _LazyLoader("bentoml.batch", globals(), "bentoml.batch")
models = _LazyLoader("bentoml.models", globals(), "bentoml.models")
metrics = _LazyLoader("bentoml.metrics", globals(), "bentoml.metrics")
@@ -185,6 +187,7 @@ def __getattr__(name: str) -> Any:
"client",
"server",
"io",
"types",
"Tag",
"Model",
"Runner",
34 changes: 33 additions & 1 deletion src/bentoml/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from pydantic import Field

from ._internal.models.model import ModelSignature
from ._internal.types import ModelSignatureDict

__all__ = ["ModelSignature", "ModelSignatureDict"]
if TYPE_CHECKING:
from _bentoml_sdk.types import Audio
from _bentoml_sdk.types import File
from _bentoml_sdk.types import Image
from _bentoml_sdk.types import Tensor
from _bentoml_sdk.types import Video
else:

def __getattr__(name: str) -> None:
if name not in ("File", "Image", "Audio", "Video", "Tensor"):
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

import _bentoml_sdk.types

return getattr(_bentoml_sdk.types, name)


__all__ = [
"ModelSignature",
"ModelSignatureDict",
"File",
"Image",
"Audio",
"Video",
"Tensor",
"Field",
]