Integrate with Jupyter

Integrate with Jupyter

ModelOp Center provides plugins into common data science development tools such as Jupyter, to allow data scientists to interact with ModelOp Center from their preferred development environment.

Using ModelOp Center Jupyter plugin

Overview

The ModelOp Center (MOC) is flexible on how models are registered so that data scientists can leverage their preferred environments for model creation. In other words it is agnostic to the toolkit used to create the model.

Jupyter (http://jupyter.org/) is a popular tool among data scientists and other users of Python and R for building models. It is an evolution of the IPython project, and provides a Notebook interface similar to that of Mathematica or SAGE. The Jupyer Plugin enables the integration between a Jupyter Notebook and ModelOp Center to allow Data Scientists to register and interact with models directly from the Notebook. This allows the Data Scientists to work from their IDE of choice.

Installation and configuration instructions

ModelOp Center contains a package with the Jupyter plugin installation zip file. Please contact your ModelOp representative to get the latest version.

Installation

These installation instructions assume the following:

  • Jupyter notebook is already installed.

  • Maven is already installed.

  • You have access to ModelOp’s jupyter-plugin repository.

git clone https://github.com/modelop/jupyter-plugin.git cd jupyter-plugin mvn clean install jupyter nbextension install target/jupyter-plugin-3.0.1-SNAPSHOT.zip jupyter nbextension enable modelop-plugin/modelop-plugin

Next, start the Jupyter notebook instance (please note the configuration section before running):

jupyter notebook

Configuration

Before being able to use the plugin in the Jupyter instance, please make sure Jupyter knows where ModelOp Center can be reached by providing the base URL in either of the following ways.

  1. Setting up the MOC_INSTANCE_URL environment variable with the base URL, e.g.: “http://modelop:8090” before running the jupyter notebook. Please note for Jupyterhub installations that the environment variables aren’t automatically passed to the notebook, but rather need to be whitelisted. See here for details on how to achieve this.

  2. Using the nbextensions configurator found in contrib nbextensions package. Once available this will provide an additional tab “Nbextensions” where you will be able to:

    1. Enable/Disable the plugin altogether.

    2. Override the environment variable with an arbitrary URL provided at the configurator itself.

    3. Specify the environment variable name if MOC_INSTANCE_URL is not desired to hold the base URL

       

ModelOp specific functions available within Jupyter

Once installed, when the user opens or creates a new Jupyter notebook file, the Jupyter notebook interface is provided with a set of toolbar buttons that interact with ModelOp Center and will be expanded in the sections below.

Registering a new model

From the toolbar, click on the “Register a new model with ModelOp Center” icon.

  1. The “Add Model to Model Operations Center” window opens. Click in the left side of the code cells to designate that the code is part of the model. The selected cells will have a highlighted green border on the left.

     

  2. Click Next. In the “Model Information” section, type the Model Name. Optionally, you can add a brief Description of the model.

     

  3. Click Next. In the “Cell details” section:

    1. Choose the remote repository configuration. Make sure ModelOp Center has been configured with access to the git repositories.
      If the Git Remote text field is blank it will create a local (to ModelOp Center) git repository (no remote repository associated).
      If the Git Remote text field is provided (with a valid accessible git repository URL), the local copy will be associated with given remote repository.
      Check Use default repo option if you want the same git remote and branch for all the source code assets (cells). Otherwise, specify each asset with a different remote url or branch.
      You can entirely disable git handling by switching off the Remote repo configuration toggle. This will in turn handle the source code assets using ModelOp Center internal storage only.

    2. Provide a File Name, and select Primary Model Source if appropriate.
      The file name will be complemented with a default extension, but it can be provided by the input text field as part of the file name.
      A model must have one and only one primary source code, which is where it will look for the model functions (more on model functions in the next step).

       

  4. Click Next. Specify the model functions used in your code. (For additional information on the model functions please see here.) ModelOp Center allows the user to associate the triggering operations with specific code functions. Additionally it can identify if the functions already have predefined model functions associated via smart tags. These optional smart tags should be presented as comments in the line above the function definition and the supported comments are:

    • modelop.init

    • modelop.score

    • modelop.metrics

    • modelop.training


    For example:

    # modelop.init def begin(): ...


    You will find that the functions identified from source with a smart tag are already associated with one of the functions, and this selection is not modifiable. If you wish to change the associated model function, either you can edit or remove the smart tag comment, or you can modify the associated model function in the ModelOp Center UI.

    The function associated via smart tag cannot be used for multiple model functions, but the remaining functions can be selected as options for the other associations:

     

  5. Click Next. On the next screen, add any attachments associated the model and select an asset role for each of the files to upload. This will help ModelOp Center runtime identify the accompanying assets for different purposes across the Model Life Cycle. Leave the asset role blank to let ModelOp Center automatically identify the asset based on the file type.

     

  6. Click Next. Review the summary and click Submit Model.

Opening an existing model

'

From the toolbar, click on the “Load model from ModelOp Center“ icon.

Then, either select the desired model from the list or filter models using the live search bar. Note that your search can match the name of the model or the tags of the model.

The plugin will then create a new cells at the bottom of the active notebook with the source code assets' contents (each asset on a new cell).

Updating an existing model

Submit model version