Skip to content

Latest commit

 

History

History
161 lines (93 loc) · 6.72 KB

setup-bas.md

File metadata and controls

161 lines (93 loc) · 6.72 KB

Setup SAP Business Application Studio and a dev space

[1/10] Use SAP Business Technology Platform

It is assumed that you have access to the SAP Business Technology Platform - either via your organization or via a free trial, as described in prerequisites.

If you are using SAP BTP Trial, then open it: https://hanatrial.ondemand.com/

[2/10] Open SAP Business Application Studio

If you are using the SAP BTP free trial, then open SAP Business Application Studio trial from the "Quick Tool Access" section.

Open BAS Trial

Should you have issues opening SAP Business Application Studio (for example when you have had the account for a long time), then check the steps in this tutorial - Set Up SAP Business Application Studio for Development

[3/10] Create a new Dev Space for CodeJam exercises

Go to your instance of SAP Business Application Studio (further referred to as "BAS").

For this SAP CodeJam exercise create a new Dev Space called CodeJamHANAML of a kind Basic with an additional extension Python Tools in BAS:

Screen element Value
Dev Space name CodeJamHANAML
Kind Basic
Additional extension Python Tools

Create a Dev Space

You should see the dev space STARTING.

Dev Space is Starting

Wait for the dev space to get into the RUNNING state and then open that dev space.

Dev Space is Running

[4/10] Clone the exercises from the Git repository

Once your dev space is open in the BAS, use one of the available options to clone this Git repository with exercises using the URL 👇🏼

https://github.com/SAP-samples/hana-ml-py-codejam.git

☝🏻 into your project directory in the BAS Dev Space.

Clone the repo

Click Open to open a project in the Explorer view.

Open a project

[5/10] Open the Workspace

The cloned repository contains a file codejam.code-workspace and therefore you will be asked, if you want to open it. Click Open Workspace.

Automatic notification to open a workspace

If you missed the previous dialog, then you can go to the BAS Explorer, click on the codejam.code-workspace file, and then click on the Open Workspace.

Open a workspace

You should see:

  • CODEJAM as the workspace at the root of the hierarchy of the project, and
  • hana-ml-py-codejam as the name of the top level folder.

Open a workspace

[6/10] Check that the required extensions are installed

SAP provides you with a mechanism to access third-party sites to view and download open-source, 3rd party or its own tools, libraries, or software components ("Extensions") to dev spaces in SAP Business Application Studio. Using this mechanism, you can view and install VS Code Extensions from the VSX Open Registry at your own risk.

Go to Extensions using the activity bar (the left-most bar in the IDE) and type @builtin Py in the search bar.

You should see Python and Jupyter extensions installed already.

Extensions to install

[7/10] Create a virtual environment with venv from a command line

The built-in venv module in Python provides support for creating lightweight “virtual environments”. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.

Open a built-in terminal in BAS, eg. using the menu option.

Open a terminal

Make sure you are in the /home/user/projects/hana-ml-py-codejam directory, e.g., using the pwd command.

Use venv to create a virtual environment for your project in the new directory ~/projects/hana-ml-py-codejam/env by using the following command:

python3 -m venv ~/projects/hana-ml-py-codejam/env --upgrade-deps

Check that the virtual environment was successfully created:

ls -l ~/projects/hana-ml-py-codejam/env

Create an venv

[8/10] Activate the virtual environment env from a command line

Activate the virtual environment using the following command:

source ~/projects/hana-ml-py-codejam/env/bin/activate

You should see you are in a virtual environment as indicated by the (env) prefix in a shell's prompt.

Activate the venv

[9/10] Install required Python packages in the virtual environment

Install:

  1. the ipykernel package to be able to run Python code in a Jupyter extension using the following command:
python -m pip install --require-virtualenv --no-cache-dir ipykernel

Install ipykernel

  1. the Python machine learning client for SAP HANA (hana-ml) and other required dependencies listed in https://help.sap.com/doc/cd94b08fe2e041c2ba778374572ddba9/2024_1_QRC/en-US/Installation.html#installation-guide using the following command:
python -m pip install --require-virtualenv --no-cache-dir -U 'hana-ml==2.22.*' ipywidgets 'jinja2>=3.0.0' pydotplus graphviz 'shapely>=1.7.1' 'matplotlib' plotly setuptools

Install hana-ml and dependencies

  1. Install Jupyter's own utilities for programmatic work with notebook documents: nbformat to be able to run one notebook from another, and nbconvert to be able to clean the output of notebooks, eg. before pushing to the Git repository, using the following command:
python -m pip install --require-virtualenv --no-cache-dir nbformat nbconvert

Install nbformat and nbconvert

[10/10] Open the "Check Setup" notebook from the exercises

In your BAS hide the terminal.

Hide the terminal

Go to Explorer and open a exercises/010-check_setup.ipynb notebook.

The notebook should open in a Jupyter extension.

Next, select a kernel env (the virtual environment you set up earlier) from Python Environments.

Select the kernel

The kernel should be set in a few seconds. You should get messages about Jupyter server processes started in the background ready to execute code from your notebook.

Ready to go!

🤓 Now you are ready to use SAP Business Application Studio to go one-by-one through exercises!

Engage, learn and enjoy!