Skip to content

Commit

Permalink
fix: chdir
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Feb 12, 2025
1 parent 81db502 commit 17f32bf
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/_bentoml_impl/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,21 @@ def import_service(
# a project under current directory
extra_python_path = None

# patch model store if needed
if (
bento_path.with_name(BENTO_YAML_FILENAME).exists()
and bento_path.with_name("models").exists()
):
original_model_store = None
original_path = None
if bento_path.with_name(BENTO_YAML_FILENAME).exists():
from bentoml._internal.models import ModelStore

original_path = os.getcwd()
original_model_store = BentoMLContainer.model_store.get()
# cwd into this for relative path to work
os.chdir(bento_path.absolute())

# check in bento source

BentoMLContainer.model_store.set(
ModelStore((bento_path.with_name("models").absolute()))
)
else:
original_path = None
original_model_store = None
# patch model store if needed
if bento_path.with_name("models").exists():
original_model_store = BentoMLContainer.model_store.get()
BentoMLContainer.model_store.set(
ModelStore((bento_path.with_name("models").absolute()))
)

# load model aliases
bento: Bento | None = None
Expand Down

0 comments on commit 17f32bf

Please sign in to comment.