chore: configuration check for development
@@ -8,19 +8,15 @@ from bentoml.exceptions import BentoMLException
from bentoml.exceptions import BentoMLConfigException
try:
- import importlib.metadata as importlib_metadata
-except ModuleNotFoundError:
- import importlib_metadata
-
-import yaml
-
-try:
- import bentoml._version as version_mod
+ from ..._version import __version__
+ from ..._version import __version_tuple__
except ImportError:
# Since we aren't VCS _version.py, which is generated by setuptools_scm
- class version_mod:
- version: str
- version_tuple: t.Tuple[t.Union[str, int], ...]
+ # BentoML uses setuptools_scm 'post-release' for version scheme
+ from setuptools_scm import get_version
+
+ __version__ = get_version(version_scheme="post-release")
+ __version_tuple__ = (0, 0, 0, "dirty")
# Note this file is loaded prior to logging being configured, thus logger is only
@@ -56,7 +52,7 @@ def clean_bentoml_version(bentoml_version: str) -> str:
# Find BentoML version managed by setuptools_scm
-BENTOML_VERSION: str = importlib_metadata.version("bentoml")
+BENTOML_VERSION = __version__
# Get clean BentoML version indicating latest PyPI release. E.g. 1.0.0.post => 1.0.0
CLEAN_BENTOML_VERSION: str = clean_bentoml_version(BENTOML_VERSION)
@@ -86,7 +82,7 @@ def is_pypi_installed_bentoml() -> bool:
"""
# In a git repo with no tag, setuptools_scm generated version starts with "0.1."
is_tagged = not BENTOML_VERSION.startswith("0.1.")
- is_clean = not str(version_mod.version_tuple[-1]).split(".")[-1].startswith("d")
+ is_clean = not str(__version_tuple__[-1]).split(".")[-1].startswith("d")
not_been_modified = BENTOML_VERSION == BENTOML_VERSION.split("+")[0]
return is_tagged and is_clean and not_been_modified
@@ -163,6 +159,8 @@ def load_global_config(bentoml_config_file: t.Optional[str] = None):
def save_global_config(config_file_handle: t.IO[t.Any]):
+ import yaml
+
from ..configuration.containers import BentoMLContainer
content = yaml.safe_dump(BentoMLContainer.config)
