write_trials_jsonl() writes trial records to a JSON Lines file, one JSON
object per trial and line. read_trials_jsonl() reads them back.
Arguments
- trials
A list of trial records from
create_trial()orcomplete_trial().- path
Path of the file to write.
- append
Whether to append to an existing file (default
FALSE).
Details
The file follows the permission rules described in TrialLog: on Unix, an
existing file must be owned by the current user with mode 0600, and every
existing parent directory must be owned by root or the current user. Unsafe
paths are rejected rather than repaired. The directory must already exist.
See also
Other optimizer building blocks:
TrialLog,
complete_trial(),
create_trial(),
eval_program(),
load_trial_log(),
optimizer_control(),
read_trials_jsonl(),
sample_dataset(),
split_dataset()
Examples
trials <- list(
create_trial("my-search", params = list(k = 2L)),
create_trial("my-search", params = list(k = 4L))
)
path <- tempfile(fileext = ".jsonl")
write_trials_jsonl(trials, path)
readLines(path, n = 1)
#> [1] "{\"schema_version\":1,\"trial_id\":\"trial_20260930_174439_ncnyz0\",\"optimizer_name\":\"my-search\",\"params\":{\"k\":2},\"metric_summary\":[],\"cost_summary\":[],\"start_time\":\"2026-09-30T17:44:39\",\"end_time\":null,\"notes\":\"\",\"status\":\"pending\",\"trace_context\":[]}"