Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Prover CLI): Refactor status cmd #1705

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions prover/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions prover/prover_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{command, Parser, Subcommand};

use crate::commands::{get_file_info, jobs_status};
use crate::commands::{self, get_file_info, status};

pub const VERSION_STRING: &str = env!("CARGO_PKG_VERSION");

Expand All @@ -14,14 +14,15 @@ struct ProverCLI {
#[derive(Subcommand)]
enum ProverCommand {
FileInfo(get_file_info::Args),
StatusJobs(jobs_status::Args),
#[command(subcommand)]
Status(commands::StatusCommand),
}

pub async fn start() -> anyhow::Result<()> {
let ProverCLI { command } = ProverCLI::parse();
match command {
ProverCommand::FileInfo(args) => get_file_info::run(args).await?,
ProverCommand::StatusJobs(args) => jobs_status::run(args).await?,
ProverCommand::Status(status_cmd) => status::run(status_cmd).await?,
};

Ok(())
Expand Down
10 changes: 9 additions & 1 deletion prover/prover_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
use clap::Subcommand;
use status::jobs;

pub(crate) mod get_file_info;
pub(crate) mod jobs_status;
pub(crate) mod status;

#[derive(Subcommand)]
pub(crate) enum StatusCommand {
Jobs(jobs::Args),
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@ pub(crate) struct Args {
verbose: bool,
}

fn pretty_print_job_status(
l1_batch_number: &L1BatchNumber,
statistics: &JobCountStatistics,
verbose: bool,
) {
let total_jobs =
statistics.queued + statistics.in_progress + statistics.failed + statistics.successful;
let progress = (statistics.successful as f32 / total_jobs as f32) * 100.0;
println!("Batch number: {}", l1_batch_number);
println!(
"Progress: {:.2}% ({}/{})",
progress, statistics.successful, total_jobs
);
if verbose {
println!("In progress: {}", statistics.in_progress);
println!("Queued: {}", statistics.in_progress);
println!("Successful: {}", statistics.in_progress);
}
println!("Failed: {}", statistics.failed);
}

pub(crate) async fn run(args: Args) -> anyhow::Result<()> {
let postgres_config = PostgresConfig::from_env().context("PostgresConfig::from_env()")?;

Expand Down Expand Up @@ -61,3 +40,24 @@ pub(crate) async fn run(args: Args) -> anyhow::Result<()> {
}
Ok(())
}

fn pretty_print_job_status(
l1_batch_number: &L1BatchNumber,
statistics: &JobCountStatistics,
verbose: bool,
) {
let total_jobs =
statistics.queued + statistics.in_progress + statistics.failed + statistics.successful;
let progress = (statistics.successful as f32 / total_jobs as f32) * 100.0;
println!("Batch number: {}", l1_batch_number);
println!(
"Progress: {:.2}% ({}/{})",
progress, statistics.successful, total_jobs
);
if verbose {
println!("In progress: {}", statistics.in_progress);
println!("Queued: {}", statistics.in_progress);
println!("Successful: {}", statistics.in_progress);
}
println!("Failed: {}", statistics.failed);
}
9 changes: 9 additions & 0 deletions prover/prover_cli/src/commands/status/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use super::StatusCommand;

pub(crate) mod jobs;

pub(crate) async fn run(status_cmd: StatusCommand) -> anyhow::Result<()> {
match status_cmd {
StatusCommand::Jobs(args) => jobs::run(args).await,
}
}
2 changes: 2 additions & 0 deletions prover/prover_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use prover_cli::cli;
#[tokio::main]
async fn main() {
env_logger::builder()
.filter_module("zksync_db_connection::connection_pool", log::LevelFilter::Off)
.filter_module("sqlx::query", log::LevelFilter::Off)
.filter_level(log::LevelFilter::Debug)
.init();

Expand Down
Loading