Running a Model on the Edge Tutorial

In this tutorial, we will run a machine learning model in Arundo Edge. This model will calculate the total power output of two wind turbines.

The tutorial is divided into the following sections:

  • Learning Objectives - things you will know how to do after completing the tutorial.
  • Prerequisites - requirements to meet before you get started.
  • Setup - set up necessary before you get started.
  • Instructions - instructions on how to complete the tutorial.
  • Finishing Up - challenges and further reading for after the tutorial.

Learning Objectives

After completing this tutorial, you will know how to:

  • Create simulators that stream sample data
  • Build machine learning models
  • Deploy machine learning models to Arundo Edge
  • View the output of machine learning models

Prerequisites

This tutorial uses a machine learning model built in Arundo Enterprise. If you haven't worked with machine learning models in Arundo Enterprise before, take a look at the Model Workspaces and Models articles before you start this tutorial.


Setup

Before you start the tutorial, you must do the following:


Instructions

Now let's get started...

1. Set Up a Simulator

The first step is to set up a simulator to stream sample turbine data.

a) Download the Sample Data

Download the following sample data file.

Download icon Sample Turbine Data

Save the file on your local device.

Tip

The simulator will stream data from this file.

b) Add a Sequence Interface

Add a Sequence interface in Arundo Edge:

Tip

The Sequence interface will stream the sample data from Arundo Edge to Arundo Fabric on repeat.

  1. Double-click the Arundo Edge shortcut on the desktop.
  2. Log in as normal.
  3. Select Interfaces | + Add new.
  4. Select Sequence.
  5. In Name, enter "Turbine Simulator".
  6. Click Add interface.

c) Upload the Sample Data

Upload the sample data file to Sequence interface by clicking Upload CSV (highlighted below).

Upload CSV button

Then click the upload box and select the sample data file. The sample data now displays on the page as follows:

Sample data


2. Publish the Model

The next step is to build and publish a machine learning model into Arundo Fabric.

a) Build a Model Workspace

Access the Arundo Composer CLI and browse to the local directory where you want to store the model workspace. Then run the following command:

1
composer init Wind_Farm_Output

Press Y and Enter to add a new folder. The following message displays once the workspace is built:

1
2
3
4
5
(arundo) C:\Documents\Composer>composer init Wind_Farm_Output
The folder pump_efficiency does not exist, create it? [y/N]: y
Created: app.py
Created: config.yaml
Project initialized successfully: Wind_Farm_Output

b) Update the config.yaml

Next, open a source code editor, such as Atom, and open the contents of the model workspace directory. Open the config.yaml file, then set the model name and version number as follows:

1
2
3
model_name: Wind Farm Output
model_version: 1.0.0.
wrapper_version: 2

Save your changes once you are finished.

c) Update the app.py

Open the app.py file, delete the code on lines 6-13, and remove the blank space on line 1. This should leave the following:

1
2
from runtime.framework import endpoint, argument, option, returns, pass_api
from runtime.schema import objects, fields

Enter the following code on lines 5-14:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from runtime.framework import endpoint, argument, option, returns, pass_api
from runtime.schema import objects, fields


@endpoint()
@argument("Wind_Turbine_1", type=float)
@argument("Wind_Turbine_2", type=float)
@returns("Total_Output", type=float)
def AddWindTurbineOutput(Wind_Turbine_1, Wind_Turbine_2):
    """
    This model calculates the total power output (mW) for two wind turbines.
    """
    Total_Output = Wind_Turbine_1 + Wind_Turbine_2
    return Total_Output

Finally, save your changes and close the config.yaml and app.py files.

d) Publish the Model

Access the Arundo Composer CLI and browse to the model workspace directory. Then run the following command:

1
composer publish

The following message displays:

1
requirements.txt is missing. Do you want to continue? [y/N]:

Press Y and Enter to continue. The publishing begins and the following message displays once the model is published successfully:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Build status is:  completed after 1m21s
Model ID:         088e5951-7062-e32a-b721-818afc68c4
Name:             Wind_Farm_Output
Version:          1.0.0
Wrapper Version:  2
Build Status:     completed
Owner:            support@arundo.com
Created:          2019-13-03 09:44:19.246000
Base URL:         https://test.arundo.com/model/088e5951-7062-e32a-b721-818afc68c4
Scale:            1/1

3. Deploy the Model

The next step is to deploy the model from Arundo Fabric to Arundo Edge. First, access Arundo Edge, open the System menu and select Upload Configuration to Fabric.

​​Upload Configuration

Next, access Arundo Fabric and select Models on the Navigation bar. Then locate the model in the list and click Deploy to Edge next to the model.

Models list

Select your edge device in the Edge Agents list.

Edge Agents list

Under Endpoint Configuration, select the following inputs and outputs for the model:

Endpoint Configuration

Finally, click Deploy. A message displays at the top of the page once the model is deployed successfully.


4. View Model Output

The final step is to view the calculated output for the model. To do this, complete the following:

  1. Select Viewer on the sidebar.
  2. Open the Graph tab.
  3. Select "Sent to Cloud" in Filter.
  4. Select Auto refresh.
  5. Click Reload.

    The output displays on the Total_Output panel under Models.

    Total Output


Finishing Up

Congratulations! You've now deployed and ran a machine learning model on the edge. We hope you now understand how to run models on the edge to enhance your data analytics.

Want to expand your knowledge further? Try the following:

Challenge

Deploy your own machine learning models to Arundo Edge to generate output for analysis.

Recommended Reading

We have used a number of features in this tutorial. Read the following articles to learn more about them:

Feature Article
Arundo Enterprise Arundo Enterprise Overview
Arundo Fabric Arundo Fabric Overview
Arundo Composer Arundo Composer Overview
Model Workspaces Model Workspaces
Models Models

Downloads

Download the files used in this tutorial.

Download icon Tutorial Files