4.13 About Interpreters and Notebook Service Levels

An interpreter is a plug-in that allows you to use a specific data processing language backend.

For the Zeppelin Notebooks in Oracle Machine Learning UI, you use the SQL, PL/SQL, Python and R interpreters within an Oracle Database interpreter group, and the Markdown interpreter for plain text formatting syntax so that it can be converted to HTML. You use the Conda interpreter to connect to the Conda environment and work with Python third-party library packages.

To use the interpreters, you must use these directives at the beginning of the paragraph in a notebook
  • SQL — %sql
  • PL/SQL — %script
  • Python — %python
  • R - %r
  • Markdown — %md
  • Conda — %conda
Notebooks contain an internal list of service levels that define the order of the interpreters in an interpreter group. The default order of interpreter bindings in the Oracle Database interpreter group is:
  • low — Provides the least level of resources for in-database operations, typically serial (non-parallel) execution. It supports the maximum number of concurrent in-database operations by multiple users. The interpreter with low priority is listed at the top of the interpreter list, and hence, is the default.
  • medium — Provides a fixed number of CPUs to run in-database operations in parallel, where possible. It supports a limited number of concurrent users, typically 1.25 times the number of CPUs allocated to the pluggable database.
  • high — Provides the highest level of CPUs to run in-database operations in parallel, up to the number of CPUs allocated to the pluggable database. It offers the highest performance, but supports the minimum number of concurrent in-database operations, typically 3.
  • gpu — Provides GPU compute capabilities in a notebook through the Python interpreter with the database service level set to high. The memory settings is 8 GB (DDR4), by default. It is extensible up to 200 GB.
With respect to interpreter bindings, you can perform the following tasks:
  • Bind and unbind interpreters: If you do not bind any specific interpreter to your notebook, then you get the error message:
    Not supported interpreter <name of interpreter>
  • Set and re-order interpreter bindings. You may want to set and re-order interpreter bindings if you want to use a specific interpreter for a specific paragraph in a notebook. In that case, you have to select the specific interpreter for that paragraph.
  • Change the interpreter binding for any specific paragraph in a notebook
You must note the interpreter binding order in the following scenarios:
  • Notebook creation — When you create a notebook, the notebook inherits the initial interpreter binding order, which is low (default), medium, high.
  • Notebook import — When importing a notebook, the notebook inherits the defined interpreter bindings. However, after you import a notebook, ensure to check the order of the interpreter bindings and that the required interpreters are selected.
  • Notebook export — When exporting a notebook, the notebook inherits the defined interpreter bindings.
  • Notebook creation from templates — When you create a notebook from templates, the notebook inherits the default order of interpreter bindings.

4.13.1 Change Notebook Service Level

Notebook type corresponds to the ADB service levels — low, medium, high and gpu. These service levels affect parallelism in the database. The notebook type that is set for a notebook applies to all the paragraphs in that notebook.

Note:

In Notebooks Classic, the notebook type is referred to as the interpreter bindings. The notebook type gpu is not available in Notebooks Classic.
To use the interpreters, you must use these directives at the beginning of a paragraph in a notebook
  • SQL — %sql
  • PL/SQL — %script
  • Python — %python
  • R — %r
  • Markdown — %md
  • Conda — %conda
You can change notebook service levels in both the new Notebook and Notebooks Classic.

Change Notebook Service Levels in the new Notebook

  1. Open your notebook in the notebook editor.
  2. Click on the Update Notebook Type icon on the top right corner. The available notebook types are displayed. The current notebook type is indicated by a tick mark, and is also displayed next to the Update Notebook Type icon.

    Figure 4-49 ADB service levels as displayed in a notebook



    The Notebook Types (ADB service levels) are:
    • low —Provides the least level of resources for in-database operations, typically serial (non-parallel) execution. It supports the maximum number of concurrent in-database operations by multiple users. The interpreter with low priority is listed at the top of the interpreter list, and hence, is the default.
    • medium—Provides a fixed number of CPUs to run in-database operations in parallel, where possible. It supports a limited number of concurrent users, typically 1.25 times the number of CPUs allocated to the pluggable database.
    • high—Provides the highest level of CPUs to run in-database operations in parallel, up to the number of CPUs allocated to the pluggable database. It offers the highest performance, but supports the minimum number of concurrent in-database operations, typically 3.
    • gpu—Provides GPU compute capabilities in a notebook through the Python interpreter with the database service level set to high. The notebook memory setting is 32 GB (DDR4), by default. It is extensible up to 200 GB.
  3. To change the notebook type, click on the type that you want to select. In this example, let's click high. A confirmation message is displayed stating: Notebook Type is updated to "high".

    Note:

    The updated notebook type is applicable to all the paragraphs in the notebook. You cannot change the notebook type at the paragraph level.

    Figure 4-50 ADB service level - high



4.13.2 Verify Notebook Service Level

After changing the Notebook service level, you can use a SQL statement to view and verify the information. Notebook type, referred to as interpreter bindings in Notebooks Classic, corresponds to the ADB service levels — low, medium, high and gpu. These service levels affect parallelism in the database.

For Python notebooks, the interpreter binding is used for all python paragraphs.

Note:

For Python notebooks, do not override the interpreter binding at the paragraph level.

Verify Notebook Service Level in a Notebook

  1. Open the notebook for which you want to verify the updated notebook type.
  2. Run the following SQL statement:
    %sql
    SELECT SYS_CONTEXT ('USERENV', 'SERVICE_NAME') FROM DUAL;
  3. Click Run. The SQL statement returns the following information about the updated notebook type, as shown in the screenshot below:

    Figure 4-51 ADB service level information as displayed in a notebook


    ADB service level information as displayed in a notebook

You can see that the service level is now displayed as high. In this example:
  • HMUGVWHGDA3DBYM is the tenant name
  • OMLLABS104047 is the database name
  • high is the ADB service name
  • adb.oraclecloud.com is the domain

Verify Interpreter Bindings in Notebooks Classic

  1. Open the Notebooks Classic for which you want to validate the updated interpreter bindings.
  2. Run the following SQL statement:
    %sql
    SELECT SYS_CONTEXT ('USERENV', 'SERVICE_NAME') FROM DUAL;
  3. The SQL statement returns the following information about the updated interpreter bindings, as shown in the screenshot below:

    Figure 4-52 ADB service level information as displayed in Notebooks Classic


    ADB service level information as displayed in Notebooks Classic

You can see that the service level is now displayed as high. In this example:
  • HMUGVWHGDA3DBYM is the tenant name
  • OMLLABS104047 is the database name
  • high is the ADB service name
  • adb.oraclecloud.com is the domain