package kaun-board

  1. Overview
  2. Docs

Module Kaun_board.RunSource

Training runs.

A run is a directory on disk containing a run.json manifest and an append-only events.jsonl log. Runs are created by Log and read back here for dashboards and analysis.

Run IDs follow the format YYYY-MM-DD_HH-MM-SS_XXXX where XXXX is a random hex suffix. When an experiment name is given, it is appended: YYYY-MM-DD_HH-MM-SS_XXXX_experiment.

Types

Sourcetype t

The type for training run handles.

Accessors

Sourceval run_id : t -> string

run_id r is r's unique identifier.

Sourceval dir : t -> string

dir r is the absolute path to r's directory.

Sourceval created_at : t -> float

created_at r is the Unix timestamp when r was created.

Sourceval experiment_name : t -> string option

experiment_name r is r's experiment name, if any.

Sourceval tags : t -> string list

tags r is the metadata tags associated with r.

Sourceval total_epochs : t -> int option

total_epochs r is r's expected total number of epochs, if specified in the manifest.

Constructors

Sourceval create : ?base_dir:string -> ?experiment:string -> ?tags:string list -> ?config:(string * Jsont.json) list -> unit -> t

create () is a new run with a unique ID and an on-disk directory containing a run.json manifest.

base_dir defaults to the value of RAVEN_RUNS_DIR, or XDG_CACHE_HOME/raven/runs when unset. experiment is appended to the run ID when given. tags defaults to []. config defaults to [] and is written to the manifest as-is.

Raises Sys_error if the directory or manifest cannot be created.

See also load.

Sourceval load : string -> t option

load dir is the run in dir, if dir contains a valid run.json manifest, and None otherwise.

See also create and latest.

Sourceval latest : string -> t option

latest base_dir is the most recent run in base_dir, determined by reverse-sorting directory entries and loading the first valid manifest. Returns None if base_dir does not exist or contains no valid runs.

See also load.

Events

Sourceval append_event : t -> Event.t -> unit

append_event r ev appends ev as a JSON line to r's events.jsonl.

Incremental reading

Sourcetype event_stream

The type for incremental event readers. Tracks the file position and detects log rotation or truncation.

Sourceval open_events : t -> event_stream

open_events r is a stream positioned at the beginning of r's event log.

See also close_events.

Sourceval read_events : event_stream -> Event.t list

read_events stream is the list of events appended since the last call, or the empty list when no new data is available.

Automatically resets to the beginning if the underlying file has been rotated or truncated.

Sourceval last_mtime : event_stream -> float

last_mtime stream is the last observed modification time of the event log file, as recorded by read_events. Returns 0.0 before the first successful read.

Sourceval close_events : event_stream -> unit

close_events stream releases the stream's file descriptor. Safe to call multiple times.