accelmo.monitor.cache

Computing optics from logged knobs in the background, and keeping the results.

accelmo.monitor.cache.REFERENCES = 0

lower runs first.

Type:

Priorities

accelmo.monitor.cache.SELECTED = 1

lower runs first.

Type:

Priorities

accelmo.monitor.cache.LATEST = 2

lower runs first.

Type:

Priorities

accelmo.monitor.cache.BACKFILL = 10

lower runs first.

Type:

Priorities

accelmo.monitor.cache.refinement_order(items)[source]

items ordered first, last, then the midpoints of ever finer halves.

Computing a history in this order gives an evenly spread picture early, which fills in as more is done.

Return type:

list[Any]

Parameters:

items (Sequence[Any])

class accelmo.monitor.cache.OpticsCache(spec, directory, *, workers=1, memory=0)[source]

Bases: object

Computes references, optics and summaries with the spec’s source, on worker threads.

Results are written below directory (one folder per model, one file per distinct set of knob values) and so survive restarts of the monitor. Reads never block: anything not computed yet is queued and None returned. Nothing is kept in memory after it is read unless memory asks for that many tables to be (the monitor does not: it rereads from disk to draw).

Parameters:
  • spec (MonitorSpec)

  • directory (Path)

  • workers (int)

  • memory (int)

errors: dict[str, str]

The last error per key, shown in the monitor instead of retrying forever.

model_key(metadata)[source]

Identifies the model: the stage metadata and the spec version.

Return type:

str

Parameters:

metadata (Mapping[str, Any])

static knobs_key(knobs)[source]

Identifies a set of knob values, whatever step or stage they come from.

Return type:

str

Parameters:

knobs (pandas.Series)

has_references(metadata)[source]

Whether the references are on disk; queues them if not.

Return type:

bool

Parameters:

metadata (Mapping[str, Any])

references(metadata)[source]

Reference optics of the run, or None until computed.

Return type:

dict[str, DataFrame] | None

Parameters:

metadata (Mapping[str, Any])

request(metadata, knobs, priority)[source]

Queue the optics for knobs at priority unless done; True when done.

Return type:

bool

Parameters:
  • metadata (Mapping[str, Any])

  • knobs (pd.Series)

  • priority (int)

optics(metadata, knobs, priority)[source]

The optics for knobs, or None after queueing them at priority.

Return type:

Optional[DataFrame]

Parameters:
  • metadata (Mapping[str, Any])

  • knobs (pd.Series)

  • priority (int)

has_summary(metadata, knobs)[source]

Whether the summary for knobs is on disk; never queues anything.

Return type:

bool

Parameters:
  • metadata (Mapping[str, Any])

  • knobs (pd.Series)

summary(metadata, knobs)[source]

The summary for knobs if computed; never queues anything.

Return type:

dict[str, float] | None

Parameters:
  • metadata (Mapping[str, Any])

  • knobs (pd.Series)

error(metadata, knobs=None)[source]

Error message of a failed model or knobs computation, if any.

Return type:

str | None

Parameters:
  • metadata (Mapping[str, Any])

  • knobs (pd.Series | None)

property pending: int

Number of queued and running computations.