pub struct Run { /* private fields */ }Implementations§
Source§impl Run
impl Run
Sourcepub fn log(&mut self, key: &str, value: f64, step: u64) -> Result<(), LogError>
pub fn log(&mut self, key: &str, value: f64, step: u64) -> Result<(), LogError>
Log a single metric data point.
Steps must be monotonically increasing per metric key. Logging a step less than or equal to the previous step for the same key returns an error.
Examples found in repository?
examples/rust_api.rs (line 15)
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}Sourcepub fn points_logged(&self) -> u64
pub fn points_logged(&self) -> u64
Examples found in repository?
examples/rust_api.rs (line 24)
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}pub fn points_dropped(&self) -> u64
Sourcepub fn id(&self) -> RunId
pub fn id(&self) -> RunId
Examples found in repository?
examples/rust_api.rs (line 8)
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}Sourcepub fn finish(self) -> Result<RunStats, FinishError>
pub fn finish(self) -> Result<RunStats, FinishError>
Flushes remaining points and waits for the pipeline to drain.
Examples found in repository?
examples/rust_api.rs (line 26)
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§impl Run
impl Run
Sourcepub fn builder() -> RunBuilder
pub fn builder() -> RunBuilder
Examples found in repository?
examples/rust_api.rs (line 2)
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}Auto Trait Implementations§
impl !RefUnwindSafe for Run
impl !UnwindSafe for Run
impl Freeze for Run
impl Send for Run
impl Sync for Run
impl Unpin for Run
impl UnsafeUnpin for Run
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
Mutably borrows from an owned value. Read more