Quick Start: Deploy your first model

Aim

This guide will show you how to build a simple in-memory model that will continuously process live data. The model will contain a function to identify when the pressure applied to the brake system exceeds 50% max.

We will use the Quix SDK and deploy the model using a pub/sub pattern on Kafka. The model will read from a Kafka topic containing raw data, and write the output of the function to a new Kafka topic.

By the end you will have:

  1. Created topics to act as input and output sources for your data

  2. Deployed a model to process data in real-time

Before you begin

  • You’ll need to have streamed in data from our example car project in order to follow this guide. If you haven’t already done so, you can follow our Quick Start to streaming data.

Overview

This walkthrough covers the following steps:

  1. Set up topics

  2. Create a new project for the model

  3. Deploy the project

  4. Visualize the model results

Set up topics

You should already have a topic containing car engine data. You’ll use this as an input topic for the model. The model also needs an output topic, to send the processed data.

  1. Click the Topics icon topics in the left-hand menu.

  2. Click the CREATE TOPIC button, give your new topic a name — hard-braking — and click CREATE.

  3. Change the Persistence toggle to “ON”, to ensure data in the topic is persisted to the Data Catalogue.

At this point, you should have at least two topics: cars and hard-braking.

Create a new project for the model

You can use our sample model project as a template. You’ll get code assets for a basic model, customised to your specific environment. This includes certificates for remote sdk access, and details of the two topics you’ve set up.

  1. Click the Topics icon topics in the left-hand menu.

  2. Hover over the cars topic and click the Connect icon topic connect. You’ll see the Easy connect wizard which allows you to quickly create a project based on our sample code.

  3. Select PYTHON as your code language, then click NEXT.

  4. Select MODEL as your Template type, then click NEXT.

  5. Select cars as your input topic, then click NEXT.

  6. Select hard_braking as your output topic, then click FINISH.

At this point, you’ll be taken to the Model tab within the Library section. You should see the Data filtering project, with custom values for your username, workspace, topics, etc.

sample model project

In the code screenshot above, lines 30-40 (highlighted) contain code that drives the model. When you want to start your own project, using this sample code as a template, that’s the place to start implementing your own logic.

You can read a brief explanation of the sample project’s code in its README file.

  1. Click SAVE AS PROJECT and name your project brake-model, then click CREATE.

You’ll now be taken to the Develop section, where you should see a full file view of your project, alongside the Quix web IDE.

Deploy the project

  1. Click the DEPLOY button, then DEPLOY again to use the default setup

Your deployment will build and start running automatically.
  1. Once the brake model project is running, it will stay running, reacting to data from the cardata stream. To ensure data is available, run the cardata project again using the START button alongside that deployment. Unlike the brake-model project, it will run to completion, then stop.

Visualize the model results

When run, the model writes a HardBraking parameter to its output stream. You can visualise this data alongside data from the input stream to see how they relate.

  1. Click the Data icon data icon in the left-hand menu.

  2. Make sure you’re viewing “Locations” and that Mode is set to “Pipelines”.

Click the arrow to the left of your most recent cardata stream. You should see the cardata hard braking stream listed under “Models”, confirming the pipeline is set up correctly:

stream pipeline
  1. Hover over the cardata stream and click the visualize icon visualize icon.

  2. On the Visualize page, click the SELECT button next to “Parameters:” and select the Brake parameter from the cardata stream, and the HardBraking parameter from the hard braking stream, then click CLOSE.

You should see a waveform which demonstrates the correlation between the Brake and HardBraking parameters.

brake model waveform

Next steps

  1. Find out more about managing deployments.