ModelOp CLI Reference

The ModelOp Center command line (CLI) offers a terminal-based medium to allow you to interact with ModelOp Center via moc commands. You can execute these commands from an SSH session or from the system console.

Table of Contents

 

Introduction

The primary functions enabled through the CLI include the ability to register models with the ModelOp Center, upload additional attachments and artifacts to an existing model, and run Batch Jobs to make sure the code is right. From there, you may use the Command Center web UI to edit and update your models further.

Document conventions

This article uses the following conventions:

  • Angle brackets (<>) indicate that the enclosed element is mandatory. You are required to replace the text within the angle brackets with the appropriate information.

  • Square brackets ([]) indicate that the enclosed element is optional. You can choose one or more items or no items.

  • The pipe character (|) indicates that one of the bracketed statements can be specified.

This article contains the following sections for each command:

  • Synopsis

    • A description of the commands, options, and arguments available for the command.

  • Description

    • General information about the command.

  • Options

    • Options to control the behavior of a command. Options always begin with one or two dashes. Use one dash for the abbreviated term such as -v. Use two dashes for the full term such as --version. Square brackets mean that element of the command is optional.
      Not all commands have options.

  • Arguments

    • Some commands require arguments. Arguments are names of commands, files, host names, IP addresses, URLs and so on that you specify to control the behavior of the command. Not all commands have arguments. You do not precede arguments with dashes.
      Not all commands have arguments.

  • Examples

    • Usage samples with the expected output. Not all commands have examples.

CLI Installation

You install the CLI in these steps:

  • Download the CLI files to your local machine.

  • Make them executable if necessary.

  • Set a PATH to the location where the files are stored.

  • Run the init command to connect to your ModelOp instance.

To install the CLI

  1. Click the file type you use to download the CLI file:

    1. Darwin

    2. Linux

    3. Windows

  2. Make the Mac (Darwin) or Linux files executable. Browse to the folder where you stored the CLI file. For Macs and Linux, this folder should be /usr/local/bin/

    1. For Darwin, type chmod 755 <filename>

    2. For Linux, type chmod +x <filename>

  3. Set a PATH to the CLI file.

  4. Confirm the installation. At the prompt, type moc help.
    Output:

Usage: moc [flags] moc [command] Available Commands: asset Manage assets for models credentials Manage credentials with CLI deployment Manage deployed models in ModelOp Center help Help about any command init Configure CLI to point to ModelOp Center. Requires an URL with http scheme. iterative Iterative development and testing with ModelOp engine job Manage jobs in ModelOp Center mlc Run MLC service related commands model Manage models in ModelOp Center schema Manage schemas show Outputs init configuration. snapshot Manage snapshots for a given model in ModelOp Center Flags: -h, --help help for moc -v, --version Print version information Use "moc [command] --help" for more information about a command.
  1. Configure the CLI to connect to your instance of ModelOp Center. Type

moc init <URL of ModelOp Center>

Overview of commands

The term “moc commands” refers to the list of available ModelOp Center CLI commands.

The help for the moc commands is presented in Linux man page format.

  • Type help to get general information about command-line man pages.

  • Type help <command> to get information about a specific command.

The following moc commands are available:

  • asset

  • credentials

  • deployment

  • init

  • job

  • model

  • show

  • snapshot

  • schema

Command details

moc

Synopsis

moc [--help | --version] moc <command>

Description

The ModelOp Center CLI base command which is the required prefix to execute moc commands.

Options

v, --version

Displays the version of the CLI

h, --help

Displays information about the specified command

moc command list

asset

Manage assets for models

credentials

Manage credentials with CLI. Use of this command is only required if the ModelOp Center is using Oauth2 for security

deployment

Manage deployments (DeployedModels) in the ModelOp Center

init

Configure CLI to point to a particular instance of ModelOp Center. Requires a URL to the specific ModelOp Center instance. This should be executed first before using other commands (besides help).

