This is a bit grody, but I would re-write BlockMatrix.to_numpy
yourself:
import os
import numpy as np
from hail.linalg import BlockMatrix
from hail.utils import new_local_temp_file, local_path_uri
def to_numpy(bm, _force_blocking=False):
if bm.n_rows * bm.n_cols > 1 << 31 or _force_blocking:
path = new_temp_file()
bm.export_blocks(path, binary=True)
return BlockMatrix.rectangles_to_numpy(path, binary=True)
path = new_local_temp_file()
try:
uri = local_path_uri(path)
bm.tofile(uri)
return np.fromfile(path).reshape((bm.n_rows, bm.n_cols))
finally:
try:
os.remove(path)
except FileNotFoundError:
pass