run-local

Description

The environment specified by --image is built locally, and the model that exists locally is executed only once in that environment. The contents of the file specified with --input are executed as the model input, and the result is output.

Notes

In order to use the run-local command, docker must be installed.

Synopsis

$ abeja model run-local [--help]
Usage: abeja model run-local [OPTIONS]

  Local run commands

Options:
  -h, --handler TEXT              Model hanlder  [required]
  -i, --image TEXT                Base-image name  [required]
  -d, --device_type [x86_cpu|x86_gpu|jetson_tx2|raspberry3]
                                  Device type
  --input TEXT                    Input data  [required]
  -e, --environment ENVIRONMENTSTRING
                                  Environment variables
  --no-cache, --no_cache          Not use built cache
  -q, --quiet                     Suppress info logs
  --v1                            Specify if you use old custom runtime image
  --help                          Show this message and exit.

Options

-h, --handler

Specify the path of the function to be called.

If --handler main: handler is specified, thehandler defined in the main.py file is called. If the file to call is placed directly under the src directory, it is src.main: handler.

-i, --image

Specify the image to use. See here for images that can be specified.

-d, --device_type

Specify the device type. [x86_cpu, x86_gpu, jetson_tx2, raspberry3]

--input

Specify the input file. The file specified here becomes the input to the model. The file extensions that can be entered are json,jpeg, png, andgif.

-e, --environment

Specify an environment variable. Registered environment variables can be referenced from the code. e.g.)IMAGE_WIDTH:100
For more information on user-specifiable environment variables, see here.

--no-cache, --no_cache

Rebuild and recreate the image.

-q, --quiet

Suppress info log output.

--v1

This option should be given when using 18.10 custom images.

Example

Run locally

Premise:

  • Assume the following conditions.
$ cat main.py
def handler(iter, context):
    for data in iter:
        yield data

$ cat input.json
{
    "val": 12345
}

Command:

$ abeja model run-local -h main:handler -i abeja/all-cpu:18.10 --input ./input.json

Output:

[info] preparing image : abeja/all-cpu:18.10
Pulling from abeja/all-cpu:18.10
...
Pull complete
Digest: sha256:1605a09f7669c2a25fc1db321e7ec1304c125b93171ef654653940ef882baebf
Status: Downloaded newer image for abeja/all-cpu:18.10
[info] building image
...
Successfully built 58ba7ff0edf4
[info] setting up local server
[info] waiting server running
[info] sending request to model
[info] finish requesting to model
[{'val': 12345}]