Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 9 additions & 4 deletions asap-planner-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct Args {

/// `milp` plans with sketch-bench's rqe-optimizer: PromQL or SQL with
/// --input_config only, labels from its `metrics:` hints or tables'
/// `metadata_columns`. `saved` writes a PromQL plan sketch-bench's
/// `metadata_columns`. `saved` writes a PromQL or SQL plan sketch-bench's
/// `autosketch_vs_asap` already solved.
#[arg(long, value_enum, default_value = "legacy")]
planner: PlannerArg,
Expand All @@ -70,7 +70,8 @@ struct Args {
plan: Option<PathBuf>,

/// Saved only. The eval workload table the plan was solved for; its
/// `e2e` block gives the PromQL queries and metric labels.
/// `e2e` block gives the queries in --query-language and the metrics'
/// labels.
#[arg(long = "workload-table", required_if_eq("planner", "saved"))]
workload_table: Option<PathBuf>,

Expand Down Expand Up @@ -339,8 +340,11 @@ fn run_milp(args: &Args) -> anyhow::Result<()> {

fn run_saved(args: &Args) -> anyhow::Result<()> {
anyhow::ensure!(
args.query_language == QueryLanguage::promql,
"--planner saved supports only --query-language promql"
matches!(
args.query_language,
QueryLanguage::promql | QueryLanguage::sql

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Language is validated twice: this matches!(promql | sql) guard duplicates the other => bail! in E2eQuery::text (which also reruns per query). Two error strings for one condition; adding a language means editing both.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 7459ec4: the language is checked once, at the top of saved_plan_output. The main.rs guard is gone, and E2eQuery::text only picks the field.

),
"--planner saved supports only --query-language promql or sql"
);
let scrape_interval_ms = check_optimizer_flags(args, "saved")?;
anyhow::ensure!(
Expand All @@ -359,6 +363,7 @@ fn run_saved(args: &Args) -> anyhow::Result<()> {
weights: args.weights.as_deref().expect("clap requires --weights"),
sla_ms: args.sla_ms,
},
args.query_language,
scrape_interval_ms,
)?
.write_to_dir(&args.output_dir)?;
Expand Down
Loading
Loading