OpenBI Docs Buy

Steps and the kernel

What a C# step sees without a prefix (queries on the model, Display, Status, TikZ), OAX and SQL written with interpolated values, how values are shown under a step, and dates.

KernelGlobals

public class KernelGlobals

What C# steps see without a prefix: Dax() and Sql() on the open model, Display() and Status(). (Steps also see the OpenBI.Notebooks types: Table, LightGbm, Metrics, Chart, Dates, Models, Output.)

Constructors

Its constructors: KernelGlobals().

Methods

Table Dax(string query)
Runs an OAX query on the model.
Table Dax(DaxText query)
Runs an OAX query written with $"…": dates, numbers and lists in braces become OAX literals.
Table Sql(string sql)
Runs DuckDB SQL over the project's sources and the model.
Table Sql(SqlText sql)
Runs SQL written with $"…": dates, numbers and lists in braces become SQL literals.
Network Network(string table, string from, string to, string? weight = null, bool directed = false)
A network measured from a table of edges in the model, on the rows this user may see: each node's degree, weight, PageRank, betweenness, community, component, k-core, cut point and place, and the edges. Network("Sales", "Sales[CustomerKey]", "Sales[ProductKey]", weight: "Sales[Liters]"); the table may be any OAX table expression (FILTER(Sales, …)), the ends and the weight OAX expressions on its rows.
DisplayData TikZ(string code, string? title = null)
A TikZ picture (LaTeX, as papers draw figures), compiled offline by the engine: TikZ(@"\draw[->] (0,0) -- (2,1);", title: "…"). A TikZ step does the same with the code as it is.
void Display(params object?[] values)
Shows values under the step: tables, charts, metrics, text.
void Status(string text)
A line of progress under the running step.

Notebook

public static class Notebook

The running notebook: steps call it to show values and report progress.

Properties

static INotebookHost? Host { get; set; }
The host of the step running now (null outside a notebook: displays go nowhere).

Also: static CancellationToken Interrupted { get; }.

Methods

