@@ -609,6 +609,29 @@ def _import():
609609
610610# ------------------------- TensorBoardX --------------------------
611611
612+
613+ class StubSummaryWriter :
614+ """Stubbed TensorBoardX SummaryWriter replacement."""
615+
616+ def __init__ (self , * args , ** kwargs ): # pylint: disable=unused-argument
617+ del args , kwargs
618+
619+ def add_text (self , * args , ** kwargs ):
620+ pass
621+
622+ def add_scalar (self , * args , ** kwargs ):
623+ pass
624+
625+ def add_histogram (self , * args , ** kwargs ):
626+ pass
627+
628+ def flush (self ):
629+ pass
630+
631+ def close (self ):
632+ pass
633+
634+
612635try :
613636 if not is_decoupled (): # Only attempt real import when not decoupled
614637 from tensorboardX import writer # type: ignore # pylint: disable=import-outside-toplevel,unused-import
@@ -619,30 +642,10 @@ def _import():
619642except Exception : # pragma: no cover - provide stub fallback # pylint: disable=broad-exception-caught
620643 _TENSORBOARDX_AVAILABLE = False
621644
622- class _StubSummaryWriter :
623- """Stubbed TensorBoardX SummaryWriter replacement."""
624-
625- def __init__ (self , * args , ** kwargs ): # pylint: disable=unused-argument
626- del args , kwargs
627-
628- def add_text (self , * args , ** kwargs ):
629- pass
630-
631- def add_scalar (self , * args , ** kwargs ):
632- pass
633-
634- def add_histogram (self , * args , ** kwargs ):
635- pass
636-
637- def flush (self ):
638- pass
639-
640- def close (self ):
641- pass
642-
643645 class writer : # pylint: disable=too-few-public-methods
644- SummaryWriter = _StubSummaryWriter
646+ SummaryWriter = StubSummaryWriter
645647
646648
647649__all__ .append ("writer" )
648650__all__ .append ("_TENSORBOARDX_AVAILABLE" )
651+ __all__ .append ("StubSummaryWriter" )
0 commit comments