Skip to content

Commit

Permalink
Temporary fix to avoid #1469
Browse files Browse the repository at this point in the history
  • Loading branch information
sergii-mamedov committed Feb 1, 2024
1 parent 6a08d61 commit d707d88
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions metaspace/engine/sm/engine/annotation_lithops/load_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,28 @@ def _upload_imzml_browser_files(
browser_storage: Storage,
uuid: str,
) -> None:
"""Save imzml browser files on the object storage"""
"""Save imzML browser files on the object storage"""

def upload_file(data: np.array, key: str):
save_cobj(browser_storage, data, key=key)

# TODO: need reimplement save_cobj for file > 5 GB
# https://github.com/metaspace2020/metaspace/issues/1469
if mzs.itemsize > 4:
mzs = mzs.astype('f')
if ints.itemsize > 4:
ints = ints.astype('f')

if any([o.nbytes >= 5 * 1024 ** 3 for o in (mzs, ints, sp_idxs)]):
print('At least one object has a size of more than 5 GB')
return

keys = [f'{uuid}/{k}' for k in ['mzs.npy', 'ints.npy', 'sp_idxs.npy']]
with ThreadPoolExecutor(3) as executor:
cobjs = list(executor.map(upload_file, [mzs, ints, sp_idxs], keys))

chunk_records_number = 1024
mz_index = mzs[::chunk_records_number].astype('f')
mz_index = mzs[::chunk_records_number]
cobjs.append(save_cobj(browser_storage, mz_index, key=f'{uuid}/mz_index.npy'))

key = f'{uuid}/portable_spectrum_reader.pickle'
Expand Down

0 comments on commit d707d88

Please sign in to comment.