static void CheckInterrupt()
Stops a step the person interrupted (loops call it; the kernel adds it to C# loops).

Also: static void Display(params object?[] values), static void Status(string text).

DisplayData

public sealed class DisplayData

What a step shows: one value in one or more formats (MIME type → content), as Jupyter keeps outputs.

Constructors

Its constructors: DisplayData(IDictionary<string, JsonNode?> formats), DisplayData(string text).

Properties

IReadOnlyDictionary<string, JsonNode?> Formats { get; }
MIME type → content: text/plain, text/html, image/svg+xml, application/vnd.openbi.table+json, …

Also: string Text { get; }.

Methods

Its methods: JsonObject ToJson(), static DisplayData FromJson(JsonObject o).

Formatter

public static class Formatter

How values are shown: a table as a grid, a chart as a chart, a metric as a number.

Fields

const string VisualMime = "application/vnd.openbi.visual+json"
A report visual (Visual): {html | page, height, title}; the studio draws it with the report runtime.
const string DiagramMime = "application/vnd.openbi.diagram+json"
A diagram (Diagram: TikZ): {kind, title}, beside its picture (image/png) and its PDF (application/pdf).

Also: const string TableMime = "application/vnd.openbi.table+json", const string ChartMime = "application/vnd.openbi.chart+json", const string MetricMime = "application/vnd.openbi.metric+json", const string VerdictMime = "application/vnd.openbi.verdict+json", const string NetworkMime = "application/vnd.openbi.network+json", const string OptimizationMime = "application/vnd.openbi.optimization+json", const string ScenariosMime = "application/vnd.openbi.scenarios+json", const string RoutesMime = "application/vnd.openbi.routes+json", const string ValuationMime = "application/vnd.openbi.valuation+json", const int PreviewRows = 20.

Methods

static string Short(double v)
A number short, for an axis or a label: 3.3 M, 1.25 bn, 48,200, 0.125.
static DisplayData Table(Table t, string? caption)
A table: its first rows as a grid (text, HTML and OpenBI's format), and its size.

Also: static DisplayData Format(object? value), static JsonObject VerdictJson(Verdict v), static string Plain(object? v).

DaxQuery

public sealed class DaxQuery

An OAX step with parameters (@asOf): run for any values with DaxQuery.Run, or for a date with DaxQuery.At. Its DaxQuery.Preview is the result at the step's own values. A model version keeps this query, so it computes its own inputs when it scores.

Constructors

Its constructors: DaxQuery(string name, string text, IReadOnlyDictionary<string, object?> values, Func<string, Table> run).

Properties

string Text { get; }
The query, with its @parameters.
IReadOnlyDictionary<string, object?> Values { get; }
The parameters' values in the step (the preview's).
Table Preview { get; }
The result at the step's values (set when the step runs).

Also: string Name { get; }, IReadOnlyList<string> Parameters { get; }, ColumnSet Columns { get; }.

Methods

Table Run(params (string Name, object? Value)[] values)
The result for these parameter values (the step's for the others).
Table At(DateTime date)
The result at a date: the query's one date parameter set to it.
string Bind(params (string Name, object? Value)[] values)
The query's text with these values (and the step's for the others) written in as OAX literals.
static IReadOnlyList<string> FindParameters(string dax)
The @names of an OAX text, outside strings, comments and quoted names.

Also: string ToString().

Operators

Its operators: static implicit operator Table(DaxQuery q).

DaxText

public struct DaxText

OAX written with $"…": a date, number or list in braces goes in as an OAX literal (text goes in as it is).

Constructors

Its constructors: DaxText(int literalLength, int formattedCount).

Methods

Its methods: void AppendLiteral(string s), void AppendFormatted<T>(T? value), void AppendFormatted<T>(T value, string? format), string ToString().

SqlText

public struct SqlText

SQL written with $"…": a date, number or list in braces goes in as a SQL literal (text goes in as it is).

Constructors

Its constructors: SqlText(int literalLength, int formattedCount).

Methods

Its methods: void AppendLiteral(string s), void AppendFormatted<T>(T? value), void AppendFormatted<T>(T value, string? format), string ToString().

Literal

public static class Literal

Values written into OAX and SQL text: dates, numbers, true/false and lists as literals of each language.

Methods

static string Dax(object? v)
A value as OAX: DATE(2025, 6, 30), 0.05, TRUE(), BLANK(), { 1, 2 }; text as it is (code, such as a column's name).
static string Sql(object? v)
A value as SQL (DuckDB): DATE '2025-06-30', 0.05, TRUE, NULL, (1, 2); text as it is (code).
static string DaxText(string s)
Text as an OAX string literal: "it""s".
static string SqlText(string s)
Text as a SQL string literal: 'it''s'.

Dates

public static class Dates

Dates for as-of points and periods.

Methods

static IReadOnlyList<DateTime> MonthStarts(DateTime until, int count)
The first day of the last count months that start on or before until, oldest first.
static IReadOnlyList<DateTime> MonthStarts(DateTime from, DateTime until)
The first day of every month from from's to until's (both included when they are 1sts).
static IReadOnlyList<DateTime> Days(DateTime from, DateTime until, int step = 1)
Every step days from from to until.

Also: static DateTime MonthStart(DateTime d).

Diagram

public static class Diagram

A TikZ picture in a notebook: real TikZ (LaTeX), as papers draw their figures, compiled offline by the engine's Tectonic. A TikZ step is the picture's code; in C#, TikZ(@"\draw (0,0) -- (1,1);"). The code may be a tikzpicture, a tikzcd, circuitikz, forest or pgfplots axis, bare TikZ commands (put in a tikzpicture), or a whole document (\documentclass…); lines it starts with that set things up (\usepackage, \usetikzlibrary, \tikzset, \definecolor, \newcommand…) go before \begin{document}. Its output: the picture (image/png, for the step and Jupyter) and its PDF (application/pdf: the paper takes it as a vector figure).

Methods

static Diagram.Document Wrap(string code)
The code as a standalone document (unchanged when it is one).
static DisplayData Render(ModelConnection engine, string code, string? title = null, CancellationToken ct = default)
The picture of a TikZ step's code: compiled by the engine; its error (TeX's, at the step's own line) thrown as a TikzException.

Diagram.Document

public sealed record Document(
    string Tex,
    int HeadLines,
    int PreambleLines,
    int OpenLines)

The standalone document a step's code is compiled as, and how its lines map back to the step's.

Properties

Its properties: string Tex { get; init; }, int HeadLines { get; init; }, int PreambleLines { get; init; }, int OpenLines { get; init; }.

Methods

int StepLine(int line)
The step's line of a line of the document (0: one the step did not write).

TikzException

public sealed class TikzException : Exception

TeX could not draw a TikZ picture: its message, and the step's line it points at.

Constructors

TikzException(string message, int? line)
TeX could not draw a TikZ picture: its message, and the step's line it points at.

Properties

Its properties: int? Line { get; }.

INotebookHost

public interface INotebookHost

Where a running step's outputs, status and interrupt come from: the kernel sets it for each step.

Properties

CancellationToken Interrupted { get; }
Set when the person interrupts.
string? ProjectFolder { get; }
The project's folder (models are saved under predictions/), or null.
string? NotebookName { get; }
The notebook's name (its prediction's), or null.
string User { get; }
Who runs it.
bool ByAgent { get; }
The agent runs this step (it may save drafts; it never approves).

Methods

void Status(string text)
A line that replaces the last status (progress of a long step).
JsonObject RunRecord()
The steps run so far in this kernel, in order, with what they showed: the notebook as it ran.

Also: void Display(DisplayData data).

Last updated · OpenBI Studio 0.3.78