pub struct DashboardServerExt {
pub config: DashboardConfig,
pub loss_history: MetricHistory,
pub lr_history: MetricHistory,
pub grad_norm_history: MetricHistory,
pub connected_clients: usize,
pub messages_sent: u64,
/* private fields */
}Expand description
In-process training dashboard that records metric histories and can generate CSV / JSON summaries suitable for logging or downstream tools.
This is an in-process implementation that does not bind network sockets.
For SSE streaming, see super::websocket::DashboardServer.
§Example
use trustformers_debug::dashboard_ws::metrics::{DashboardConfig, DashboardServerExt};
let mut server = DashboardServerExt::new(DashboardConfig::default());
server.record_metrics(10, 1.5, 1e-3, 0.9);
server.record_metrics(20, 1.2, 9e-4, 0.85);
let csv = server.format_metric_csv();
assert!(csv.contains("step"));Fields§
§config: DashboardConfig§loss_history: MetricHistory§lr_history: MetricHistory§grad_norm_history: MetricHistory§connected_clients: usize§messages_sent: u64Implementations§
Source§impl DashboardServerExt
impl DashboardServerExt
Sourcepub fn new(config: DashboardConfig) -> Self
pub fn new(config: DashboardConfig) -> Self
Creates a new in-process dashboard server with the given configuration.
Sourcepub fn record_metrics(&mut self, step: u64, loss: f32, lr: f32, grad_norm: f32)
pub fn record_metrics(&mut self, step: u64, loss: f32, lr: f32, grad_norm: f32)
Records one training step into the internal metric histories.
Sourcepub fn broadcast_message(
&mut self,
msg: &DashboardMessage,
) -> Result<(), DashboardError>
pub fn broadcast_message( &mut self, msg: &DashboardMessage, ) -> Result<(), DashboardError>
Appends a DashboardMessage to the internal broadcast buffer.
Returns DashboardError::BufferFull when the buffer is at capacity.
Sourcepub fn buffered_messages(&self) -> &[DashboardMessage]
pub fn buffered_messages(&self) -> &[DashboardMessage]
Returns all messages currently in the broadcast buffer (in order).
Sourcepub fn clear_buffer(&mut self)
pub fn clear_buffer(&mut self)
Clears the broadcast buffer.
Sourcepub fn generate_summary_json(&self) -> String
pub fn generate_summary_json(&self) -> String
Returns a JSON summary of all metric histories.
Includes the latest value, a 10-point trend (slope), and EMA
(α = 0.1) for each of loss, lr, and grad_norm.
§Example
use trustformers_debug::dashboard_ws::metrics::{DashboardConfig, DashboardServerExt};
let mut s = DashboardServerExt::new(DashboardConfig::default());
s.record_metrics(1, 2.0, 1e-3, 0.5);
let json = s.generate_summary_json();
assert!(json.contains("\"loss\""));Sourcepub fn format_metric_csv(&self) -> String
pub fn format_metric_csv(&self) -> String
Exports all recorded metrics as a CSV string.
Columns: step,loss,lr,grad_norm
Rows are aligned by index — if one history is shorter it writes empty cells.
Auto Trait Implementations§
impl Freeze for DashboardServerExt
impl RefUnwindSafe for DashboardServerExt
impl Send for DashboardServerExt
impl Sync for DashboardServerExt
impl Unpin for DashboardServerExt
impl UnsafeUnpin for DashboardServerExt
impl UnwindSafe for DashboardServerExt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.