plesty.lib.experiment.schedule
Experiment plans: ordered schedules of atomic measurement steps.
A Plan is the frozen schedule of an experiment run — an ordered list
of Step items, each the smallest unit of work that either completes
(its result is persisted and journaled) or is re-run on resume. The plan is
written to disk at run start and never mutated; its content hash lets a
resumed run verify it is continuing the same schedule.
Classes
One atomic measurement step in an experiment plan. |
|
A frozen, hashable schedule of atomic steps plus the run configuration. |
Module Contents
- class plesty.lib.experiment.schedule.Step
One atomic measurement step in an experiment plan.
- Variables:
id – Stable, deterministic identifier unique within the plan, e.g.
"scan[x=3,y=5]". Resume matches completed steps by this id, so it must not depend on run time or randomness.op – Name of the experiment method to call for this step.
params – Keyword arguments passed to the method.
- id: str
- op: str
- params: dict[str, Any]
- to_dict() dict[str, Any]
Return a JSON-serializable representation of the step.
- Return type:
dict[str, Any]
- class plesty.lib.experiment.schedule.Plan(steps: list[Step], config: dict[str, Any] | None = None)
A frozen, hashable schedule of atomic steps plus the run configuration.
Usage:
plan = Plan( steps=[Step(id=f"scan[{i}]", op="scan_point", params={"x": i}) for i in range(10)], config={"exposure_s": 0.1}, ) plan.save("runs/run_001/plan.json")
Initialize the plan with its steps and optional configuration.
- Parameters:
steps (list[Step]) – Ordered atomic steps; step ids must be unique.
config (dict[str, Any] | None) – Experiment configuration recorded alongside the schedule.
- Raises:
ValueError – If two steps share the same id.
- config: dict[str, Any]
- to_dict() dict[str, Any]
Return a JSON-serializable representation of the plan.
- Return type:
dict[str, Any]
- classmethod from_dict(data: dict[str, Any]) Plan
Reconstruct a plan from
to_dict()output.- Parameters:
data (dict[str, Any])
- Return type:
- content_hash() str
Return a stable SHA-256 hash of the schedule and configuration.
Used on resume to verify that the persisted plan matches the plan the experiment would generate now — resuming under changed parameters is refused rather than silently mixing two schedules.
- Return type:
str
- save(path: str | pathlib.Path) pathlib.Path
Write the plan as JSON to path, creating parent directories.
- Parameters:
path (str | pathlib.Path)
- Return type:
pathlib.Path
- classmethod load(path: str | pathlib.Path) Plan
Load a plan previously written by
save().- Parameters:
path (str | pathlib.Path)
- Return type:
- __len__() int
Return the number of steps in the plan.
- Return type:
int