romanbredehoft-zama commited on
Commit
04d1e2c
1 Parent(s): bf71bfa

Clean and refactor user names

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. backend.py +9 -13
app.py CHANGED
@@ -186,7 +186,7 @@ with demo:
186
  outputs=[encrypted_output_representation],
187
  )
188
 
189
- # Button to decrypt the output as the user
190
  decrypt_button.click(
191
  decrypt_output,
192
  inputs=[client_id],
 
186
  outputs=[encrypted_output_representation],
187
  )
188
 
189
+ # Button to decrypt the output
190
  decrypt_button.click(
191
  decrypt_output,
192
  inputs=[client_id],
backend.py CHANGED
@@ -66,22 +66,18 @@ def clean_temporary_files(n_keys=20):
66
  key_dirs = sorted(FHE_KEYS.iterdir(), key=os.path.getmtime)
67
 
68
  # If more than n_keys keys are found, remove the oldest
69
- user_ids = []
70
  if len(key_dirs) > n_keys:
71
  n_keys_to_delete = len(key_dirs) - n_keys
72
  for key_dir in key_dirs[:n_keys_to_delete]:
73
- user_ids.append(key_dir.name)
74
  shutil.rmtree(key_dir)
75
-
76
- # Get all the encrypted files in the temporary folders
77
- client_files = CLIENT_FILES.iterdir()
78
- server_files = SERVER_FILES.iterdir()
79
-
80
  # Delete all files related to the IDs whose keys were deleted
81
- for user_dir in chain(client_files, server_files):
82
- for user_id in user_ids:
83
- if user_id in user_dir.name:
84
- shutil.rmtree(user_dir)
85
 
86
 
87
  def _get_client(client_id):
@@ -285,7 +281,7 @@ def pre_process_encrypt_send_user(client_id, *inputs):
285
 
286
 
287
  def pre_process_encrypt_send_bank(client_id, *inputs):
288
- """Pre-process, encrypt and send the user inputs for a specific client to the server.
289
 
290
  Args:
291
  client_id (str): The current client ID to consider.
@@ -301,7 +297,7 @@ def pre_process_encrypt_send_bank(client_id, *inputs):
301
 
302
 
303
  def pre_process_encrypt_send_third_party(client_id, *inputs):
304
- """Pre-process, encrypt and send the user inputs for a specific client to the server.
305
 
306
  Args:
307
  client_id (str): The current client ID to consider.
 
66
  key_dirs = sorted(FHE_KEYS.iterdir(), key=os.path.getmtime)
67
 
68
  # If more than n_keys keys are found, remove the oldest
69
+ client_ids = []
70
  if len(key_dirs) > n_keys:
71
  n_keys_to_delete = len(key_dirs) - n_keys
72
  for key_dir in key_dirs[:n_keys_to_delete]:
73
+ client_ids.append(key_dir.name)
74
  shutil.rmtree(key_dir)
75
+
 
 
 
 
76
  # Delete all files related to the IDs whose keys were deleted
77
+ for directory in chain(CLIENT_FILES.iterdir(), SERVER_FILES.iterdir()):
78
+ for client_id in client_ids:
79
+ if client_id in directory.name:
80
+ shutil.rmtree(directory)
81
 
82
 
83
  def _get_client(client_id):
 
281
 
282
 
283
  def pre_process_encrypt_send_bank(client_id, *inputs):
284
+ """Pre-process, encrypt and send the bank inputs for a specific client to the server.
285
 
286
  Args:
287
  client_id (str): The current client ID to consider.
 
297
 
298
 
299
  def pre_process_encrypt_send_third_party(client_id, *inputs):
300
+ """Pre-process, encrypt and send the third party inputs for a specific client to the server.
301
 
302
  Args:
303
  client_id (str): The current client ID to consider.