job

Manage jobs in the ModelOp Center

model

Manage models in the ModelOp Center

show

Outputs CLI configuration done by init command

snapshot

Manage snapshots in the ModelOp Center

asset

Synopsis

moc asset [--help] moc asset <command> moc asset add <model name or id> <path to file> [--name] [--external | --force] [--region] [--verbose] moc asset ls <model name or id>

Description

Manage assets for models. Use add command to add an asset to an existing model. Use ls command to list assets for a given model.

Use moc model ls to find the model ID and name.

Options

e, --external

Use if the file is larger than 10 MB, or needs to be stored in external storage configured with model-manage. Otherwise, by default, the file is stored internally in model-manage.

If the file already exists in external storage, provide a link to the asset in the following format: [protocol]://ResourceAccessKey: ResourceSecretKey@ResourceDomain/PATH TO FILE/FILENAME.EXTENTION

Supported protocols:

  • http

  • https

  • s3

  • s3n

  • s3a

You can use the environment variables to provide Accesskey and SecretKey credentials to enable access to the external resource.

f, --force

Stores file in model-manage if the file size is less than 10 MB, or in external storage otherwise.

h, --help

Help with asset command

--name string

Name by which asset is stored. Overrides current name

--region string  

Region for the asset if provided by a link

V, --verbose

Be verbose

Arguments

model name or id

Specify the model name or id. (Use moc model ls to find the model name or id)

path to file

Specify the path to the file that will be added as an asset to the model

Examples

credentials

Synopsis

Description

Manage credentials with the CLI which is required if the ModelOp Center is using OAuth2 for authentication and authorization. Add credentials using add, update using update and remove using rm. To view the current username stored with the CLI, use ls. The CLI will give appropriated prompts and will ask for the user input.

Options

h, --help

Help for the commands

--username

Enter a username to save the step of CLI asking for username

--password

Enter a password to save the step of CLI asking for username

--currentusername

Flag used with credentials update command to provide CLI with current username

--currentpassword

Flag used with credentials update command to provide CLI with current password

--newusername

Flag used with credentials update command to provide CLI with new username

--newpassword

Flag used with credentials update command to provide CLI with new password

Arguments

add

Add credentials

update

Update username and/or password

ls    

Lists the current username for the CLI

rm

Remove stored credentials (Needs existing username password confirmation)

username

This argument is only necessary for the rm. Provide the current username stored in order to delete the credentials. Password confirmation will be asked before removing it.

Examples

deployment

Synopsis

Description

Manage deployments (DeployedModels) with the ModelOp Center. Use ls command to list deployments for a particular model

Options

--batch-deployment

Get only the models deployed as Batch Model

--id

Get only the ID of the most recent deployed model

--persistent-deployment

Get only the models deployed as REST or KAFKA

--recent

Get the most recent deployed model

--snapshot-tag

Get Deployed models by snapshot tag. This flag should be used only if the deployments are to be fetched by the snapshot tag.

--state

Filter Deployed models by one of the states: CREATED, DEPLOYED, FAILURE, REMOVED

--tag

Filter Deployed models by deployed model's tag. (tag is matched on deployedModel object)

Arguments

model name or id or --snapshot-tag

Specify model-name or model-id (storedModel) or snapshot-tag

Examples

init

Synopsis

Description

Configure CLI to point to a particular instance of ModelOp Center. Requires a URL to the specific ModelOp Center instance.

Options

h, --help

Help for init

V --verbose

Be verbose

Arguments

url

URL of the ModelOp Center is required with the HTTP(http/https) scheme.

Examples

job

Synopsis

Description

Manage jobs in ModelOp Center.

Options

--enforce-deployed

Enforce the state to be DEPLOYED on the model provided ( for deployed batch job)

--engine string

Specify the target engine name where the job should run

--external-input

Force the URL provided for input to be an external S3 file URL

