burn-train 0.22.0-pre.3

Training crate for the Burn framework
Documentation
#[cfg(feature = "tui")]
use std::io::IsTerminal;

mod base;
pub use base::*;

pub(crate) mod cli;

pub use cli::*;

/// The tui renderer
#[cfg(feature = "tui")]
pub mod tui;
use crate::Interrupter;

/// Return the default metrics renderer.
///
/// This can be either:
///   - `TuiMetricsRenderer`, when the `tui` feature is enabled and `stdout` is
///     a terminal, or
///   - `CliMetricsRenderer`, when the `tui` feature is not enabled, or `stdout`
///     is not a terminal.
pub fn default_renderer(
    #[cfg_attr(not(feature = "tui"), allow(unused_variables))] interuptor: Interrupter,
    #[cfg_attr(not(feature = "tui"), allow(unused_variables))] checkpoint: Option<usize>,
) -> Box<dyn MetricsRenderer> {
    #[cfg(feature = "tui")]
    if std::io::stdout().is_terminal() {
        return Box::new(tui::TuiMetricsRendererWrapper::new(interuptor, checkpoint));
    }

    Box::new(CliMetricsRenderer::new())
}