qxmt.experiment.reproducer module#
- class qxmt.experiment.reproducer.Reproducer(experiment)
Bases:
object
Handle reproduction of an existing experiment run.
This class is responsible for reproducing and validating experiment runs. It is intentionally decoupled from the Experiment facade, but requires an Experiment instance to access database information and launch new runs.
- Parameters:
experiment (Experiment)
- _exp
The experiment instance to use for reproduction.
- Type:
Experiment
- logger
Logger instance for logging operations.
- __init__(experiment)
Initialize the Reproducer.
- Parameters:
experiment (Experiment) – The experiment instance to use for reproduction. Note: Experiment is forward-declared via string to avoid circular import.
- Return type:
None
- reproduce(run_id, *, check_commit_id=False, tol=1e-06)
Reproduce a specific run and validate its evaluation metrics.
This method reproduces a run with the given ID and compares its results with the original run to ensure reproducibility.
- Parameters:
run_id (int) – ID of the run to reproduce.
check_commit_id (bool, optional) – Whether to check if the current commit ID matches the original run’s commit ID. Defaults to False.
tol (float, optional) – Tolerance for comparing evaluation metrics. Defaults to 1e-6.
- Returns:
- A tuple containing the reproduced run’s
artifact and record.
- Return type:
Tuple[RunArtifact, RunRecord]
- Raises:
ReproductionError – If the run was executed in instance mode or if the config file is not found.
ValueError – If the evaluation results differ beyond the specified tolerance or if the evaluation types are invalid.
Examples
>>> reproducer = Reproducer(experiment) >>> artifact, record = reproducer.reproduce(run_id=1, check_commit_id=True)