Register a Model

This section describes how to register a model within ModelOp Center using the ModelOp Jupyter plugin or the ModelOp CLI.

Table of Contents

 

Introduction

The ModelOp Center is flexible on how models are registered so that data scientists can leverage their preferred environments for model creation.

  • ModelOp Center is agnostic to the toolkit used to create the model.

  • You can register the model using the ModelOp Center Jupyter Plugin or the ModelOp Center CLI. Both methods are described in this section.

  • When you register the model, you can include the following elements:

    • Model Source

    • Attachments

    • Schemas

    • Model Platform

  • You can map the following functions from the source code:

    • Init Function

    • Scoring Function

    • Metrics Function

    • Training Function

  • For more information on the core elements that compose a model see Model Governance: Standard Model Definition.

  • For more information on the functions for the Model Source, see Creating Production-Ready Models.

Register a Model Using a Jupyter Plugin

These instructions assume the following:

  • The Jupyter plugin is installed within your Jupyter environment.

  • The Jupyter plugin is enabled. To verify, go to the Nbextensions tab in Jupyter:

    • Select “ModelOp Center Services” if it is not already selected.

    • Enable the ModelOp Center Services. Click the “Enable” button at the bottom of the screen. It is enabled when the “Disable” button is highlighted in blue as shown below.

To register a model

  1. Navigate to the Jupyter instance with the plugin installed.

  2. Create a new file. Under the Files tab, select New > Python3.

  3. If the ModelOp Center Jupyter plugin was enabled correctly, the plugin toolbar appears in the right-hand side of the Jupyter toolbar:

    1.  

  4. Click the Register icon on the right side of the Tools ribbon.

     

  5. The Add Model to Model Operations Center window opens. Double click in the left side of the code cell to designate that the code is part of the model.

     

  6. Click Next. The Model Information pane opens within the Add Model to Model Operations Center window. In the Model Information section, type the Model Name. Optionally, you can add a brief description of the model, including appropriate model usage information.

     

  7. Click Next.

  8. In the Cell details section:

    1. Provide the Git Remote for the repository if you would like to store the assets with a specific repository.

      1. If you do not currently have your own Git remote repository, you may also select the Use default repo for all cells checkbox to store the model assets within the default repo set up by the Administrator.

      2. ModelOp Center makes a remote Git repository for this model, which is then used to keep the source code under version control.

    2. Provide a File Name for the selected cell.

      1. Please note that each cell within Jupyter is actually stored as a separate file within ModelOp Center and the backing Git-based source control. This allows for more robust version control as well as more flexible execution of the code at the various entry points in the model’s life cycle.

    3. Select Primary Model Source if this particular cell contains the main entry point in your source code for model execution.

  9. Repeat Step 8 for each cell in your Jupyter notebook that you want brought under management within ModelOp Center.

  10. Click Next. On the next screen, add any attachments that go with the model.

  11. Click Next. Review the summary. If you are satisfied, click Submit Model.

Register a Model Using the ModelOp Center CLI

Pre-Requisites

This procedure assumes the following:

  • You have installed the ModelOp Center command line interface (CLI). For more details, see the ModelOp CLI Reference.

  • You have an existing model, minimally in the form of a source code file (e.g. mymodel.py file)

Optional

When you register a model using the CLI, you have the following options:

  • You can add model attachments, such as a trained model artifact that results from model training.

  • You can include an input schema and/or an output schema with the model. These schemas enable the ModelOp Center to verify that the incoming and outgoing data adhere to the original model design intent. If preferred, you can disable schema checking by default, even if you upload input and/or output schemas.

To register a model from the CLI:

  1. Create a model with a primary source code file.

  2. At the command prompt, type:

moc model add <model name> <path to source code file>

a. (Optional) To include a schema associated with the model, use one or both of the following commands:

-schema-in=<path for input schema>

-schema-out=<path for output schema>

b.  (Optional) When you include a schema with a model, schema checking is enabled by default. To override schema checking, use one of the following commands:

-input-check-off — disables input schema checking for the model

-output-check-off — disables output schema checking for the model

-schema-check-off — disables both input and output schema checking for the model

Example: moc model add sample_model /path/to/model/model.py --schema-in=inputSchema.avsc --schema-out=outputSchema.avsc --schema-check-off

3. When the command in Step 2 is executed with all the options, a successful response looks like this:

Model added, ID:  1fbc8cc8-d5b2-40d1-913e-d30c4a71c16a

Note: if your source code file contains ModelOp Center “smart tag comments” for the primary functions of your model (see this article for more details), the CLI registration process automatically stores those function references for the newly registered model.

4. Once a model has successfully been registered, you may add model attachments. Type:

moc asset add <model name> <path to attachment>

Additional Options:

  • To override the file name, add the --name=<string> option.

  • The MOC CLI determines whether to store the attachments in model-manage or external storage based on file size. Files larger than 10 MB are automatically stored in external storage, for efficiency. To control how the file is stored, use the following options:

-force : stores the file in model-manage if file size is less than 10 MB, or in external storage otherwise

-external : stores the attachment as external storage. If the file already exists in an external storage location (e.g. an AWS S3 bucket), provide a link to the asset in the following format:

[protocol]://ResourceAccessKey: ResourceSecretKey@ResourceDomain/PATH TO FILE/FILENAME.EXTENTION.

--region — Add to URL to tell CLI the region for the external storage.  

  • Additional Examples:

moc asset add model_name attachment.zip -- external

moc asset add model_name http://$AKEY:$SKEY@modelop:9000/akash/output.json --region=default-region

Related Articles