-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python] handle exceptions if they are raised by children in variables pane #2752
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this does improve Positron's UX, I'd like to propose a slight refactor for more flexibility in the future.
Currently, inspectors are totally decoupled from the variables pane and all other Positron (and even non-Positron) components. They solve the general problem of providing a consistent interface over a variety types from popular Python libraries. In theory, we could even open source inspectors as its own package in the future. Apologies, I should document this information somewhere!
This change does improve Positron's UX but it also slightly reduces the flexibility of inspectors i.e. the least surprising behavior of
inspector.get_child(key)
wherekey
is a property is to raise any potential errors in calculating the property, but the user will instead get the result"Unable to show value."
.Here's how we could solve this in a more general way.
The underlying problem is the
get_items
call here:positron/extensions/positron-python/python_files/positron/positron_ipykernel/variables.py
Line 708 in d6e75aa
It raises an unhandled exception, and the frontend's RPC request times out. So I'd suggest that we catch the error at that call instead of inside
get_child
.We need the value of
key
to pass to_summarize_variable
, but currently we can't get that whenget_items()
errors since it yields both the key and value at the same time. I suggest replacingget_items
with a newget_children
method, and updating_summarize_children
(and any other users/tests ofget_items
as necessary) to:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that makes sense to require the
inspectors
always return the "real" value, and let whatever summaries handle errors. (I'm not sure of a good place to write this down, maybe a Positron wiki subfolder? 😅)I'm happy to make these changes in a follow up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could start by writing it in the module docstring. It'd be great if you could add a note in your followup PR, otherwise I could also do a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can write that up in the follow up PR!