예제 #1
0
def build_model_docker(image_name: str, model: 'core.Model', server: Server = None,
                       image_tag='latest', force_overwrite=False, **kwargs):
    """
    Builds docker image from Model instance

    :param image_name: docker image name to create
    :param model: model to create image
    :param server: server instance to wrap model
    :param image_tag: docker image tag
    :param force_overwrite: force overwrite image if it exists
    :param kwargs: same as in DockerBuilder.__init__
    """
    if server is None:
        from ebonite.ext.flask import FlaskServer
        server = FlaskServer()

    if not module_importable('docker'):
        raise RuntimeError("Can't build docker container: docker module is not installed. Install it "
                           "with 'pip install docker'")

    from ebonite.build.builder.docker_builder import DockerBuilder, is_docker_running

    if not is_docker_running():
        raise RuntimeError("Docker is unavailable")

    provider = MLModelProvider(model, server)
    builder = DockerBuilder(provider, image_name, image_tag, force_overwrite, **kwargs)
    builder.build()
예제 #2
0
def python_builder(created_model) -> PythonBuilder:
    return PythonBuilder(MLModelProvider(created_model, FlaskServer()))
예제 #3
0
def python_builder_async(created_model) -> PythonBuilder:
    return PythonBuilder(MLModelProvider(created_model, AIOHTTPServer()))