Tracker#

class tropt.tracker.BaseTracker(experiment_name='tropt_experiment', experiment_config=None)[source]#

Bases: ABC

Interface for experiment trackers.

Lifecycle (managed by BaseOptimizer’s wrapper):

__init__()        # by the user: stores backend config, no run started
init(config)      # by the optimizer wrapper: opens a run (now stateful)
log(data)         # per optimization step
finish(summary)   # by the optimizer wrapper: closes the run (back to stateless)

The tracker can be reused across multiple runs: after finish(), a subsequent init() opens a fresh run on the same backend.

Subclasses must implement _init, _log, and _finish. The base class manages their guards.

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

finish(summary=None)[source]#

Close the current run, optionally logging a final summary.

Parameters:

summary (dict | None)

init(config=None)[source]#

Open a new run. Called by the optimizer wrapper before optimization.

Merges the user’s experiment_config (from __init__) with the optimizer-generated config and forwards to _init.

Parameters:

config (dict | None)

log(data)[source]#

Log per-step data. Must be called between init and finish.

Parameters:

data (dict)

class tropt.tracker.DictTracker(experiment_name='tropt_experiment', experiment_config=None)[source]#

Bases: BaseTracker

Accumulates logged values in plain Python dicts.

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

records#

Each log() call appends one record (the raw dict).

Type:

list[dict]

history#

Per-key view — history[key] contains only values from records that included key. Convenient but records from different keys may not be index-aligned; use records when you need to join across keys.

Type:

dict[str, list]

config#

Run config, if logged.

Type:

dict

summary#

Run summary, if logged.

Type:

dict

class tropt.tracker.DummyTracker(experiment_name='tropt_experiment', experiment_config=None)[source]#

Bases: BaseTracker

No-op tracker. Discards all logged data.

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

class tropt.tracker.JSONTracker(experiment_name='tropt_experiment', experiment_config=None, log_file_path='./logs/{experiment_name}.json')[source]#

Bases: BaseTracker

Writes accumulated logs to a JSON file on finish().

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

  • log_file_path (str)

class tropt.tracker.LiveLossPlotTracker(experiment_name='tropt_experiment', focus_on_metrics=('loss',))[source]#

Bases: BaseTracker

Live-updating loss plot via livelossplot.

Parameters:
  • experiment_name (str)

  • focus_on_metrics (tuple)

class tropt.tracker.PrintTracker(experiment_name='tropt_experiment', print_keys=('loss', 'best_trigger_str'))[source]#

Bases: BaseTracker

Prints each optimisation step to stdout and accumulates history.

Useful for Jupyter notebooks or any situation where you want live step-by-step loss/trigger output without a heavyweight logging backend.

Parameters:
  • experiment_name (str)

  • print_keys (tuple)

history#

Accumulated values keyed by metric name.

Type:

dict

class tropt.tracker.TrackioTracker(experiment_name='tropt_experiment', experiment_config=None, project_name='tropt_experiment', space_id=None, **trackio_kwargs)[source]#

Bases: BaseTracker

Logs to Hugging Face’s Trackio.

Construction stores backend parameters (project, space_id, etc.) without starting a run. The run is opened on init() and closed on finish().

Trackio has no per-run summary object (unlike WandB); finish(summary=...) records the summary as a final trackio.log() entry whose keys are prefixed by "summary/" so it can be recovered from the run history.

See https://huggingface.co/docs/trackio for backend details.

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

  • project_name (str)

  • space_id (Optional[str])

class tropt.tracker.WandbTracker(experiment_name='tropt_experiment', experiment_config=None, project_name='tropt_experiment', **wandb_kwargs)[source]#

Bases: BaseTracker

Logs to Weights & Biases.

Construction stores backend parameters (project, entity, etc.) without starting a run. The run is opened on init() and closed on finish().

Parameters:
  • experiment_name (str)

  • experiment_config (Optional[dict])

  • project_name (str)