Skip to content

handle conveniences#1390

Open
casperdcl wants to merge 3 commits intomasterfrom
handle-conveniences
Open

handle conveniences#1390
casperdcl wants to merge 3 commits intomasterfrom
handle-conveniences

Conversation

@casperdcl
Copy link
Copy Markdown
Member

@casperdcl casperdcl commented Mar 31, 2026

  • HANDLE convenience singleton (can't do Handle.new since classproperties are deprecated)
  • functools.wraps backend functions in Handle.c*
  • for discussion: what is the purpose of (unused) check_stack/inspect.stack()?

Follow-up to #1388

@casperdcl casperdcl added this to the v3.10.0 milestone Mar 31, 2026
@casperdcl casperdcl added enhancement question design Discussions on design of the software labels Mar 31, 2026
@casperdcl casperdcl self-assigned this Mar 31, 2026
@casperdcl casperdcl force-pushed the handle-conveniences branch from 3f6f564 to 980e9b6 Compare March 31, 2026 12:47
Copy link
Copy Markdown
Member

@KrisThielemans KrisThielemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but now might be a good time to add a little bit of documentation on the Handle class (and indeed the new HANDLE. It is an implementation detail (should we call it _Handle in Python tradition?), but developers do need to know how this works :-)

Comment thread src/common/Utilities.py
def __init__(self, handle, check_stack: int | None = None):
if (check_stack is None or check_stack >= 0) and pyiutil.executionStatus(handle) != 0:
check_stack = inspect.stack()[1 if check_stack is None else check_stack]
check_stack = inspect.stack()[1 if check_stack is None else check_stack] # TODO: delete or print this?
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete unused lines 40-43 please (not much help anyway as the error may be higher up the stack than level 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re the purpose of inspect.stack: what I wanted was to get closer to the line that throws monkey wrench.

For example: running PET demos I get

`Error opening file acf.hs\n' exception caught at line 427 of /home/sirfuser/devel/buildVM/sources/SIRF/src/xSTIR/cSTIR/cstir.cpp

but actual failure happens in STIR function ProjData::read_from_file called either at line 694 or line 852 of SIRF's stir_data_containers.h depending on the storage scheme (file or memory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

design Discussions on design of the software enhancement question

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants