mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-19 10:51:34 +08:00
Assert that at least one file in npz zipfile ends with .npy
from https://pydoc.dev/numpy/latest/numpy.lib.npyio.NpzFile.html: > NpzFile is used to load files in the NumPy .npz data archive format. It assumes that files in the archive have a .npy extension, other files are ignored.
This commit is contained in:
@@ -4135,9 +4135,9 @@ class Npz(CompressedArchive):
|
||||
|
||||
def sniff(self, filename: str) -> bool:
|
||||
try:
|
||||
npz = np.load(filename)
|
||||
if isinstance(npz, np.lib.npyio.NpzFile):
|
||||
return True
|
||||
with np.load(filename) as npz:
|
||||
if isinstance(npz, np.lib.npyio.NpzFile) and any(f.filename.endswith(".npy") for f in npz.zip.filelist):
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user