mirror of
https://github.com/zama-ai/concrete.git
synced 2026-04-17 03:00:54 -04:00
enhance(compiler): Python bindings: Forward llvm::Expected error messages in exceptions
The code in `lib/CAPI/Support/CompilerEngine.cpp` invokes several functions returning an `llvm::Expected<T>`. When those fail, the error message retrieved from the error object the `llvm::Expected<T>` instance is written to the standard error stream via `mlir::zamalang::log_error()` and an exception with a more generic error message is thrown. This causes errors to show up on the standard error stream in tests generating errors on purpose and checking them, e.g.: ``` tests/python/test_compiler_engine.py::test_compile_invalid[not @main] Compilation failed: cannot find the function for generate client parameters PASSED ``` This patch forwards the error message from an `llvm::Expected<T>` instance in a runtime exception rather than writing it to the standard error stream. Since exceptions are properly caught by the tests, no errors show up during testing.
This commit is contained in:
@@ -102,5 +102,5 @@ def test_compile_and_run_tlu(mlir_input, args, expected_result, tab_size):
|
||||
)
|
||||
def test_compile_invalid(mlir_input):
|
||||
engine = CompilerEngine()
|
||||
with pytest.raises(RuntimeError, match=r"failed compiling"):
|
||||
with pytest.raises(RuntimeError, match=r"Compilation failed:"):
|
||||
engine.compile_fhe(mlir_input)
|
||||
|
||||
@@ -69,5 +69,5 @@ def test_valid_mlir_inputs(mlir_input):
|
||||
@pytest.mark.parametrize("mlir_input", INVALID_INPUTS)
|
||||
def test_invalid_mlir_inputs(mlir_input):
|
||||
# We need to check that invalud inputs are raising an error
|
||||
with pytest.raises(RuntimeError, match=r"mlir parsing failed"):
|
||||
with pytest.raises(RuntimeError, match=r"MLIR parsing failed:"):
|
||||
compiler.round_trip(mlir_input)
|
||||
|
||||
Reference in New Issue
Block a user