Couple of issues hit in ModelScan._iterate_models() while testing with zip files:
Unhandled exception while scanning a folder containing password-protected zip files
File "<snip>\Lib\site-packages\modelscan\modelscan.py", line 105, in _iterate_models
with zip.open(file_name, "r") as file_io:
^^^^^^^^^^^^^^^^^^^^^^^^
File "<snip>\Lib\zipfile\__init__.py", line 1662, in open
raise RuntimeError("File %r is encrypted, password "
RuntimeError: File 'benign.pickle' is encrypted, password required for extraction
This ends the scan and prevents generating a report instead of skipping the zip file. The issue is that the code catches BadZipFile but not RuntimeError. Potentially a one-line fix:
except (zipfile.BadZipFile, RuntimeError) as e:
Zip files with unsupported zip extensions are decompressed
In HF model https://huggingface.co/hugginglearners/fastai-style-transfer/tree/main, model.pkl is a zip file in spite of its pkl extension. The code seems to want to skip that file because "supported_zip_extensions": [".zip", ".npz"], but the if statement has an and instead of or so it ends up scanning the unsupported extension. Maybe the typo is not a bug but a feature and supported_zip_extensions should be removed? model.pkl is a zip file with an actual Pickle file in it, so worth scanning.
if (
not _is_zipfile(file, model.get_stream())
and Path(file).suffix
not in self._settings["supported_zip_extensions"]
):
continue
Happy to send a PR if helpful.
To Reproduce
Steps to reproduce the behavior:
Add a password-protected zip file in a folder of model files to scan
Describe the bug
Couple of issues hit in
ModelScan._iterate_models()
while testing with zip files:This ends the scan and prevents generating a report instead of skipping the zip file. The issue is that the code catches
BadZipFile
but notRuntimeError
. Potentially a one-line fix:In HF model https://huggingface.co/hugginglearners/fastai-style-transfer/tree/main, model.pkl is a zip file in spite of its pkl extension. The code seems to want to skip that file because
"supported_zip_extensions": [".zip", ".npz"]
, but theif
statement has anand
instead ofor
so it ends up scanning the unsupported extension. Maybe the typo is not a bug but a feature andsupported_zip_extensions
should be removed? model.pkl is a zip file with an actual Pickle file in it, so worth scanning.Happy to send a PR if helpful.
To Reproduce Steps to reproduce the behavior:
Expected behavior Scans complete.
Screenshots .
Environment (please complete the following information):
Additional context .