Skip to content

Commit

Permalink
[python] More auto-detect of function_name_for_messages (#3286)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored Nov 4, 2024
1 parent ebf0380 commit 2728aa2
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions apis/python/src/tiledbsoma/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,20 +551,26 @@ def tiledbsoma_upgrade_domain(
whether the operation would succeed if attempted, and a reason why it
would not.
"""
frame = inspect.currentframe()
function_name_for_messages = frame.f_code.co_name if frame else "tiledbsoma"

pyarrow_domain_table = self._upgrade_or_change_domain_helper(
newdomain, "tiledbsoma_upgrade_domain"
newdomain,
function_name_for_messages,
)

if check_only:
return cast(
StatusAndReason,
self._handle._handle.can_upgrade_domain(
pyarrow_domain_table, "tiledbsoma_upgrade_domain"
pyarrow_domain_table,
function_name_for_messages,
),
)
else:
self._handle._handle.upgrade_domain(
pyarrow_domain_table, "tiledbsoma_upgrade_domain"
pyarrow_domain_table,
function_name_for_messages,
)
return (True, "")

Expand All @@ -578,18 +584,25 @@ def change_domain(
`("", "")`, or as `None`. If ``check_only`` is ``True``, returns whether
the operation would succeed if attempted, and a reason why it would not.
"""
frame = inspect.currentframe()
function_name_for_messages = frame.f_code.co_name if frame else "tiledbsoma"

pyarrow_domain_table = self._upgrade_or_change_domain_helper(
newdomain, "change_domain"
newdomain,
function_name_for_messages,
)
if check_only:
return cast(
StatusAndReason,
self._handle._handle.can_change_domain(
pyarrow_domain_table, "change_domain"
pyarrow_domain_table,
function_name_for_messages,
),
)
else:
self._handle._handle.change_domain(pyarrow_domain_table, "change_domain")
self._handle._handle.change_domain(
pyarrow_domain_table, function_name_for_messages
)
return (True, "")

def __len__(self) -> int:
Expand Down Expand Up @@ -685,7 +698,7 @@ def read(

self._set_coords(sr, coords)

# # TODO: batch_size
# TODO: batch_size
return TableReadIter(sr)

def write(
Expand Down

0 comments on commit 2728aa2

Please sign in to comment.