Imp.Tracking.WandB (Imp v0.5.0)

Copy Markdown View Source

Isolated client for the W&B 0.21.x run protocol.

The public API is transport-independent and keeps run state immutable. Pass the returned client from each successful operation into the next operation.

Version sensitivity

W&B's GraphQL and file_stream interfaces are internal protocols, not stable public APIs. This implementation is pinned to wire behavior from the official W&B SDK v0.21.3 in an isolated internal module. A W&B SDK or server upgrade requires recording and comparing the requests before changing that module.

:gepa_v0_1_1 finish semantics reproduce GEPA v0.1.1, whose context manager calls wandb.finish() without propagating exception status. :accurate semantics convert failed outcomes to a nonzero W&B exit code.

Summary

Functions

Sends the terminal W&B file-stream payload.

Verifies credentials, resolves the entity, and creates or resumes a run.

Appends one history row and enforces strictly increasing steps.

Uploads HTML and logs it to history; by default it also replaces that summary key.

Uploads a W&B table file and logs its media reference as a history row.

Merges values into the local summary and sends a full replacement.

Creates a client without making a network request.

Replaces the complete W&B summary document at file-stream offset zero.

Types

outcome()

@type outcome() ::
  :success
  | :finished
  | :failed
  | :failure
  | :killed
  | :cancelled
  | :error
  | {:failed, non_neg_integer()}

status_mode()

@type status_mode() :: :gepa_v0_1_1 | :accurate

t()

@type t() :: %Imp.Tracking.WandB{
  authorization: term(),
  base_url: term(),
  entity: term(),
  finished?: term(),
  group: term(),
  history_offset: term(),
  id: term(),
  job_type: term(),
  last_step: term(),
  name: term(),
  notes: term(),
  project: term(),
  request_opts: term(),
  resume: term(),
  status_mode: term(),
  storage_id: term(),
  summary: term(),
  tags: term(),
  transport: term()
}

Functions

finish(client, outcome \\ :success)

@spec finish(t(), outcome()) :: {:ok, t()} | {:error, term()}

Sends the terminal W&B file-stream payload.

init(client, opts)

@spec init(t(), keyword() | map()) :: {:ok, t()} | {:error, term()}

Verifies credentials, resolves the entity, and creates or resumes a run.

log(client, metrics, opts \\ [])

@spec log(t(), map(), keyword()) :: {:ok, t()} | {:error, term()}

Appends one history row and enforces strictly increasing steps.

log_html(client, key, html, opts \\ [])

@spec log_html(t(), String.t(), String.t(), keyword()) ::
  {:ok, t()} | {:error, term()}

Uploads HTML and logs it to history; by default it also replaces that summary key.

log_table(client, key, columns, rows, opts \\ [])

@spec log_table(t(), String.t(), [String.t()], [list()], keyword()) ::
  {:ok, t()} | {:error, term()}

Uploads a W&B table file and logs its media reference as a history row.

merge_summary(client, values)

@spec merge_summary(t(), map()) :: {:ok, t()} | {:error, term()}

Merges values into the local summary and sends a full replacement.

new(opts)

@spec new(keyword()) :: t()

Creates a client without making a network request.

replace_summary(client, summary)

@spec replace_summary(t(), map()) :: {:ok, t()} | {:error, term()}

Replaces the complete W&B summary document at file-stream offset zero.