ictonyx.loggers

MLflow and other experiment logging integrations.

class ictonyx.loggers.BaseLogger(verbose=True, print_params=False, print_metrics=False)[source]

Bases: object

Base experiment logger with in-memory history tracking.

Stores parameters and per-step metrics in a history dict. All log_* methods for artifacts, models, and figures are no-ops in the base class — subclasses (e.g. MLflowLogger) override them to persist data to external systems.

This class is used as the default logger when no tracker is passed to ExperimentRunner.

Parameters:
  • verbose (bool) – If True, print activity to stdout. Default True.

  • print_params (bool) – If True and verbose, print logged parameters. Default False.

  • print_metrics (bool) – If True and verbose, print logged metrics. Default False.

history

Dict with keys 'params' (Dict) and 'metrics' (List of {'key', 'value', 'step'} dicts).

log_params(params)[source]

Logs a dictionary of parameters and stores it in history.

Parameters:

params (Dict[str, Any])

log_metric(key, value, step=0)[source]

Logs a single metric and stores it in history.

Parameters:
log_metrics(metrics, step=0)[source]

Logs multiple metrics at once.

Parameters:
log_artifact(artifact_path, artifact_name=None)[source]

Logs an artifact (file) - base implementation does nothing.

Parameters:
  • artifact_path (str)

  • artifact_name (str | None)

log_model(model, artifact_path='model')[source]

Logs a model - base implementation does nothing.

Parameters:

artifact_path (str)

log_figure(figure, artifact_name)[source]

Logs a matplotlib figure - base implementation does nothing.

Parameters:

artifact_name (str)

set_tags(tags)[source]

Sets tags for the run - base implementation does nothing.

Parameters:

tags (Dict[str, str])

end_run()[source]

Called at the end of a run to finalize logging.

start_child_run(run_name=None)[source]

No-op for base logger. Returns empty string.

Parameters:

run_name (str | None)

Return type:

str

end_child_run()[source]

No-op for base logger.

Return type:

None

get_history()[source]

Returns the logged history.

Return type:

Dict[str, Any]

class ictonyx.loggers.MLflowLogger(run_name=None, experiment_name='ictonyx_experiment', tracking_uri=None, verbose=True)[source]

Bases: BaseLogger

Experiment logger backed by MLflow.

Extends BaseLogger to persist parameters, metrics, artifacts, models, and figures to an MLflow tracking server. Creates a new MLflow run on initialization and ends it on end_run().

Requires mlflow. Install with pip install mlflow.

Parameters:
  • run_name (str | None) – Optional display name for this MLflow run.

  • experiment_name (str) – MLflow experiment name. Created if it does not exist. Default 'ictonyx_experiment'.

  • tracking_uri (str | None) – MLflow tracking server URI. If None, uses the local mlruns/ directory. Default None.

  • verbose (bool) – Print logging activity to stdout. Default True.

Raises:

ImportError – If mlflow is not installed.

__init__(run_name=None, experiment_name='ictonyx_experiment', tracking_uri=None, verbose=True)[source]

Initialize MLflow logger.

Parameters:
  • run_name (str | None) – Name for this specific run

  • experiment_name (str) – Name of the MLflow experiment

  • tracking_uri (str | None) – MLflow tracking server URI (None uses local mlruns/)

  • verbose (bool) – Whether to print logging messages

property run_id: str

Get the current run ID.

property experiment_name: str

Get the current experiment name.

log_params(params)[source]

Logs parameters to MLflow and stores in history.

Parameters:

params (Dict[str, Any])

log_metric(key, value, step=0)[source]

Logs a metric to MLflow and stores in history.

Parameters:
log_metrics(metrics, step=0)[source]

Logs multiple metrics efficiently.

Parameters:
log_artifact(artifact_path, artifact_name=None)[source]

Logs an artifact file to MLflow.

Parameters:
  • artifact_path (str)

  • artifact_name (str | None)

log_model(model, artifact_path='model', **kwargs)[source]

Log a model to MLflow using the framework-appropriate flavor.

Parameters:

artifact_path (str)

log_figure(figure, artifact_name)[source]

Logs a matplotlib figure as an artifact.

Parameters:

artifact_name (str)

log_dataframe(df, artifact_name)[source]

Logs a pandas DataFrame as a CSV artifact.

Parameters:
log_confusion_matrix(cm_df, artifact_name='confusion_matrix.csv')[source]

Logs a confusion matrix DataFrame.

Parameters:
log_training_history(history, artifact_name='training_history.csv')[source]

Logs training history as both metrics and artifact.

Parameters:
set_tags(tags)[source]

Sets tags for the current run.

Parameters:

tags (Dict[str, str])

log_system_info()[source]

Logs system information as tags.

start_child_run(run_name=None)[source]

Start a nested child run under the current parent run.

Parameters:

run_name (str | None)

Return type:

str

end_child_run()[source]

End the current nested child run.

Return type:

None

end_run()[source]

Ends the MLflow run.

log_study_summary(results)[source]

Log statistical summary of a completed study to the parent run.

Logs mean and SD for all tracked validation metrics, and mean and SD for all tracked test metrics when test data is present.

Parameters:

results (Any) – A VariabilityStudyResults object from run_study() or variability_study().

Return type:

None

get_run_url()[source]

Return the MLflow UI URL for this run.

For remote tracking servers, uses the configured tracking URI directly. For local file-based tracking (file://), defaults to http://localhost:5000 — the standard mlflow ui address. Override with the MLFLOW_UI_URL environment variable when serving the UI on a non-default host or port.

Return type:

str