scientisto

Crates.ioscientisto
lib.rsscientisto
version0.3.0
sourcesrc
created_at2023-01-27 21:11:20.425849
updated_at2023-05-24 14:05:25.689375
descriptionA light-weight Rust implementation of the github/scientist library used for careful refactoring of critical code paths.
homepagehttps://teebor-choka.github.io/scientisto/scientisto/index.html
repositoryhttps://github.com/Teebor-Choka/scientisto
max_upload_size
id769920
size29,605
Tibor (Teebor-Choka)

documentation

https://teebor-choka.github.io/scientisto/scientisto/index.html

README

Scientisto

Crates.io MIT licensed Publish codecov

scientisto is a light-weight Rust implementation of the github/scientist library used for careful refactoring of critical code paths. It provides the Experiment struct used to define the conducted experiment and publishing utilities.

About

The library aims to be as minimal as possible, pulling no external dependencies and using a bare minimum from the std library.

Usage

Experiment and AsyncExperiment structs represents a definition of the control and experimental execution block code paths.

The experiment is guided by the configuration specified during the Experiment construction and result observations are published internally using the publish function.

use scientisto::{Experiment,Observation};
use tracing;

let expected: i32 = 1;
let result = Experiment::new("Test")
    .control(|| expected)
    .experiment(|| expected + 1)
    .publish(|o: &Observation<i32, i32>| {
        tracing::info!("You can do any magic in the publisher")
     })
    .run();

For async code the AsyncExperiment alternative can be used:

use scientisto::{AsyncExperiment,Observation};
use tracing::info;

async_std::task::block_on(async {
    AsyncExperiment::new("Test")
        .control(async { 3.0 })
        .experiment(async { 3.0 })
        .publish(|o: &Observation<f32, f32>| {
            assert!(o.is_matching());
            info!("Any logic, including side effects, can be here!")
         })
        .run().await;
})

Limitations

  • No defaults are provided for the control and experiment callbacks, they must be fully specified

Testing

Current code coverage with tests:

Code coverage

License

MIT

Commit count: 51

cargo fmt