Skip to main content

RunBuilder

Struct RunBuilder 

Source
pub struct RunBuilder { /* private fields */ }
Expand description

Configure and start a Run.

All fields have defaults. The simplest usage is:

let mut run = Run::builder().start()?;

Implementations§

Source§

impl RunBuilder

Source

pub fn run_id(self, id: RunId) -> Self

Source

pub fn name(self, name: impl Into<String>) -> Self

Source

pub fn project(self, name: impl Into<String>) -> Self

Source

pub fn experiment(self, name: impl Into<String>) -> Self

Source

pub fn user(self, id: UserId) -> Self

Source

pub fn tags(self, tags: Vec<String>) -> Self

Source

pub fn tag(self, tag: impl Into<String>) -> Self

Source

pub fn wal_dir(self, dir: impl Into<PathBuf>) -> Self

Source

pub fn wal(self, wal: WalKind) -> Self

Source

pub fn max_points_per_batch(self, n: usize) -> Self

Examples found in repository?
examples/rust_api.rs (line 4)
1fn main() {
2    let mut run = photon::Run::builder()
3        .endpoint("[::1]:50051")
4        .max_points_per_batch(50)
5        .start()
6        .expect("failed to start run");
7
8    println!("Run: {}", run.id());
9
10    // Simulate a training loop
11    for step in 0..200 {
12        let loss = 1.0 / (1.0 + step as f64 * 0.05);
13        let accuracy = 1.0 - loss;
14
15        run.log("train/loss", loss, step).unwrap();
16        run.log("train/accuracy", accuracy, step).unwrap();
17
18        if step % 10 == 0 {
19            let lr = 0.001 * 0.95_f64.powi(step as i32 / 10);
20            run.log("train/lr", lr, step).unwrap();
21        }
22    }
23
24    println!("Logged: {} points", run.points_logged());
25
26    let stats = run.finish().expect("finish failed");
27
28    println!("\n--- Results ---");
29    println!("Points:       {}", stats.points);
30    println!("Dropped:      {}", stats.points_dropped);
31    println!("Batches:      {}", stats.batches);
32    println!("Bytes (raw):  {}", stats.bytes_uncompressed);
33    println!("Bytes (wire): {}", stats.bytes_compressed);
34    println!("Sent:         {}", stats.batches_sent);
35    println!("Acked:        {}", stats.batches_acked);
36
37    assert!(stats.batches > 0);
38    assert_eq!(stats.points, 420);
39    assert_eq!(stats.points_dropped, 0);
40
41    println!("\nAll checks passed!");
42}
Source

pub fn batch_interval(self, interval: Duration) -> Self

Source

pub fn channel_capacity(self, cap: usize) -> Self

Source

pub fn codec(self, codec: CodecKind) -> Self

Source

pub fn compressor(self, compressor: CompressorKind) -> Self

Source

pub fn transport(self, transport: TransportKind) -> Self

Source

pub fn endpoint(self, url: impl Into<String>) -> Self

Examples found in repository?
examples/rust_api.rs (line 3)
1fn main() {
2    let mut run = photon::Run::builder()
3        .endpoint("[::1]:50051")
4        .max_points_per_batch(50)
5        .start()
6        .expect("failed to start run");
7
8    println!("Run: {}", run.id());
9
10    // Simulate a training loop
11    for step in 0..200 {
12        let loss = 1.0 / (1.0 + step as f64 * 0.05);
13        let accuracy = 1.0 - loss;
14
15        run.log("train/loss", loss, step).unwrap();
16        run.log("train/accuracy", accuracy, step).unwrap();
17
18        if step % 10 == 0 {
19            let lr = 0.001 * 0.95_f64.powi(step as i32 / 10);
20            run.log("train/lr", lr, step).unwrap();
21        }
22    }
23
24    println!("Logged: {} points", run.points_logged());
25
26    let stats = run.finish().expect("finish failed");
27
28    println!("\n--- Results ---");
29    println!("Points:       {}", stats.points);
30    println!("Dropped:      {}", stats.points_dropped);
31    println!("Batches:      {}", stats.batches);
32    println!("Bytes (raw):  {}", stats.bytes_uncompressed);
33    println!("Bytes (wire): {}", stats.bytes_compressed);
34    println!("Sent:         {}", stats.batches_sent);
35    println!("Acked:        {}", stats.batches_acked);
36
37    assert!(stats.batches > 0);
38    assert_eq!(stats.points, 420);
39    assert_eq!(stats.points_dropped, 0);
40
41    println!("\nAll checks passed!");
42}
Source

pub fn start(self) -> Result<Run, StartError>

Examples found in repository?
examples/rust_api.rs (line 5)
1fn main() {
2    let mut run = photon::Run::builder()
3        .endpoint("[::1]:50051")
4        .max_points_per_batch(50)
5        .start()
6        .expect("failed to start run");
7
8    println!("Run: {}", run.id());
9
10    // Simulate a training loop
11    for step in 0..200 {
12        let loss = 1.0 / (1.0 + step as f64 * 0.05);
13        let accuracy = 1.0 - loss;
14
15        run.log("train/loss", loss, step).unwrap();
16        run.log("train/accuracy", accuracy, step).unwrap();
17
18        if step % 10 == 0 {
19            let lr = 0.001 * 0.95_f64.powi(step as i32 / 10);
20            run.log("train/lr", lr, step).unwrap();
21        }
22    }
23
24    println!("Logged: {} points", run.points_logged());
25
26    let stats = run.finish().expect("finish failed");
27
28    println!("\n--- Results ---");
29    println!("Points:       {}", stats.points);
30    println!("Dropped:      {}", stats.points_dropped);
31    println!("Batches:      {}", stats.batches);
32    println!("Bytes (raw):  {}", stats.bytes_uncompressed);
33    println!("Bytes (wire): {}", stats.bytes_compressed);
34    println!("Sent:         {}", stats.batches_sent);
35    println!("Acked:        {}", stats.batches_acked);
36
37    assert!(stats.batches > 0);
38    assert_eq!(stats.points, 420);
39    assert_eq!(stats.points_dropped, 0);
40
41    println!("\nAll checks passed!");
42}

Trait Implementations§

Source§

impl Default for RunBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,