feat(frontend-python): support ctrl+c during compilation and key generation

This commit is contained in:
Umut
2023-06-26 11:20:11 +02:00
parent 87d460e9ec
commit 45e69798aa
3 changed files with 13 additions and 7 deletions

View File

@@ -11,6 +11,7 @@ from typing import Optional, Union
from concrete.compiler import ClientSupport, EvaluationKeys, KeySet, KeySetCache
from .specs import ClientSpecs
from .utils import interruptable_native_call
# pylint: enable=import-error,no-name-in-module
@@ -64,11 +65,13 @@ class Keys:
seed_msb = (seed >> 64) & ((2**64) - 1)
if self._keyset is None or force:
self._keyset = ClientSupport.key_set(
self.client_specs.client_parameters,
self._keyset_cache,
seed_msb,
seed_lsb,
self._keyset = interruptable_native_call(
lambda: ClientSupport.key_set(
self.client_specs.client_parameters,
self._keyset_cache,
seed_msb,
seed_lsb,
)
)
def save(self, location: Union[str, Path]):

View File

@@ -147,7 +147,7 @@ class Server:
output_dir = None
support = JITSupport.new()
compilation_result = support.compile(mlir, options)
compilation_result = interruptable_native_call(lambda: support.compile(mlir, options))
server_lambda = support.load_server_lambda(compilation_result)
else:
@@ -159,7 +159,7 @@ class Server:
support = LibrarySupport.new(
str(output_dir_path), generateCppHeader=False, generateStaticLib=False
)
compilation_result = support.compile(mlir, options)
compilation_result = interruptable_native_call(lambda: support.compile(mlir, options))
server_lambda = support.load_server_lambda(compilation_result)
client_parameters = support.load_client_parameters(compilation_result)