Skip to main content

Running Jupyter Executables

This article explains how input fields work, and how to properly trigger your Jupyter notebook.

S
Written by Satya Singh
Updated over 2 months ago

Jupyter Executables let you turn a Jupyter notebook into a reusable, parameterized action that can be run from multiple places in the product (Jupyter Hub, Labsheets, manifests, and Glue).

Here is the workflow to run a Jupyter Executable:

  • You define inputs in the Executable UI (text fields, dropdowns, auto-fed rows, files, etc.)

  • Those inputs are passed to the notebook in order

  • Inside the notebook, you read them using standard Python input() calls

Defining Inputs in the Executable

When creating a new executable:

  1. Go to Labsheets > Jupyter Executable in the left navbar

  2. Create New > Executable

  3. Fill out the Name, Script, and Description

  4. Add one or more input fields (text or dropdown). This represents what you want the user to specify when running the script.

  5. Optionally enable Automatically Use Selected Labsheet Rows as Inputs. This will allow the users to pass the comma separated IDs of the selected rows to the first Text type input.

In the above example, we have a

  • text field called "Sample ID", which takes the given ID as free-form text input

  • dropdown field called "QC Run Mode," where the user can specify "Full QC," "Identity Only," or "Purity Only."

Using Inputs Inside the Jupyter Notebook

Inside your Python notebook, read inputs in the same order they were defined. For example, in the screenshot above, we have a Sample ID input, and a QC Run Mode input. These inputs are passed in order to the notebook. You can ingest this Pythonically as follows:

# Notebook Inputs
sample_id = input()
qc_run_mode = input()

Running Jupyter Executables from Different Places

Jupyter Executables can be triggered from several locations. Each of these locations has special inputs that they pass the Jupyter Script based on where they are triggered.

Location

Where to Run

Notes on Input

Jupyter Scripts Page

Go to Side Navbar > Labsheets Dropdown > Jupyter Notebook. You will see a list of all the scripts you have written. Click Run to open the input modal.

All configured inputs must be manually entered.

Labsheets

Go to a Labsheet of your choice, and click Jupyter Notebook in the top right of the screen. Click on the desired script.

If you selected "Automatically use selected labsheet rows as inputs" while creating the script, the IDs of any selected rows will be autopopulated as comma-separated values in the first Text input. The user must configure each other inputs.

Otherwise, the script will not populate anything and you will have to manually specify all inputs.

ELN Page

Go to a Labspace page, and click the triple dot dropdown at the top right of the page. Then click on the revealed Jupyter Notebook button to open a modal with all scripts displayed. Then, click on your desired script.

The first Text input will be auto-populated with the HRID of the Labspace Page. The user must configure the other inputs.

Manifests

Go to a Manifest, and click on Table View. At the top right of the page, click on the Jupyter Notebook button to open a modal with all scripts displayed. Then, click on your desired script.

The first Text input will be auto-populated with the HRID of the Manifest. The user must configure the other inputs.

GLUE

Go to the GLUE dashboard, and create a new connection. Select the desired script from the Data Transformation section.

When this script runs, it will take the file that triggered the run, and insert it as a new row into the system generated Files Repository. It will pass the UUID of the newly generated row as input to the script, where you can use APIs to retrieve the respective file. As this call is made by the system, no other inputs will be sent.

Did this answer your question?