chore: fix auto-merged PR

This commit is contained in:
Arthur Meyre
2021-12-23 15:53:23 +01:00
parent 25a8d51d2d
commit 2c8dbce3e0
5 changed files with 57 additions and 18 deletions

View File

@@ -292,6 +292,7 @@ jobs:
echo "Conformance failed, check logs"
exit 1
fi
# Taring the docs allows for much faster upload speed (from ~3min worst case to ~2s best case)
- name: Tar docs artifacts
if: ${{ steps.conformance.outcome == 'success' && !cancelled() }}
run: |

View File

@@ -245,7 +245,8 @@ release_docker:
upgrade_py_deps:
./script/make_utils/upgrade_deps.sh
# Keeping this target as it proved useful before the package was stabilized
# Keeping this target as it proved useful before we had a proper package, allowed to run code that
# pytest-codeblocks was failing to execute if not installed as a pip package.
# This is done by hand as pytest-codeblocks was failing with our native extensions.
# See refused PR on the project here: https://github.com/nschloe/pytest-codeblocks/pull/58
# Test code blocks using a custom python script in the documentation

View File

@@ -643,13 +643,14 @@ def _compile_op_graph_to_fhe_circuit_internal(
# Add MLIR representation as an artifact
compilation_artifacts.add_final_operation_graph_mlir(mlir_result)
if (
_COMPILE_FHE_INSECURE_KEY_CACHE_DIR is not None
and not compilation_configuration.use_insecure_key_cache
if _COMPILE_FHE_INSECURE_KEY_CACHE_DIR is not None and not (
compilation_configuration.use_insecure_key_cache
and compilation_configuration.enable_unsafe_features
):
raise RuntimeError(
f"Unable to use insecure key cache {_COMPILE_FHE_INSECURE_KEY_CACHE_DIR} "
f"as use_insecure_key_cache is not set to True in compilation_configuration"
"as use_insecure_key_cache or enable_unsafe_features are not set to True in"
"compilation_configuration"
)
# Compile the MLIR representation

View File

@@ -77,7 +77,7 @@ def get_keyring_dir_from_session_or_default(
@pytest.fixture
def default_keyring_path():
"""fixture to get test keyring dir"""
"""Fixture to get test keyring dir."""
return DEFAULT_KEYRING_PATH
@@ -85,12 +85,15 @@ def default_keyring_path():
original_compilation_config_init = CompilationConfiguration.__init__
def monkeypatched_compilation_configuration_init_for_codeblocks(self, *args, **kwargs):
def monkeypatched_compilation_configuration_init_for_codeblocks(
self: CompilationConfiguration, *args, **kwargs
):
"""Monkeypatched compilation configuration init for codeblocks tests."""
original_compilation_config_init(self, *args, **kwargs)
self.dump_artifacts_on_unexpected_failures = False
self.enable_unsafe_features = True # This is for our tests only, never use that in prod
self.treat_warnings_as_errors = True
self.use_insecure_key_cache = True
self.use_insecure_key_cache = True # This is for our tests only, never use that in prod
def pytest_sessionstart(session: pytest.Session):
@@ -349,6 +352,7 @@ def default_compilation_configuration():
"""Return the default test compilation configuration"""
return CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
enable_unsafe_features=True, # This is for our tests only, never use that in prod
treat_warnings_as_errors=True,
use_insecure_key_cache=True, # This is for our tests only, never use that in prod
)
@@ -399,7 +403,8 @@ def check_is_good_execution_impl(
# Enabled only when we have a circuit that's using the maximum possible bit width
allow_relaxed_tests_passing = max_bit_width == ACCEPTABLE_MAXIMAL_BITWIDTH_FROM_CONCRETE_LIB
# Increased with compiler accuracy which dropped
# FIXME: https://github.com/zama-ai/concretefhe-internal/issues/1255
# Increased with compiler accuracy which dropped, make sure to remove once accuracy improves
nb_tries = 10
# Prepare the bool array to record if cells were properly computed

View File

@@ -1979,16 +1979,21 @@ def test_compile_with_random_inputset(default_compilation_configuration):
)
def test_fail_compile_with_random_inputset(default_compilation_configuration):
def test_fail_compile_with_random_inputset():
"""Test function for failed compile with random input set"""
compilation_configuration = CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
treat_warnings_as_errors=True,
)
with pytest.raises(ValueError):
try:
compile_numpy_function_into_op_graph_and_measure_bounds(
lambda x: x + 1,
{"x": EncryptedScalar(UnsignedInteger(3))},
inputset="unsupported",
compilation_configuration=default_compilation_configuration,
compilation_configuration=compilation_configuration,
)
except Exception as error:
expected = (
@@ -2004,7 +2009,7 @@ def test_fail_compile_with_random_inputset(default_compilation_configuration):
lambda x: x + 1,
{"x": EncryptedScalar(UnsignedInteger(3))},
inputset="random",
compilation_configuration=default_compilation_configuration,
compilation_configuration=compilation_configuration,
)
except Exception as error:
expected = (
@@ -2151,8 +2156,36 @@ def test_compile_and_run_correctness_with_negative_results(
assert check_equality_modulo(compiler_engine.run(*args), function(*args), modulus)
def test_compile_improper_use_of_insecure_key_cache(default_keyring_path):
"""Test the case where the key cache is used with wrong compilation configuration"""
@pytest.mark.parametrize(
"compilation_configuration",
[
CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
enable_unsafe_features=False,
use_insecure_key_cache=False,
),
CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
enable_unsafe_features=True,
use_insecure_key_cache=False,
),
CompilationConfiguration(
dump_artifacts_on_unexpected_failures=False,
enable_unsafe_features=False,
use_insecure_key_cache=True,
),
],
)
def test_compile_improper_use_of_insecure_key_cache(
default_keyring_path, compilation_configuration
):
"""Test the case where the key cache is used with wrong compilation configuration.
DO NOT USE INSECURE KEY CACHE FOR NORMAL PRODUCTION WORK
This is a test to check we properly fail for users trying to incorrectly use the insecure key
cache (to reuse keys across compilations). This allows to speed up tests A LOT but should not be
used in normal prod environment /!\\ DANGER /!\\."""
def f(x):
return x + 42
@@ -2162,13 +2195,11 @@ def test_compile_improper_use_of_insecure_key_cache(default_keyring_path):
default_keyring_path
)
compilation_configuration = CompilationConfiguration()
compilation_configuration.use_insecure_key_cache = False
with pytest.raises(
RuntimeError,
match="Unable to use insecure key cache .* "
"as use_insecure_key_cache is not set to True in compilation_configuration",
"as use_insecure_key_cache or enable_unsafe_features are not set to True in"
"compilation_configuration",
):
_ = compile_numpy_function(
f,