Datalore 2024.2 Help

Kernel and reactive mode

When creating a notebook, you select a kernel and a computation mode. The chapters provide information about kernel management and computation mode options, specifically Datalore's reactive mode.

Kernel

Kernel is the element that runs the cells in your notebook. At the moment, Datalore provides kernels for Python, Kotlin, Scala, and R.

Select kernel for a new notebook

You choose which kernel to choose in the new notebook on the Kernel tab of the New notebook dialog.

Kernel and mode selection

    Manage kernel in the editor

    You can interrupt or restart the kernel at any time working in the editor. There are two interfaces that you can use: Kernel menu and Computation tool.

    1. Go to Main menu | Kernel.

    2. Select one of the options from the menu:

      • Interrupt kernel: used to stop the currently running task without stopping the kernel.

      • Restart kernel: used to stop and start the kernel again. The main reason why you might need this is to clean the runtime environment of old variable data.

    1. Open the Computation tab from the left-hand toolbar.

    2. Under Kernel, click one of the icons:

      • Interrupt kernel: used to stop the currently running task without stopping the kernel.

      • Restart kernel: used to stop and start the kernel again. The main reason why you might need this is to clean the runtime environment of old variable data.

    Computation tab

      Reactive mode

      Besides the standard Jupyter mode, Datalore offers reactive mode, an alternative method for managing your notebook calculations.

      Reactive mode is a reproducible mode that enforces a fixed top-down evaluation order and automatic recalculation of the cells below the modified one. It has the following key benefits:

      • Interactivity support: when combined with interactive controls, reactive mode allows you to turn notebooks into interactive reports.

      • Automatically restored notebook state: with reactive mode enabled, notebook state is saved after each cell evaluation to ensure automatic recalculation of only those cells that are below the modified one. This can be particularly helpful when working on big projects.

      • Easy experimenting: reactive mode keeps the notebook state consistent by automatically recalculating the cells below the modified one. This means you can edit any cell in your notebook and quickly have all affected cells updated.

      • Switching machines: switch between machines without losing the variables state. This allows you to start with writing code on a basic machine, switch to a more expensive GPU machine only to perform some computation-intensive task, and then switch back to a basic machine. With Jupyter mode selected, switching between machines clears the variables, which means that you would have to recalculate all the cells.

      Choose reactive mode for a new notebook

      You choose reactive mode on the Kernel tab of the New notebook dialog.

      Kernel and mode selection

        Enable reactive mode in the editor

        You can enable reactive mode at any time working in the editor. There are two interfaces that you can use: Kernel menu and Computation tool.

        1. Go to Main menu | Kernel.

        2. Select the reactive mode option.

        3. Click the OK button in the Change computation mode confirmation window.

        1. Open the Computation tab from the left-hand toolbar.

        2. Under Kernel, click switch the reactive mode toggle.

          Computation tab
        3. Click the OK button in the Change computation mode confirmation window.

          Handle connections to ensure reactive mode performance

          Expand the code blocks below to view examples of how to handle connections to make sure reactive mode works properly.

          Socket library
          import socket def open_connection(host='jetbrains.com', port=80): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = (host, port) print(f'connecting to {server_address}') sock.connect(server_address) return sock sock = open_connection() print(f'Connected to jetbrains.com: {sock}') sock.close()
          Requests library
          import requests def test_session(): s = requests.Session() s.headers.update({'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1'}) url = "http://httpbin.org/get" r = s.get(url) s.close() return r print(test_session().text)
          Last modified: 29 May 2024