Skip to content

Commit

Permalink
Update pyarrow import for build without Arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseMckinzie committed Aug 11, 2023
1 parent a5bba48 commit 9698ab6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/nyx/python/nyxus/nyxus.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import os
import numpy as np
import pandas as pd
import pyarrow as pa
from typing import Optional, List

#pa.import_pyarrow()
if arrow_is_enabled_imp():
import pyarrow as pa

class Nyxus:
"""Nyxus image feature extraction library
Expand Down Expand Up @@ -773,16 +773,19 @@ def get_arrow_memory_mapping(self):
"""

arrow_file_path = self.get_arrow_ipc_file()

if (arrow_file_path == ""):
self.create_arrow_file()
if arrow_is_enabled_imp():
arrow_file_path = self.get_arrow_ipc_file()

with pa.memory_map(arrow_file_path, 'rb') as source:
array = pa.ipc.open_file(source).read_all()

return array

if (arrow_file_path == ""):
self.create_arrow_file()
arrow_file_path = self.get_arrow_ipc_file()

with pa.memory_map(arrow_file_path, 'rb') as source:
array = pa.ipc.open_file(source).read_all()

return array
else:
raise RuntimeError("Apache arrow is not enabled. Please rebuild Nyxus with Arrow support to enable this functionality.")


def get_arrow_table(self):
Expand Down

0 comments on commit 9698ab6

Please sign in to comment.