def serve(port, archive_path=installed_archive_path): """ Start REST API server hosting BentoService loaded from archive """ model_service = load(archive_path) server = BentoAPIServer(model_service, port=port) server.start()
def serve(port, bento=None, with_conda=False, enable_microbatch=False): track_cli('serve') bento_service_bundle_path = resolve_bundle_path( bento, pip_installed_bundle_path) bento_service = load(bento_service_bundle_path) if with_conda: run_with_conda_env( bento_service_bundle_path, 'bentoml serve {bento} --port {port} {flags}'.format( bento=bento_service_bundle_path, port=port, flags="--enable-microbatch" if enable_microbatch else "", ), ) return if enable_microbatch: with reserve_free_port() as api_server_port: # start server right after port released # to reduce potential race marshal_server = MarshalService( bento_service_bundle_path, outbound_host="localhost", outbound_port=api_server_port, outbound_workers=1, ) api_server = BentoAPIServer(bento_service, port=api_server_port) marshal_server.async_start(port=port) api_server.start() else: api_server = BentoAPIServer(bento_service, port=port) api_server.start()
def serve(port, archive_path=archive_path, with_conda=False): if with_conda: config = load_bentoml_config(archive_path) metadata = config['metadata'] env_name = metadata['service_name'] + '_' + metadata[ 'service_version'] pip_req = os.path.join(archive_path, 'requirements.txt') subprocess.call( 'command -v conda >/dev/null 2>&1 || {{ echo >&2 "--with-conda ' 'parameter requires conda but it\'s not installed."; exit 1; }} && ' 'conda env update -n {env_name} -f {env_file} && ' 'conda init bash && ' 'eval "$(conda shell.bash hook)" && ' 'conda activate {env_name} && ' '{{ [ -f {pip_req} ] && pip install -r {pip_req} || echo "no pip ' 'dependencies."; }} &&' 'bentoml serve {archive_path} --port {port}'.format( env_name=env_name, env_file=os.path.join(archive_path, 'environment.yml'), archive_path=archive_path, port=port, pip_req=pip_req, ), shell=True, ) return track_cli('serve') bento_service = load(archive_path) server = BentoAPIServer(bento_service, port=port) server.start()
def serve(port, bento=None, with_conda=False): track_cli('serve') bento_service_bundle_path = resolve_bundle_path( bento, pip_installed_bundle_path) if with_conda: run_with_conda_env( bento_service_bundle_path, 'bentoml serve {bento} --port {port}'.format( bento=bento_service_bundle_path, port=port, ), ) return bento_service = load(bento_service_bundle_path) server = BentoAPIServer(bento_service, port=port) server.start()
def serve(port, archive_path=archive_path): model_service = load(archive_path) server = BentoAPIServer(model_service, port=port) server.start()
def serve(port, archive_path=archive_path): track_cli('serve') bento_service = load(archive_path) server = BentoAPIServer(bento_service, port=port) server.start()