Post · 2 min read· pp. 138–139

create_experiment_tracker

gepa.logging.experiment_tracker.create_experiment_tracker(use_wandb: bool = False, wandb_api_key: str | None = None, wandb_init_kwargs: dict[str, Any] | None = None, wandb_attach_existing: bool = False, wandb_step_metric: str | None = None, use_mlflow: bool = False, mlflow_tracking_uri: str | None = None, mlflow_experiment_name: str | None = None, mlflow_attach_existing: bool = False, key_prefix: str = '') -> ExperimentTracker

Create an experiment tracker based on the specified backends.

Parameters:

NameTypeDescriptionDefault
use_wandbboolWhether to use wandbFalse
use_mlflowboolWhether to use mlflowFalse
wandb_api_key`strNone`API key for wandb
wandb_init_kwargs`dict[str, Any]None`Additional kwargs for wandb.init()
wandb_attach_existingboolWhen True, skip wandb.init() and wandb.finish() and log into the already-active run.False
wandb_step_metric`strNone`Custom x-axis metric name for wandb. When set, GEPA uses wandb.define_metric to log all metrics against this custom step instead of wandb's global monotonic step counter. Required when embedding GEPA inside a host training loop that manages its own wandb step counter.
mlflow_tracking_uri`strNone`Tracking URI for mlflow
mlflow_experiment_name`strNone`Experiment name for mlflow
mlflow_attach_existingboolWhen True, skip mlflow.start_run() and mlflow.end_run() and log into the already-active run.False

Returns:

TypeDescription
ExperimentTrackerExperimentTracker instance

Note

Both wandb and mlflow can be used simultaneously if desired.

Source code in gepa/logging/experiment_tracker.py

text
def create_experiment_tracker(
    use_wandb: bool = False,
    wandb_api_key: str | None = None,
    wandb_init_kwargs: dict[str, Any] | None = None,
    wandb_attach_existing: bool = False,
    wandb_step_metric: str | None = None,
    use_mlflow: bool = False,
    mlflow_tracking_uri: str | None = None,
    mlflow_experiment_name: str | None = None,
    mlflow_attach_existing: bool = False,
    key_prefix: str = "",
) -> ExperimentTracker:
    """
    Create an experiment tracker based on the specified backends.

    Args:
        use_wandb: Whether to use wandb
        use_mlflow: Whether to use mlflow
        wandb_api_key: API key for wandb
        wandb_init_kwargs: Additional kwargs for wandb.init()
        wandb_attach_existing: When True, skip wandb.init() and wandb.finish()
            and log into the already-active run.
        wandb_step_metric: Custom x-axis metric name for wandb.  When set,
            GEPA uses ``wandb.define_metric`` to log all metrics against this
            custom step instead of wandb's global monotonic step counter.
            Required when embedding GEPA inside a host training loop that
            manages its own wandb step counter.
        mlflow_tracking_uri: Tracking URI for mlflow
        mlflow_experiment_name: Experiment name for mlflow
        mlflow_attach_existing: When True, skip mlflow.start_run() and
            mlflow.end_run() and log into the already-active run.

    Returns:
        ExperimentTracker instance

    Note:
        Both wandb and mlflow can be used simultaneously if desired.
    """
    return ExperimentTracker(
        use_wandb=use_wandb,
        wandb_api_key=wandb_api_key,
        wandb_init_kwargs=wandb_init_kwargs,
        wandb_attach_existing=wandb_attach_existing,
        wandb_step_metric=wandb_step_metric,
        use_mlflow=use_mlflow,
        mlflow_tracking_uri=mlflow_tracking_uri,
        mlflow_experiment_name=mlflow_experiment_name,
        mlflow_attach_existing=mlflow_attach_existing,
        key_prefix=key_prefix,
    )