Skip to content

Enhance TensorBoard test verification in test notebooks #1263

Open
@coderabbitai

Description

@coderabbitai

Problem

Currently, the test_tensorboard() method in various test notebooks (e.g., jupyter/rocm/tensorflow/ubi9-python-3.12/test/test_notebook.ipynb) trains a model with TensorBoard callbacks but does not verify that the logging functionality actually worked or that log files were created.

Background

This issue was identified during review of PR #1259 (#1259 (comment)) where the TensorBoard test lacks proper verification of its core functionality.

Acceptance Criteria

  • Update test_tensorboard() methods across all test notebooks to verify log file creation
  • Use temporary directories for log storage during testing to avoid filesystem pollution
  • Add assertions to check that log files exist and contain expected content
  • Ensure tests clean up temporary files after completion
  • Verify the solution works across all affected notebook images (TensorFlow, PyTorch, etc.)

Implementation Guidance

  1. Search for all affected files:

    find . -name "test_notebook.ipynb" -exec grep -l "test_tensorboard" {} \;
  2. For each affected file, update the test method to:

    • Import os and tempfile modules
    • Use tempfile.TemporaryDirectory() for log storage
    • Add verification that log files are created
    • Include proper error messages in assertions
  3. Example implementation pattern:

    def test_tensorboard(self):
        import os
        import tempfile
        
        # Create model and prepare data...
        
        with tempfile.TemporaryDirectory() as log_dir:
            tensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir)
            # Train model...
            
            # Verify log files were created
            log_files = os.listdir(log_dir)
            self.assertTrue(len(log_files) > 0, "TensorBoard should create log files")

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions