OpenBI Docs Buy

Steps and the kernel

A notebook’s steps run one at a time in its kernel, which keeps what each step made for the next. This page is how that works: what a step sees and shows, variables, parameters, errors, and interrupting and restarting.

The kernel

Each open notebook has a kernel: a process of its own that the studio starts with the first step you run. It talks to the engine that has the project’s model open, so OAX and SQL steps answer as the model does, with its roles. A step that brings the kernel down takes only the kernel with it, never the studio; the next run starts a new one.

The kernel writes numbers and dates the same way on every computer, whatever its language settings: 1,283,161 and 2025-12-31 in a step’s output and in its own $"{n:N0}", so a notebook and its paper read the same in Oslo and in Copenhagen.

What a C# step sees

  • The library, every type of OpenBI.Notebooks without a using (see the library reference), and OR-Tools’ own classes by their full names.
  • .NET’s usual namespaces without a using either: System, System.Linq, System.Collections.Generic, System.Globalization, System.Text, System.IO, System.Net.Http, System.Threading.Tasks, System.Diagnostics, System.Text.RegularExpressions and System.Text.Json.
  • Functions without a prefix: Dax(…) and Sql(…) query the model, Network(…) measures a network, TikZ(…) draws a figure, Display(…) shows values and Status(…) a line of progress (see KernelGlobals).
  • The variables of every step run before it.

What a step shows

An OAX or SQL step shows its rows. A C# step shows its last expression when it has no semicolon, and anything it passes to Display; tables, charts, metrics, verdicts, plans and networks each show as themselves. Console.WriteLine prints under the step, and Status shows how far a long step has come while it runs:

// Console.WriteLine prints under the step; Status shows progress while it runs
foreach (var r in soFar.Preview.Rows)
{
    Status($"{r.Text("Product")}…");
    Console.WriteLine($"{r.Text("Product"),-8} {r.Number("Liters"),12:N0}");
}
Cider         111,541
IPA           125,172
Lettøl         62,791
Pils          380,304

Variables

An OAX or SQL step’s rows become a variable named after the step; a C# step’s var makes one. They live until the kernel restarts. A later step can use them, or make a variable of the same name again:

// a variable lives until the kernel restarts; a later step changes it only by assigning it again
var total = soFar.Preview["Liters"].Sum();
total / soFar.Preview.Count
169,952

The Variables pane lists each one with its type and a line about its value; notebook_read gives an agent the same list. A step whose code changed since it ran is marked so, and the steps that use what it makes as out of date: run from it again.

Parameters

An OAX step can take parameters, written in its parameters box as asOf = 2024-12-31 (several with commas) and used in the query as @asOf. A value is a date (2024-12-31, or with a time), a number, true or false, or text:

// liters by product up to a date: @asOf is a parameter
EVALUATE
SUMMARIZECOLUMNS (
    Products[Product],
    FILTER ( ALL ( Sales[Month] ), Sales[Month] <= @asOf ),
    "Liters", [Liters sold]
)
ProductLiters
Cider111,541
IPA125,172
Lettøl62,791
Pils380,304

With parameters, the step’s variable is the query itself (a DaxQuery), not only its rows: Preview is the rows at the step’s values, and C# can run it again at others. Where a table is wanted, the query stands for its rows.

// the same query at other dates: soFar is the query, not only its rows
var a = soFar.At(new DateTime(2025, 12, 31));
var b = soFar.Run(("asOf", new DateTime(2026, 6, 30)));
Display(a, b);
$"{soFar.Preview["Liters"].Sum():N0} liters by the end of 2024, {a["Liters"].Sum():N0} by the end of 2025"
ProductLiters
Cider213,051
IPA235,508
Lettøl119,421
Pils715,181
ProductLiters
Cider262,847
IPA289,264
Lettøl148,056
Pils880,020
679,808 liters by the end of 2024, 1,283,161 by the end of 2025

This is how a prediction learns only from the past: the same query at each date gives what was known about each customer then (see Learning). SQL steps take no parameters; in C#, Sql($"…") and Dax($"…") write values in braces as literals (see Data in and out).

Errors and hints

A step that fails shows its error under it, with the line of the step it points at, and Run all stops there. When a C# step names something the library doesn’t have, the error says what the type does have that is nearest, and where to read the rest:

soFar.Preview["Liters"].Summ()
Line 1: 'Column' does not contain a definition for 'Summ' and no accessible extension method 'Summ' accepting a first argument of type 'Column' could be found (are you missing a using directive or an assembly reference?). Column has Sum, Name, Item, Number. analytics_catalog(api: "Column") lists its members; analytics_catalog(goal: "…") finds the recipe for a goal.

An error the step throws while it runs says its line too (Line 3: …). An agent gets the same message, and fixes the step from it.

Interrupt and restart

  • Interrupt stops the running step. Every loop in a C# step checks for it at each turn, and so do OpenBI’s own calls, so a step stops where it is.
  • A step stuck somewhere that doesn’t check, a call into another library for instance, is stopped by Restart kernel. Restarting starts a new kernel with every variable gone: run the steps again, or Run all.
  • A kernel that ended by itself is replaced at the next run.

An agent has the same two: notebook_interrupt and notebook_restart (see Agents and notebooks).

Text and TikZ steps

A Text step is Markdown: headings, lists, bold, italic and code. It runs nothing; its first heading is the paper’s title and the text before the first section its abstract. A TikZ step is a figure in LaTeX (TikZ, pgfplots and the like), compiled on this computer, with nothing sent anywhere; its name is its caption (see Charts and visuals).

Last updated · OpenBI Studio 0.3.78