--external-output

Force the URL provided for output to be an external S3 file URL

--force

In case the file is too large to be stored as a local asset, store it as an external asset

h, --help

Help for job command

--hdfs-input

Force the URL provided for input to be a HDFS URL

--hdfs-output

Force the URL provided for output to be a HDFS URL

--input-param

Provide parameters for the input SQL query

--input-query

Provide a query string for the input SQL asset

--input-region

Provide the region for the input S3 URL

--input-schema-check

Enable schema checking on input

--output-param

Provide parameters for the output SQL query

--output-query

Provide a query string for the output SQL asset

--output-region

Provide the region for the output S3 URL

--output-schema-check

Enable schema checking on output

--schema-check

Enable schema checking on both input and output

-sql-input

Force the URL provided for input to be a SQL connection string

--sql-output

Force the URL provided for output to be a SQL connection string

--test-job

Create MODEL_BATCH_TEST_JOB with the model provided for deployed batch job

--training-job

Create MODEL_BATCH_TRAINING_JOB with the model provided for deployed batch job

--upload-input

Upload the input file provided to the S3 bucket configured with ModelOp Center

--upload-output

Create an empty output file with the provided name in the S3 bucket configured with ModelOp Center

V, --verbose

Be verbose

Arguments

create (or add)

Create batch jobs

<versioned(deplooyable)model ID/name>

Versioned Model’s ID for which the job should be created

<input_file>

Uses when creating a job. Input can be provided by the following methods:

  • Provide the path to a local file that will be embedded in the database for input. There is a size limit of 10MB for embedding files. If unsure of the file size, use the --force flag; this will not fail the command, and will push the file to the S3 bucket configured with ModelOp Center

  • Provide the path to a local file and use the --upload-input flag to push the file to the S3 bucket configured with ModelOp Center

  • Provide a URL to an existing file in the S3 bucket in the format [http/s3/S3n/S3a]://accessKey:secretKey@Domain/PATH/file.txt. The access key and secret key can be provided using environment variables as well, e.g., [http/s3/S3n/S3a]://$ACCESS_KEY:$SECRET_KEY@Domain/PATH/file.txt. If the file is in the S3 bucket configured with the ModelOp Center, access key and secret key are not required, e.g., [http/s3/S3n/S3a]://Domain/PATH/file.txt . When using a URL of a file in S3, use the --input-region flag to provide the S3 region. If the URL is not using one of the schemes - "http", "s3", "s3n", "s3a", use the --external-input flag to enforce the URL to be an external asset URL

  • Provide a SQL asset as input. Use the connection URL as the input URL, e.g., mysql://username:password@host:3306/db_name. The query can be provided using the --input-query flag, and additional parameters can be provided using the --input-param flag. The --input-param flag can be used multiple times and the query parameters will be stored in the order the flags are provided. If the connection URL is not using one of the schemes - "mysql", "sqlserver", "snowflakedsiidriver", "db2", use the --sql-input flag to enforce the URL to be used as a SQL connection URL.

  • Provide an HDFS asset using a URL, e.g., hdfs:///hadoop/demo/test_model/sample_data.csv. If the URL is not using the "hdfs" scheme, use the --hdfs-input flag to enforce the URL to be a HDFS asset URL

<output_file_name>

Used when creating a job. Output can be provided in a similar way to the input, but uses output-related flags:

  • Provide a name for the output file that will be embedded in the database

  • Provide a name of the file, and use the --upload-output flag to push the file to the S3 bucket configured with ModelOp Center

  • Provide a URL to an existing file in the S3 bucket in a similar format as the input file. When using a URL of a file in S3, use the --output-region flag to provide the S3 region. If the URL is not using one of the schemes - "http", "s3", "s3n", "s3a", use the --external-output flag to enforce the URL to be external asset URL

  • Provide a SQL asset as output. Use connection URL as the output URL, e.g., mysql://username:password@host:3306/db_name. The query can be provided using the --output-query flag, and additional parameters can be provided using the --output-param flag. The --output-param flag can be used multiple times and the query parameters will be stored in the order the flags are provided. If the connection URL is not using one of the schemes - "mysql", "sqlserver", "snowflakedsiidriver", "db2", use the --sql-output flag to enforce the URL to be used as a SQL connection URL

  • Provide an HDFS asset using URL, e.g., hdfs:///hadoop/demo/test_model/sample_data.csv. If the URL is not using the "hdfs" scheme, use the --hdfs-output flag to enforce the URL to be a HDFS asset URL.

