Variables
You can reference variables set by other python cells on the global scope.Cell Results
All cells - with the exception of Markdown and Python cells, set their output variable ot a CellResult object.Output
Ways to output information from a python cell:- Print to stdout/stderr
- Display objects via
IPython.display.display() - Return a display object
- Return a
CellResultobject - Raise an exception
Examples
Execute arbitrary Python code for custom logic:Cell Parameters (@param)
NOTE: See Form Cells for the preferred method of adding dynamic user inputs Python cells support inline parameter definitions using the@param comment syntax. Parameters create interactive form inputs that users can modify before running the cell, without editing the code directly.
Use @param when you need to parameterize a single cell’s behavior. For inputs that need to be shared across multiple cells, use form cells instead.
Basic Syntax
Supported Types
String
Dropdown (Static Options)
Provide a JSON array of choices:Boolean
Number
For integers:Secret
Creates a dropdown of available secrets in the workspace:Connection
Creates a dropdown of available connections:Parameter Options
| Option | Description |
|---|---|
type | Parameter type: string, boolean, integer, number, secret, connection |
label | Display label for the form input |
description | Help text shown below the input |
placeholder | Placeholder text for string inputs |
min | Minimum value for number/integer types |
max | Maximum value for number/integer types |
required | Whether the field must have a value (true/false) |
Dynamic Dropdowns with Selectors
For dropdowns populated dynamically from data, use selectors. Selectors must be created in a prior cell usingSpinContext.create_selector().
Cell 1: Create the selector
Complete Example
Packages
The following python packages are pre-installed in the spin runtime container.| Package | Version | Purpose |
|---|---|---|
| datadog-api-client | ^2.29.0 | Datadog integration |
| pyyaml | ^6.0.2 | YAML parsing |
| splunk-sdk | ^2.1.0 | Splunk integration |
| fastapi | ^0.100.0 | API framework |
| httpx | ^0.25.0 | HTTP client |
| uvicorn | ^0.25.0 | ASGI server |
| websockets | ^11.0.0 | WebSocket support |
| jupyter-client | ^8.0.0 | Jupyter kernel communication |
| notebook | ^7.0.0 | Jupyter notebook |
| cryptography | ^42.0.0 | Crypto operations |
| pyjwt | ^2.10.1 | JWT handling |
| openai | ^1.91.0 | OpenAI API client |
| sqlalchemy | ^2.0.0 | SQL toolkit/ORM |
| pandas | ^2.2.0 | Data analysis |
| psycopg2-binary | ^2.9.0 | PostgreSQL driver |
| pymysql | ^1.1.0 | MySQL driver |
| clickhouse-connect | ^0.9.0 | ClickHouse driver |
| apscheduler | ^3.10.4 | Task scheduling |
| boto3 | ^1.28.0 | AWS SDK |
| google-cloud-storage | ^3.7.0 | GCS SDK |