Friday 8 April 2022

Deploy Machine Learning/Exploratory Data Analysis Models to SAP Business Technology Platform

DISCLAIMER: Please note that the content of this blog post is for demonstration purpose only, it should not be used productively without impact evaluation on production environment.

Introduction:

In this blog, we will implement an end to end solution for Python based web application(Flask) on SAP Business Technology Platform.

◉ We will use a cloud based HANA DB, and will leverage python package hdbcli to fetch the relevant data using SQL statement.

◉ We will be using python data science packages such as pandas,seaborn and matplotlib to display various graphs showing Exploratory Data Analysis.

◉ Node js will be used as a single point of entry to access our Python Application.Python package xssec will be used for authentication.

◉ Finally we will deploy this application on Launchpad.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

Prerequisites:


◉ Create a SAP HANA Cloud Database (Service : hana-cloud-trial), below mentioned settings should be enabled:

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

◉ Data Source : CO2 and Greenhouse Gas Emissions Country Profiles, we can use the CSV file for uploading in SAP HANA Database Explorer. [ https://ourworldindata.org/co2-and-other-greenhouse-gas-emissions ]

◉ Github Repo: Machine Learning Model






Above references/links will be used for implementing the complete implementation steps.

Main Part : 


Data Preparation:

1. Firstly lets upload the downloaded CSV file(owid-co2-codebook.csv) into SAP HANA Cloud database using Database Explorer as mentioned in above tutorial 1.

2. Make country and year as the primary key.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

Connecting Python with SAP HANA Cloud:

1. Connect to the SAP HANA Cloud DB with the help of tutorial 2.

2. Download the GITHUB files from here, for reference purpose.

3. Replace the USERNAME,PASSWORD  and URL in file env_cloud.json with your instance details.

4. URL can be retrieved from Copy SQL Endpoint by removing port number.Provide port number in port field.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

5. Update manifest.yml file with the application names as per your needs.

6. Update requirements.txt with the python packages you want to use while developing the model.

7. Update runtime.txt with the python runtime version supported.

Deployment of Application:

1. Install CLI with the help of tutorial 4, please note cf.exe file should exist in the same directory as you have manifest.yml file.

2. Login to Cloud Foundry using commands cf login or cf login –sso

3. Push the extracted and modified folder containing above files using command cf push

4. In case of successful push , you will be able to see both the applications running in BTP Cockpit.

5. In case of any runtime error in python , error log can be inspected in SAP BTP.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

6. Application can be opened using application route :

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

Configure the application on Launchpad:

i. Configure the launchpad using tutorial 5 including Application/Catalog and Group.
ii. Provide application route as per your application in URL:

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

Conclusion:


Demonstration:

1. Configured application is deployed to the launchpad

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

2. Application will display a link to the Flask frame-work python Application. We can click on it to display the details as well.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

3. We can see different graphs showing the correlation between the features.

SAP HANA, SAP HANA Cloud, SAP HANA Learning, SAP HANA Certification, SAP HANA Learning, SAP HANA Career, SAP HANA Jobs, SAP HANA Skills, SAP HANA Preparation Exam

No comments:

Post a Comment