Skip to content

display

Console output of scripts: sections, key/value blocks and links to results.

The output of a run, e.g. of simulation experiments or of a fit, is a sequence of sections with aligned key/value lines. A result which is a file, e.g. a report, is a link: the terminal opens it with one click.

from sbmlsim import display

display.section("Report", icon=display.ICON_REPORT)
display.key_values({"experiments": 3})
display.link("report", "results/index.html")

The output goes to the console of the package, see sbmlsim.console.

relocated

relocated(moves)

Let the links printed in the block name the folders the output ends up in.

A command which writes into a staging folder and moves it into its place when the run succeeded (e.g. the staged swap of the commands of pkpdsim) prints its links while the output is still in the staging folder, which no longer exists once it is moved (#669). Within the block a link to a path in one of the folders of moves names the path in the folder it is moved to; the deepest folder wins, so a folder of the result which is moved up out of the staging folder is given before the staging folder itself. Blocks nest, the inner moves are applied first.

Parameters:

Name Type Description Default
moves Mapping[Path | str, Path | str]

the folders the run writes into, by the folder each ends up as.

required

section

section(title, icon=None)

Start a section of the output.

A blank line separates the section from whatever came before it, so the sections are told apart whether the previous one ended in a table or in a key/value block.

Parameters:

Name Type Description Default
title str

title of the section.

required
icon str | None

emoji in front of the title, e.g. ICON_REPORT; left out when the console does not write UTF-8.

None

key_values

key_values(items)

Print aligned key/value lines, the smallest section of the output.

link(key, path)

Print a link to a file or a directory, which the terminal opens with a click.

The link is a hyperlink of the terminal (OSC 8), which VS Code, iTerm2, Windows Terminal, GNOME Terminal and kitty open with a click, whatever the width of the terminal. Its text is the file:// URI of the path on a single line, so that a terminal without hyperlinks still recognizes it, and it is what ends up in a log file. The URI has forward slashes and a drive is file:///C:/...; a windows path with backslashes is not a link a terminal opens.

Parameters:

Name Type Description Default
key str

what the link points to, in front of it.

required
path Path | str

path of the file or the directory, relative paths are resolved; a path in a folder of relocated names the folder it ends up as.

required