div result
Prints what a run declared about itself at DIVERGENT_RESULT_PATH — the whole JSON object, or the one value a script wants.
div result run-7
div result run-7 metrics.accuracy
div result run-7 | jq '.metrics'
Every run is given DIVERGENT_RESULT_PATH. A JSON object written there before the run exits is its result: the control plane keeps it with the run, judges the run’s checks against it, and div result prints it.
import json, os
with open(os.environ["DIVERGENT_RESULT_PATH"], "w") as f:
json.dump({"metrics": {"accuracy": 0.91, "loss": 0.42}}, f)
The file is read once the process has exited, so it can be written at any point and rewritten as often as you like; the last version is the one kept.
A path picks one value
Given a path, div result prints the value there instead of the whole object: a string as it is, anything else as JSON. It reads the path the same way a check does, a key at a time between the dots.
acc=$(div result run-7 metrics.accuracy) # 0.91
When there is nothing to print
div result exits 1, and says why on stderr, rather than printing an empty line a script would read as a value:
| When | What it says |
|---|---|
| the run has not finished | run-7 is still running; its result arrives when it finishes |
| it wrote nothing | run-7 has no result: it wrote nothing to DIVERGENT_RESULT_PATH |
| it wrote something we could not keep | run-7 has no result: the result is not JSON |
| the path is not in it | run-7 has nothing at metrics.f1 |
A result has to be one JSON object of at most 64 KiB. One that is longer is refused whole, never cut short: half an object could pass a check the whole one would fail. Any value of one of the org’s secrets is masked in it, as it is in the log.