Skip to content

systemslab context monitor ​

Description Block until a context reaches a terminal state, printing a line each time one of its attached experiments finishes.
Usage systemslab context monitor [OPTIONS] <UUID>

Description ​

The systemslab context monitor command waits for a context to reach a terminal state (complete or cancelled) instead of requiring a script to poll systemslab context show in a loop. This is the right command to wait on a matrix submit (systemslab submit against a TOML matrix, or several systemslab submit --context <id> calls), where the interesting unit of completion is the whole context rather than any single experiment.

WARNING

A context only reaches a terminal state after it has been marked complete (or cancelled). A matrix submit and systemslab sweep (without --context) mark their context complete once every experiment has been submitted, but a context created with systemslab context new and filled with systemslab submit --context <id> or systemslab context attach stays open until you run systemslab context complete <id>. Monitoring an open context waits forever (or until --timeout), and the command prints a note on stderr to say so.

Marking the context complete while its experiments are still running is fine: it moves to pending and becomes complete once they finish.

bash
CTX=$(systemslab --output-format short context new --name my-sweep)
systemslab submit a.jsonnet --context "$CTX"
systemslab submit b.jsonnet --context "$CTX"
systemslab context complete "$CTX"
systemslab context monitor "$CTX"

As each attached experiment finishes, it prints a line such as:

experiment my-benchmark-variant-2 (018f9c57-...): success

When the context itself reaches a terminal state (complete or cancelled), it prints a final summary line and exits:

Context my-sweep (018f9c57-...): complete (success)

<name> is whatever name the context was given at systemslab context new/submit time, and <status> is the aggregate outcome across all attached experiments: success, failure, error, cancelled, or empty (no experiments were attached).

The command exits 0 only if the context's final status is success or empty. Any other status, or the --timeout deadline elapsing first, causes it to exit non-zero -- so it can be used directly to gate a script:

bash
systemslab context monitor "$CONTEXT_ID" && echo "sweep passed"

On a real terminal failure the Context ... summary line above is still printed to stdout before the non-zero exit, so a script can tell that outcome apart from a --timeout giveup, which instead prints a "timed out" error to stderr and no summary line (the context is still running -- run the command again to keep waiting).

Rather than polling on a timer, this subscribes to the same server-push channel the web UI uses and only re-checks the context when the server reports that it may have changed.

Options ​

OptionDefaultDescription
<UUID>The context ID.
--timeout <TIMEOUT>Wait indefinitely Give up and exit non-zero if the context has not reached a terminal state within this many seconds. The context itself keeps running on the server -- only this command's wait gives up, and it can be run again to keep waiting.

Common Options ​

OptionDefaultDescription
--systemslab-url The URL at which to access the systemslab server.
--colorauto Controls when color is used in the output. Possible values are auto, always, and never.
--output-formatlong Output format to use when outputting messages. long will result output designed to be human-readable while short is short output meant to be used within scripts.

Environment Variables ​

VariableDescription
SYSTEMSLAB_URLSpecify the URL used to contact the SystemsLab server. Equivalent to --systemslab-url.