Skip to content

Commit

Permalink
stub args for constraints tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imalsogreg committed Nov 21, 2024
1 parent afec665 commit bd68b27
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
18 changes: 0 additions & 18 deletions engine/baml-lib/baml-core/src/ir/jinja_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,6 @@ pub fn evaluate_predicate(
}
}

pub fn evaluate_test_result(
result: &BamlValueWithMeta<()>,
predicate_expression: &JinjaExpression,
) -> Result<bool, anyhow::Error> {
let result: BamlValue = result.into();
let ctx: HashMap<String, minijinja::Value> = [(
"result".to_string(),
minijinja::Value::from_serialize(result),
)]
.into_iter()
.collect();
match render_expression(&predicate_expression, &ctx)?.as_ref() {
"true" => Ok(true),
"false" => Ok(false),
_ => Err(anyhow::anyhow!("Predicated did not evaluate to a boolean")),
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
3 changes: 2 additions & 1 deletion engine/baml-runtime/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,11 @@ mod tests {
}

fn run_pipeline(constraints: &[Constraint]) -> TestConstraintsResult {
let args = IndexMap::new();
let value = mk_value();
let constraints = constraints.into();
let response = mk_response();
evaluate_test_constraints(&value, &response, constraints)
evaluate_test_constraints(&args, &value, &response, constraints)
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion engine/baml-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use internal_baml_core::configuration::CloudProject;
use internal_baml_core::configuration::CodegenGenerator;
use internal_baml_core::configuration::Generator;
use internal_baml_core::configuration::GeneratorOutputType;
use internal_baml_core::ir::jinja_helpers::evaluate_test_result;
use on_log_event::LogEventCallbackSync;
use runtime::InternalBamlRuntime;
use std::sync::OnceLock;
Expand Down

0 comments on commit bd68b27

Please sign in to comment.