job ID

Use with status, messages and result arguments

ls

Standard Linux command to list all jobs. Displays the following details about a job:

  • ID — unique ID that is automatically assigned by ModelOp Center upon model add

  • OWNER — the user who created the job or SYSTEM

  • TYPE — the type of batch job (batch scoring, batch metrics/test, batch training)

  • JOB_STATUS — States are Created, Waiting, Running, Complete, Error

  • TOTAL_RUNNING_TIME — How long the model took the last time it ran  

  • LAST_MODIFIED_DATETIME — The last time the model was changed

  • LAST_MESSAGE — Date, time and result of last usage

result     

Get the results of a batch job. Requires a job ID Use moc job ls to see job ID

status

Get the status of a batch job. Requires a job ID. Use moc job ls to see job ID

messages

Get the messages of a job. Requires a job ID. Use moc job ls to see job ID

Examples

model

Synopsis

Description

Manage models in the ModelOp Center.

Add a model to ModelOp Center and list the models stored in ModelOp Center

Use --schema-in and --schema-out to include externalized input and output schemas with the model. When a schema file is provided to upload with a model, schema check is enabled by default.

Use --input-check-off, --output-check-off, -schema-check-off in order to disable schema checking for input and/or output.

Options

h, --help

Help for add

input-check-off

Enable schema checking for the input

i, --schema-in string   

Path for input schema

o, --schema-out string  

Path for output schema

output-check-off   

Enable schema checking for the output

schema-check-off   

Enable schema checking for input and output

V, --verbose 

Be verbose

--versioned

Option used with the model ls command to list all versioned models (deployableModel) associated with a given model

--deployed

Option used with the model ls command to list all deployedModel associated with a given model

--state

Option used with the model ls command to list all deployedModel associated with a given model with state provided

--recent

Option used with model ls to retrieve the most recent model. Also works with --versioned and --deployed

--id

Option is used to retrieve just id of a most recent model. Also works with --versioned and --deployed

Arguments

add

Add model to ModelOp Center

ls    

Get list of all models or with given name

deploy

Deploy a model to runtime added with ModelOp Center

model name

For add, this is the model name by which the provided model will be stored in ModelOp Center. For ls and deploy this model will be searched for to be listed on terminal or to be deployed.

file

Path to the model source code file.

Examples

show

Synopsis

Description

The command shows the configuration done using moc init command, i.e. the url to the ModelOp Center and if the credentials are necessary to communicate with the ModelOp Center. This command takes no arguments or options apart from -h or --help

Examples

snapshot

Synopsis

Description

Manage deployments (DeployedModels) with the ModelOp Center. Use ls command to list deployments for a particular model

Options

--tags

Add tags to the snapshot when using the snapshot create command

--id

Get only the ID of the most recent snapshot when using the ls command

--recent

Get the most recent snapshot when using the ls command

Arguments

ls

List snapshot for a model

create

Create a snapshot for a model

model name or id

Specify model-name or model-id (Use moc model ls to find the model name or id)

Examples

schema

Synopsis

Description

Manage model data schema with the ModelOp Center. Use infer command to generate schema for given data. Note here that the data should be in JSON row format. For example:

Arguments

datafile

Specify the path to sample data in JSON row format

Examples

 

 

Related Articles