Skip to content
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
21 changes: 14 additions & 7 deletions crates/bento-bench/src/commands/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::{Context, Result, anyhow};
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::Path;
Expand All @@ -22,16 +22,23 @@ pub struct ManifestEntry {
pub cycles: u64,
}

pub fn load_manifest(manifest_dir: &Path) -> Result<Manifest> {
pub fn load_manifest(manifest_dir: &Path, create: bool) -> Result<Manifest> {
let manifest_path = manifest_dir.join("manifest.json");

if !fs::exists(&manifest_path).unwrap_or(false) {
let manifest = Manifest {
description: String::from("TODO"),
entries: Vec::new(),
return match create {
true => {
let manifest = Manifest {
description: String::from("TODO"),
entries: Vec::new(),
};
tracing::warn!(
"New manifest file will be created, description needs to be updated"
);
Ok(manifest)
}
false => Err(anyhow!("No manifest file found in {manifest_dir:?}")),
};
tracing::warn!("New manifest file will be created, description needs to be updated");
return Ok(manifest);
}

let manifest_str = fs::read_to_string(&manifest_path)
Expand Down
2 changes: 1 addition & 1 deletion crates/bento-bench/src/commands/prepare_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PrepareLocalArgs {
pub async fn run(&self) -> Result<()> {
let data_dir = self.common.data_dir.clone();

let mut manifest = load_manifest(&self.common.data_dir)?;
let mut manifest = load_manifest(&self.common.data_dir, true)?;

let images_dir = data_dir.join("images");
create_dir_all(&images_dir).await.context(format!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bento-bench/src/commands/prepare_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl PrepareRequestArgs {
pub async fn run(&self) -> Result<()> {
let data_dir = self.common.data_dir.clone();

let mut manifest = load_manifest(&self.common.data_dir)?;
let mut manifest = load_manifest(&self.common.data_dir, true)?;

let images_dir = data_dir.join("images");
create_dir_all(&images_dir).await.context(format!(
Expand Down
2 changes: 1 addition & 1 deletion crates/bento-bench/src/commands/run_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub struct BenchJsonOutput {

impl RunArgs {
pub async fn run(&self) -> Result<()> {
let manifest = load_manifest(&self.common.data_dir)?;
let manifest = load_manifest(&self.common.data_dir, false)?;

self.prover_config
.proving_backend
Expand Down
Loading