Skip to content

Add tests for tensorboard and wandb#899

Open
diyasrivas wants to merge 3 commits intomainfrom
ds/logging_tests
Open

Add tests for tensorboard and wandb#899
diyasrivas wants to merge 3 commits intomainfrom
ds/logging_tests

Conversation

@diyasrivas
Copy link
Copy Markdown
Member

@diyasrivas diyasrivas commented Apr 15, 2026

Disclaimer

  • I am an AI agent.
  • I have used AI and I thoroughly reviewed every line.
  • I have not used AI extensively.

Description

Note

tldr:
Adds unit tests for the logger field on TrainingConfig and NGTrainingConfig, and also tests for TensorBoard and WandB logger initialisation in CAREamistV2.

Background - why do we need this PR?

WandB and TensorBoard logging in CAREamics currently lacks tests. The existing tests/utils/test_wandb.py was outdated and commented out, having not been updated for the Lightning-based API. As a result, there's no verification for the logging.

Overview - what changed?

  1. A new test file covering the logger on both TrainingConfig (old CAREamist) and NGTrainingConfig (CAREamistV2).

2.New tests added to the existing tests/test_careamist_v2_train.py, checking that each logger backend is correctly set up through to the Lightning Trainer and that training completes successfully with each.

I also added interoperability pytest mark in the pyproject.toml.

Implementation - how did you implement the changes?

For tests/config/test_training_config.py: Pydantic's Literal["wandb", "tensorboard"] | None enforces valid values at assignment time; tests exercise this directly via ValidationError assertions

For tests/test_careamist_v2_train.py:

  • Each test runs a minimal 1-epoch N2V training pass on a small random array and inspects careamist.trainer.loggers
  • WandB disabled-mode test sets WANDB_MODE=disabled so the test runs without a WandB account, making it safe to run in any environment
  • Live WandB test is skipped automatically if WANDB_API_KEY is not set; when credentials are present, it verifies that metrics are actually logged to a real WandB run, using a dedicated test project

Changes Made

New features or files

  • tests/config/test_training_config.py: 19 tests for the logger field on TrainingConfig and NGTrainingConfig

Modified features or files

  • tests/test_careamist_v2_train.py: 4 tests for TensorBoard and WandB logger initialisation and training
  • pyproject.toml: interoperability mark added to [tool.pytest.ini_options]

Removed features or files

  • removed tests/utils/test_wandb.py

How has this been tested?

All tests ran locally and passed.

Related Issues

Closes #537

Breaking changes

None

Additional Notes and Examples


Please ensure your PR meets the following requirements:

  • Code builds and passes tests locally, including doctests
  • New tests have been added (for bug fixes/features)
  • Documentation has been updated
  • Pre-commit passes

@diyasrivas diyasrivas requested a review from jdeschamps April 15, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Test WandB and TensorBoard

1 participant