def test_logger_with_prefix_all(mlflow_mock, wandb_mock, comet_mock, neptune_mock, monkeypatch, tmp_path):
    """Test that prefix is added at the beginning of the metric keys."""
    prefix = "tmp"

    # Comet
    _patch_comet_atexit(monkeypatch)
    logger = _instantiate_logger(CometLogger, save_dir=tmp_path, prefix=prefix)
    logger.log_metrics({"test": 1.0}, step=0)
    logger.experiment.__internal_api__log_metrics__.assert_called_once_with(
        {"test": 1.0}, epoch=None, step=0, prefix=prefix, framework="pytorch-lightning"
    )

    # MLflow
    Metric = mlflow_mock.entities.Metric
    logger = _instantiate_logger(MLFlowLogger, save_dir=tmp_path, prefix=prefix)
    logger.log_metrics({"test": 1.0}, step=0)
    logger.experiment.log_batch.assert_called_once_with(
        run_id=ANY, metrics=[Metric(key="tmp-test", value=1.0, timestamp=ANY, step=0)]
    )

    # Neptune
    logger = _instantiate_logger(NeptuneLogger, api_key="test", project="project", save_dir=tmp_path, prefix=prefix)
    assert logger.experiment.__getitem__.call_count == 0
    logger.log_metrics({"test": 1.0}, step=0)
    assert logger.experiment.__getitem__.call_count == 1
    logger.experiment.__getitem__.assert_called_with("tmp/test")
    logger.experiment.__getitem__().append.assert_called_once_with(1.0, step=0)

    # TensorBoard
    if _TENSORBOARD_AVAILABLE:
        import torch.utils.tensorboard as tb
    else:
        import tensorboardX as tb

    monkeypatch.setattr(tb, "SummaryWriter", Mock())
    logger = _instantiate_logger(TensorBoardLogger, save_dir=tmp_path, prefix=prefix)
    logger.log_metrics({"test": 1.0}, step=0)
    logger.experiment.add_scalar.assert_called_once_with("tmp-test", 1.0, 0)

    # WandB
    logger = _instantiate_logger(WandbLogger, save_dir=tmp_path, prefix=prefix)
    wandb_mock.run = None
    wandb_mock.init().step = 0
    logger.log_metrics({"test": 1.0}, step=0)
    logger.experiment.log.assert_called_once_with({"tmp-test": 1.0, "trainer/global_step": 0})
Test that prefix is added at the beginning of the metric keys.
tests/tests_pytorch/loggers/test_all.py