Unit 3. Preparing Codes


You can use the sample code file provided in this tutorial to calculate the power loss of offshore wind turbines in a notebook instance in AI Lab. This unit introduces how to upload the sample code file to a Notebook instance.

Step 1. Downloading the Code File


Download and save this code file, including the following files.


Number

Code File

Description

1

power-loss.ipynb

A Notebook file with necessary codes to calculate power losses in AI Lab.

2

power-loss.py

A Python file with necessary codes to calculate power losses in AI Pipelines.

3

requirements.txt

A TXT with requirements for designing calculation pipelines.

Step 2. Creating a Notebook Instance


  1. Log in to EnOS Management Console and select AI Studio > AI Lab on the left navigation pane.

  2. Select New Instance on the Notebook Instance tab.

  3. Configure the following information in the New Instance page.


    Field

    Description

    Instance Name

    Enter power-loss.

    Resource Pool

    Select the AI-Container resource of your OU.

    Name/Path

    Select a pyspark image.

    CPU Request

    Enter 0.01.

    CPU Limit

    Enter 0.5.

    Memory Request

    Enter 0.5.

    Memory Limit

    Enter 2.

    Workspace Storage

    Select power-loss-lab, the PVC storage requested in Unit 1.

    Mode Hadoop PVC

    Enable this function.


  4. Select Confirm to create the notebook instance.


For more information on Notebook instances, see Manage Notebook Instances.

Step 3. Uploading the Code File to the Notebook Instance


  1. Select the power-loss instance from instance list.

  2. Select the folder icon i_folder to add a new folder and enter power_loss as the folder name.

  3. Open the power_loss folder you created in the power-loss instance page.

  4. Select the up arrow icon i_upload to upload the file you downloaded in Step 1.

(Optional) Step 4. Uploading the Code File to Internal Storage


If you need to save the code file to internal storage for archiving or backup, or you need to use the file in AI Pipelines operators such as PythonEx, NotebookEx, ShellEx, PythonCode, and ShellCode, upload the code file to internal storage by the following steps:

  1. Select the plus sign icon (+) from the left panel of the power-loss instance, then select Other > Terminal to open a terminal page in the Launcher tab.

  2. Run pip install eap-notebook in the terminal to install dependencies.

  3. Run the following codes to upload your code file:

    • eap-notebook push -p power_loss: add the file to the power_loss folder, and replace the file with the same name if the file name already exists.

    • eap-notebook push -r power_loss: remove all files in the power_loss folder then upload the file.

  4. Run the following codes to view your code file:

    • eap-notebook ls -p power_loss: list all files in the power_loss folder only.

    • eap-notebook ls -rp power_loss: list all files in the power_loss folder and its sub-folders.


For more information, see Upload Model Code Files to the Internal Storage.

Next Unit


Unit 4. Calculating Power Loss