clankers-cli 0.1.5

Command-line interface for clankeRS
Documentation
use anyhow::Result;
use clankers_ml::ModelValidator;

pub fn execute(
    pytorch: Option<&str>,
    checkpoint: Option<&str>,
    onnx: &str,
    samples: &str,
    tolerance: f32,
) -> Result<()> {
    // Refuse rather than silently ignore: a user passing their checkpoint must
    // not get a green "safe to deploy" that never touched it.
    if pytorch.is_some() || checkpoint.is_some() {
        anyhow::bail!(
            "--pytorch/--checkpoint are not supported yet: live PyTorch comparison \
             is planned but not implemented, and silently ignoring these flags could \
             produce a misleading pass.\n\
             Instead: export reference outputs next to your sample inputs as \
             `expected_output.json` (see `clankers import-pytorch` and \
             docs/pytorch_to_onnx.md), then run:\n  \
             clankers validate-model --onnx {onnx} --samples {samples}"
        );
    }

    let report = ModelValidator::new()
        .onnx_model(onnx)
        .sample_inputs(samples)
        .tolerance(tolerance)
        .validate()
        .map_err(|e| anyhow::anyhow!("{e}"))?;

    report.print();

    if !report.passed {
        anyhow::bail!("model validation failed");
    }
    Ok(())
}