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

chore: provides shim for bentoctl #3322

Merged
merged 3 commits into from Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions src/bentoml/_internal/bento/gen.py
@@ -0,0 +1,39 @@
"""
This module is shim for bentoctl. NOT FOR DIRECT USE.
"""
from __future__ import annotations

import logging
import warnings
from typing import TYPE_CHECKING

import fs

from ..container.generate import generate_containerfile

if TYPE_CHECKING:
from .build_config import DockerOptions

__all__ = ["generate_dockerfile"]

logger = logging.getLogger(__name__)

warnings.warn(
"%s is deprecated. Make sure to use 'bentoml.container.build' and 'bentoml.container.health' instead."
% __name__,
DeprecationWarning,
stacklevel=4,
)


def generate_dockerfile(docker: DockerOptions, context_path: str, *, use_conda: bool):
from ..bento import Bento

bento = Bento.from_fs(fs.open_fs(context_path))
logger.debug("'use_conda' is deprecated and will not be used.")
return generate_containerfile(
docker,
bento.path,
conda=bento.info.conda,
bento_fs=bento._fs,
)
2 changes: 1 addition & 1 deletion src/bentoml/_internal/container/generate.py
Expand Up @@ -113,7 +113,7 @@ def generate_containerfile(

.. note::

You should use ``construct_dockerfile`` instead of this function.
You should use ``construct_containerfile`` instead of this function.

Returns:
str: The rendered Dockerfile string.
Expand Down
34 changes: 34 additions & 0 deletions src/bentoml/_internal/utils/buildx.py
@@ -0,0 +1,34 @@
"""
This module is shim for bentoctl. NOT FOR DIRECT USE.
Make sure to use 'bentoml.container.build' and 'bentoml.container.health' instead.
"""

from __future__ import annotations

import typing as t
import warnings

from ..container import health as _internal_container_health
from ..container import get_backend

__all__ = ["build", "health"]

_buildx_backend = get_backend("buildx")

warnings.warn(
"%s is deprecated. Make sure to use 'bentoml.container.build' and 'bentoml.container.health' instead."
% __name__,
DeprecationWarning,
stacklevel=4,
)


def health():
return _internal_container_health("buildx")


def build(**kwargs: t.Any):
# subprocess_env from bentoctl will be handle by buildx, so it is safe to pop this out.
kwargs.pop("subprocess_env")
context_path = kwargs.pop("cwd", None)
_buildx_backend.build(context_path=context_path, **kwargs)