Skip to content

Commit

Permalink
[Fix]Failure to containerize model with build-arg value contains mult…
Browse files Browse the repository at this point in the history
…iple `=` characters (#1404)
  • Loading branch information
yubozhao authored Jan 14, 2021
1 parent a3dcce5 commit e5a6e6a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bentoml/cli/bento_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def containerize(bento, push, tag, build_arg, yatai_url):
docker_build_args = {}
if build_arg:
for arg in build_arg:
key, value = arg.split("=")
key, value = arg.split("=", 1)
docker_build_args[key] = value
if yatai_url is not None:
spinner_message = f'Sending containerize RPC to YataiService at {yatai_url}'
Expand Down
4 changes: 3 additions & 1 deletion bentoml/yatai/yatai_service_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ def ContainerizeBento(self, request, context=None):
safe_retrieve(bento_service_bundle_path, temp_bundle_path)
try:
docker_client.images.build(
path=temp_bundle_path, tag=tag, buildargs=request.build_args
path=temp_bundle_path,
tag=tag,
buildargs=dict(request.build_args),
)
except (docker.errors.APIError, docker.errors.BuildError) as error:
logger.error(f'Encounter container building issue: {error}')
Expand Down
25 changes: 25 additions & 0 deletions tests/integration/yatai_server/test_containerize.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import subprocess

from bentoml.yatai.client import get_yatai_client
from tests.bento_service_examples.example_bento_service import ExampleBentoService
Expand All @@ -16,3 +17,27 @@ def test_yatai_server_containerize_without_push():
tag = 'mytag'
built_tag = yc.repository.containerize(bento=f'{svc.name}:{svc.version}', tag=tag)
assert built_tag == f'{tag}:{svc.version}'


def test_yatai_server_containerize_from_cli():
svc = ExampleBentoService()
svc.pack('model', [1, 2, 3])
logger.info('Saving bento service to local yatai server')
svc.save()
bento_tag = f'{svc.name}:{svc.version}'
tag = 'mytagfoo'

command = [
'bentoml',
'containerize',
bento_tag,
'--build-arg',
'EXTRA_PIP_INSTALL_ARGS=--extra-index-url=https://pypi.org',
'-t',
tag,
]
docker_proc = subprocess.Popen(
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
stdout = docker_proc.stdout.read().decode('utf-8')
assert f'{tag}:{svc.version}' in stdout, 'Failed to build container'

0 comments on commit e5a6e6a

Please sign in to comment.