accelmo.runlog.writer

Writing a run log from inside a fit.

accelmo.runlog.writer.START_STEP = -1

The step under which RunLog.begin() records the starting knobs.

accelmo.runlog.writer.REOPEN_SECONDS = 10.0

Seconds between closing and reopening the append-only files. A flush only reaches the local cache on AFS; the server (and so other hosts) sees the data on close.

accelmo.runlog.writer.write_json(path, payload)[source]

Write payload to path atomically, so a reader never sees half a file.

Return type:

None

Parameters:
  • path (Path)

  • payload (Mapping[str, Any])

class accelmo.runlog.writer.RunLog(directory, *, name, metadata=None, resume=False)[source]

Bases: object

Records one fit in directory; see accelmo.runlog for the files.

Call begin() with the starting knobs, then log() and record_knobs() once per step, finish() with how the fit ended and close() at the end. Every write is flushed straight away, so a monitor in another process sees each step as soon as it is logged.

Parameters:
  • directory (Path)

  • name (str)

  • metadata (Mapping[str, Any] | None)

  • resume (bool)

knob_names: list[str]
begin(knobs, *, resume_step=None)[source]

Fix the knob order to that of knobs and record them as the start.

On a log opened with resume=True that already has a stage file, the existing run is continued instead: rows from resume_step on (written after the checkpoint being restored) are dropped, and nothing else is rewritten.

Return type:

None

Parameters:
  • knobs (Mapping[str, float])

  • resume_step (int | None)

log(step, **scalars)[source]

Append one line of scalars for step.

Return type:

None

Parameters:
  • step (int)

  • scalars (float | bool | None)

record_knobs(step, knobs)[source]

Append the knob values after step, in the order fixed by begin().

Return type:

None

Parameters:
  • step (int)

  • knobs (Mapping[str, float])

finish(**summary)[source]

Record how the fit ended (stop reason, best loss, …).

Return type:

None

Parameters:

summary (Any)

record_uncertainty(**state)[source]

Replace the uncertainty stage’s state: the fitted knobs, progress, timing, the Hessian used.

Return type:

None

Parameters:

state (Any)

close()[source]

Close the history and knob files.

Return type:

None