Skip to content

Jupyter Integration

Installation

Terminal window
pip install niki[jupyter]

Quick Start

# Load the extension
%load_ext niki
# Monitor a cell
%%niki_watch
import scanpy as sc
adata = sc.read_h5ad("large_dataset.h5ad")
sc.pp.filter_cells(adata, min_genes=200)

When the cell completes, you’ll receive a notification with:

  • Execution time
  • Exit status
  • Captured output
  • Any matplotlib figures

Named Tasks

Give cells descriptive names:

%%niki_watch preprocessing_sample1
sc.pp.normalize_total(adata)
sc.pp.log1p(adata)
sc.pp.highly_variable_genes(adata)

Options

OptionDescription
--silent / -sSuppress local output
--no-plotsDon’t capture matplotlib figures
--priority P0|P1|P2Set notification priority

Examples

# Silent execution (notification only)
%%niki_watch --silent
model.fit(X_train, y_train, epochs=100)
# High priority notification
%%niki_watch critical_step --priority P0
results = expensive_computation()
# Skip plot capture
%%niki_watch --no-plots
for i in range(100):
plt.figure()
plt.plot(data[i])
plt.savefig(f"plot_{i}.png")
plt.close()

How It Works

  1. Output Capture: stdout/stderr are captured while still displaying in real-time
  2. Figure Detection: After cell execution, NIKI detects open matplotlib figures
  3. Context Gathering: Cell index and notebook name are included
  4. Notification: Data sent to NIKI daemon via HTTP

Requirements

  • NIKI daemon must be running: niki daemon start
  • IPython/Jupyter must be installed

Troubleshooting

Extension not loading

# Check if extension is available
import niki.jupyter
print(niki.jupyter.IPYTHON_AVAILABLE) # Should be True

No notifications received

  1. Check daemon is running: niki daemon status
  2. Check notification config: niki doctor