-
Notifications
You must be signed in to change notification settings - Fork 331
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
Add Positron Variables Pane Methods #1692
Conversation
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.
LGTM!
R/ark-variables-methods.R
Outdated
get_keys_and_children <- .globals$ark_variable_get_keys_and_children | ||
if (is.null(get_keys_and_children)) { | ||
get_keys_and_children <- .globals$ark_variable_get_keys_and_children <- py_eval( | ||
"lambda i: zip(*((str(key), i.get_child(key)) for key in i.get_children()))", |
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 think we should limit the the length of i.get_children()
, either by providing an argument from ark to ark_positron_variable_get_children
or hardcoded here.
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.
What do you think the limit should be? Would it be dynamic based on something? Maybe a range of which children are visible in the pane?
If we do something here, we should also include a companion PR to make sure that the Python inspectors.get_children()
is in sync. https://github.com/posit-dev/positron/blob/70e96ec21df6dbb9027b1cb96749c4a461f87616/extensions/positron-python/python_files/positron/positron_ipykernel/inspectors.py#L146
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 think the UI already has a limit of what is actually displayed. This is just a hard limit to avoid building the large object that is never shown anyway. I'd add something like 100. In the Python inspectors, since this is an iterable, I think it might respect whatever the UI really needs to read?
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.
Do we have a standard way to indicate that not all elements are being shown? E.g., ...truncated
or similar?
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.
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.
It looks like this is handled in the frontend: https://github.com/posit-dev/positron/blob/83d516172b17d2ae02da8b01411de646cb1117c9/src/vs/workbench/contrib/positronVariables/browser/components/variableOverflow.tsx#L87-L91
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.
if(!is_positron()) | ||
return (NULL) | ||
|
||
x <- Sys.getenv("_") |
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.
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.
@lionel- We'll open a PR to Ark, exporting a function like .ps.positron_ipykernel_path
, to return the path to the positron_ipykernel
python module that ships with Positron.
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.
yes that would be reasonable. .ps
stands for positron so .ps_ipykernel_path
?
This function could query the positron-r extension for that path via UIComm RPC.
This PR pairs with: rstudio/reticulate#1692 The reticulate PR addresses: #3502 (comment) It allows Reticulate to reliably obtain the path to the Positron `inspectors.py` which implements the variables pane methods. By calling: ``` .ps.ui.executeCommand("positron.reticulate.getIPykernelPath") ```
This PR adds support for reticulate objects in the Positron Variables Pane.
With an example session:
We now see:
Screen.Recording.2024-11-11.at.3.12.40.PM.mov
Previously, all python objects presented as:
This uses the ark interface added in posit-dev/ark#560 and posit-dev/ark#561