Skip to content

Commit

Permalink
chore: allow for multiple redirect calls during calibrate (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-camuto authored Nov 21, 2023
1 parent df27e81 commit e30683a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/bin/ezkl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn main() -> Result<(), Box<dyn Error>> {
info!("Running with CPU");
}
info!("command: \n {}", &args.as_json()?.to_colored_json_auto()?);
let res = run(args).await;
let res = run(args.command).await;
match &res {
Ok(_) => info!("succeeded"),
Err(e) => error!("failed: {}", e),
Expand Down
5 changes: 3 additions & 2 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'source> FromPyObject<'source> for TranscriptType {
}
}

#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, PartialOrd)]
/// Determines what the calibration pass should optimize for
pub enum CalibrationTarget {
/// Optimizes for reducing cpu and memory usage
Expand Down Expand Up @@ -171,8 +171,9 @@ impl Cli {
}

#[allow(missing_docs)]
#[derive(Debug, Subcommand, Clone, Deserialize, Serialize)]
#[derive(Debug, Subcommand, Clone, Deserialize, Serialize, PartialEq, PartialOrd)]
pub enum Commands {
Empty,
/// Loads model and prints model table
#[command(arg_required_else_help = true)]
Table {
Expand Down
25 changes: 19 additions & 6 deletions src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::circuit::CheckMode;
#[cfg(not(target_arch = "wasm32"))]
use crate::commands::CalibrationTarget;
use crate::commands::{Cli, Commands};
use crate::commands::Commands;
#[cfg(not(target_arch = "wasm32"))]
use crate::eth::{deploy_da_verifier_via_solidity, deploy_verifier_via_solidity};
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -111,8 +111,9 @@ pub enum ExecutionError {
}

/// Run an ezkl command with given args
pub async fn run(cli: Cli) -> Result<(), Box<dyn Error>> {
match cli.command {
pub async fn run(command: Commands) -> Result<(), Box<dyn Error>> {
match command {
Commands::Empty => Ok(()),
#[cfg(not(target_arch = "wasm32"))]
Commands::Fuzz {
witness,
Expand Down Expand Up @@ -615,7 +616,13 @@ pub(crate) fn calibrate(
let settings = GraphSettings::load(&settings_path)?;
// now retrieve the run args
// we load the model to get the input and output shapes
let _r = Gag::stdout().unwrap();
// check if gag already exists

let _r = match Gag::stdout() {
Ok(r) => Some(r),
Err(_) => None,
};

let model = Model::from_run_args(&settings.run_args, &model_path).unwrap();
// drop the gag
std::mem::drop(_r);
Expand Down Expand Up @@ -679,8 +686,14 @@ pub(crate) fn calibrate(
// vec of settings copied chunks.len() times
let run_args_iterable = vec![settings.run_args.clone(); chunks.len()];

let _r = Gag::stdout().unwrap();
let _q = Gag::stderr().unwrap();
let _r = match Gag::stdout() {
Ok(r) => Some(r),
Err(_) => None,
};
let _q = match Gag::stderr() {
Ok(r) => Some(r),
Err(_) => None,
};

let tasks = chunks
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl GraphCircuit {
}
}

#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, PartialOrd)]
/// The data source for a test
pub enum TestDataSource {
/// The data is loaded from a file
Expand Down
4 changes: 2 additions & 2 deletions src/pfsys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use thiserror::Error as thisError;
use halo2curves::bn256::{Bn256, Fr, G1Affine};

#[allow(missing_docs)]
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, PartialOrd)]
pub enum ProofType {
Single,
ForAggr,
Expand Down Expand Up @@ -142,7 +142,7 @@ pub enum PfSysError {
}

#[allow(missing_docs)]
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
#[derive(ValueEnum, Copy, Clone, Debug, PartialEq, Eq, Deserialize, Serialize, PartialOrd)]
pub enum TranscriptType {
Poseidon,
EVM,
Expand Down

0 comments on commit e30683a

Please sign in to comment.