Skip to Content
Technical Articles
Author's profile photo Sourabh Shekhar Sharma

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.

Block%20Diagram%20to%20demonstrate%20the%20flow%28Self%20Created%29

 *Created for this blog post

Prerequisites:

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.

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.
  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.
  6. Application can be opened using application route :

Configure the application on Launchpad:

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

Conclusion:

Demonstration:

  1. Configured application is deployed to the launchpad.
  2. Application will display a link to the Flask frame-work python Application. We can click on it to display the details as well.
  3. We can see different graphs showing the correlation between the features.

Congratulations we have finally completed the end to end implementation of application development with SAP Business Technology Platform.

In case of errors do let me know in the comments 🙂 

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Peter Baumann
      Peter Baumann

      Hi Sourabh Shekhar Sharma!

      Thank you providing and describing this example in this blog. I wonder if you have thought about to also use hana-ml library instead of seaborn and matplotlib for exploratory analysis? Any experiences here?

      Author's profile photo Sourabh Shekhar Sharma
      Sourabh Shekhar Sharma
      Blog Post Author

      Hi Peter,

      Welcome

      Yes you are right.hana-ml is a powerful and versatile python package for exploratory analysis and there are numerous resources available, however I wanted to provide another perspective in conjunction with currently available resources  🙂 

      One Additional prerequisite for using hana-ml are the below mentioned roles:(SAP HANA PAL):

      • AFL__SYS_AFL_AFLPAL_EXECUTE
      • AFL__SYS_AFL_AFLPAL_EXECUTE_WITH_GRANT_OPTION

       

      Author's profile photo Hemant Upadhyay
      Hemant Upadhyay

      Hi Sourabh,

      Indeed a really nice blog, but I am facing some issue below are some attached errors, I have created my own similar application issue is same now I tried deploying the exact same application of yours, its still the same. Could you please help?

      Thank & Regards,

      Hemant

      Author's profile photo Sourabh Shekhar Sharma
      Sourabh Shekhar Sharma
      Blog Post Author

      Thanks Hemant, by examining your logs the issue might have occured during DB table creation in HANA.

      I can suggest you two things:

      1. Please check the data type of the columns CO2 and Population in hana db table, it should be numeric or float.
      2. If the first point does not work, you can try to convert the data in CO2 and Population into Numpy array.