Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: provides shim for bentoctl (#3322)
this shim should only be used by bentoctl. The shim will be here until bentoctl uses public API.
- Loading branch information
Showing
5 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
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") | ||
kwargs["tag"] = kwargs.pop("tags") | ||
context_path = kwargs.pop("cwd", None) | ||
for key, value in kwargs.items(): | ||
if not value: | ||
kwargs[key] = None | ||
_buildx_backend.build(context_path=context_path, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters