X

Cloudera Tutorials

Optimize your time with detailed tutorials that clearly explain the best way to deploy, use, and manage Cloudera products. Login or register below to access all Cloudera tutorials.

Blog Don’t Get Left Behind in the AI Race: Your Easy Starting Point is Here Read now

 

Introduction

 

See for yourself how easy it is to create a simple inventory management web application using Cloudera Operational Database (COD) and Cloudera Machine Learning (CML) on Cloudera Data Platform (CDP).

 

 

Prerequisites

 

  • Have access to Cloudera Data Platform (CDP) Public Cloud
  • Have created a CDP workload User
  • Ensure proper CML role access
    • MLUser: ability to run workloads
    • MLAdmin: ability to create and delete workspaces

 

 

Watch Video

 

The video below provides a brief overview of what is covered in this tutorial:

 

 

Download Assets

 

There are two (2) options in getting assets for this tutorial:

  1. Download a ZIP file

It contains only necessary files used in this tutorial. Remember its location. No need to unzip the file.

  1. Clone our GitHub repository

It provides assets used in this and other tutorials; organized by tutorial title.

 

 

Setup Operational Database

 

If your environment doesn’t already have a database created, let’s create one.

Select Operational Database from Cloudera Data Platform (CDP) home page:

 

cdp-homepage-operational-database

 

Two simple pieces of information are needed to create a database - the Environment name and Database name. For example:

  1. Environment: <your environment name>
  2. Database Name: sample-opdb
  3. Select Create Database

 

opdb-create-database

 

Get Database Connection URL

 

  1. Open your database by selecting its name, sample-opdb.
  2. Select Phoenix Python tab
  3. Copy the Phoenix Python URL
  4. Later in the tutorial, we will use this URL to configure our web application to connect to this database.

 

opdb-get-connection-url

 

Setup Machine Learning

 

Provision ML Workspace

 

If your environment doesn’t already have a Machine Learning Workspace provisioned, let’s provision it.

Select Machine Learning from Cloudera Data Platform (CDP) home page:

 

cdp-homepage-machine-learning

 

In the ML Workspaces section, select Provision Workspace.

Two simple pieces of information are needed to provision an ML workspace - the Workspace name and the Environment name. For example:

  1. Workspace Name: cml-tutorial
  2. Environment: <your environment name>
  3. Select Provision Workspace

 

cml-workspace-provision

 

Create Project

 

Beginning from the ML Workspaces section, open your workspace by selecting its name, cml-tutorial.

Select New Project

Complete the New Project form using:

  1. Project Name: opdb-web-application
  2. Project Description:
    Simple inventory management system using Cloudera Operational Database (COD)
  1. Initial Setup: Local Files
    Upload or Drag-Drop tutorial-files.zip you downloaded earlier
  2. Select Create Project

 

cml-new-project

 

Application Configuration

 

Beginning from the Projects section, select the project name, opdb-web-application.

Select New Session and complete the session form:

  1. Session Name: configuration
  2. Editor: Workbench
  3. Kernel: Python 3
  4. Edition: Standard
  5. Resource Profile: 1 vCPU / 2 GiB Memory
  6. Select Start Session

 

cml-start-new-session

 

Let’s make a minor configuration change and install the dependencies:

  1. Modify the configuration file, config.ini.template, with the Phoenix Python URL we retrieved earlier and username/password.
    [COD]
    Username=<cdp_workload_username>
    Password=<cdp_workload_password>
    Url=<URL from Phoenix Thin JDBC connection>
    Serialization=PROTOBUF
    Authentication=BASIC
    

    Save the file as config.ini: File > Save As > config.ini

  2. Install the dependencies by issuing the following statement in the command-line:
  3. !pip3 install -r requirements.txt

 

cml-application-configuration

 

In the same session (or a new one), let’s create and populate a table that we’ll be using in our application.

Select file db_setup.py and click on

 

cml-run-db-setup

 

Create and Run Web Application

 

Let’s create our inventory management system web application.

Beginning from the Applications section, select New Application and fill out the form as follows:

  1. Name: opdb-web-app
  2. Subdomain: opdb-web-app
  3. Description: Simple inventory management system
  4. Script: main.py
  5. Kernel: Python 3
  6. Select Create Application

 

cml-new-application

 

After a few moments, the application is up and running. Select the application’s name, opdb-web-app, to open the web application.

 

cml-run-application

 

This web application accepts a part number and quantity. It first verifies that the part exists, if it does, it will decrease/increase the quantity on hand. For example:

A positive quantity value, decreases the quantity on hand.

A negative quantity value, increases the quantity on hand.

 

web-application

 

Summary

 

Congratulations on completing the tutorial.

While this was a simple example of a web application, I hope it sparks your imagination and inspires other creative solutions.

 

 

Further Reading

 

Videos

Blogs

Meetup

Other

 

Your form submission has failed.

This may have been caused by one of the following:

  • Your request timed out
  • A plugin/browser extension blocked the submission. If you have an ad blocking plugin please disable it and close this message to reload the page.