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
¶
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
¶
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. |
None
|
link
¶
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 |
required |