From cedebba0109d39bf93e8d1d403c9bc8d0ed6a2b9 Mon Sep 17 00:00:00 2001 From: Roman Bredehoft Date: Thu, 4 Apr 2024 10:33:43 +0200 Subject: [PATCH] chore: add explicit parameters in zipfile --- src/concrete/ml/pandas/_utils.py | 2 +- src/concrete/ml/pandas/dataframe.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/concrete/ml/pandas/_utils.py b/src/concrete/ml/pandas/_utils.py index fcf425ca6a..2c7a6b7f66 100644 --- a/src/concrete/ml/pandas/_utils.py +++ b/src/concrete/ml/pandas/_utils.py @@ -134,7 +134,7 @@ def deserialize_elementwise(array: numpy.ndarray) -> numpy.ndarray: def serialize_evaluation_keys(evaluation_keys: fhe.EvaluationKeys) -> bytes: - """Serialize the evaluation keys into a string of hexadecimal numbers. + """Serialize the evaluation keys into bytes. Args: evaluation_keys (fhe.EvaluationKeys): The evaluation keys to serialize. diff --git a/src/concrete/ml/pandas/dataframe.py b/src/concrete/ml/pandas/dataframe.py index fef9aaff92..d4716702dc 100644 --- a/src/concrete/ml/pandas/dataframe.py +++ b/src/concrete/ml/pandas/dataframe.py @@ -1,8 +1,8 @@ """Define the encrypted data-frame framework.""" import json -import zipfile from pathlib import Path from typing import Dict, Hashable, List, Optional, Sequence, Tuple, Union +from zipfile import ZIP_STORED, ZipFile import numpy import pandas @@ -327,7 +327,7 @@ def save(self, path: Union[Path, str]): encrypted_df_json_bytes = json.dumps(encrypted_df_dict).encode(encoding="utf-8") - with zipfile.ZipFile(path, "w") as zip_file: + with ZipFile(path, "w", compression=ZIP_STORED, allowZip64=True) as zip_file: zip_file.writestr("encrypted_dataframe.json", encrypted_df_json_bytes) zip_file.writestr("evaluation_keys", evaluation_keys) @@ -346,7 +346,7 @@ def load(cls, path: Union[Path, str]): if path.suffix != ".zip": path = path.with_suffix(".zip") - with zipfile.ZipFile(path, "r") as zip_file: + with ZipFile(path, "r", compression=ZIP_STORED, allowZip64=True) as zip_file: with zip_file.open("encrypted_dataframe.json") as encrypted_df_json_file: encrypted_df_json_bytes = encrypted_df_json_file.read() encrypted_df_dict = json.loads(encrypted_df_json_bytes)