-
Notifications
You must be signed in to change notification settings - Fork 100
python: bypass plotnine auto-closing comms #7657
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
base: main
Are you sure you want to change the base?
Conversation
E2E Tests 🚀 |
def __call__(self, obj): | ||
"""Compute the format for an object.""" | ||
try: | ||
if obj.__module__ == "plotnine.ggplot": |
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're special casing plotnine here since there is autoplot opening/closing code that causes Positron's plots comm to be closed and the plot gets sent over a more vanilla "display_data"
call. When the get_intrinsic_size
RPC call was made, we were getting an error since there was no longer a Positron comm to look for.
We've been able to patch other packages in the posit/patches/
directory, but this requires an interception of _ipython_display_()
, not really a patch to the code itself. What do people think about this?
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 this is a good solution!
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.
Seems totally reasonable to me given we already are doing non-standard stuff with the comms.
wip for feedback, but i'll add a test before we merge this |
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.
Nice find! This branch seems to fix the weirdness in the linked issue.
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.
Works great for me! This feels about as surgical as it could get in this case!
def __call__(self, obj): | ||
"""Compute the format for an object.""" | ||
try: | ||
if obj.__module__ == "plotnine.ggplot": |
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.
Seems totally reasonable to me given we already are doing non-standard stuff with the comms.
if self.enabled: | ||
# lookup registered printer | ||
try: | ||
printer = self.lookup(obj) | ||
except KeyError: | ||
pass | ||
else: | ||
printer(obj) | ||
return True | ||
# Finally look for special method names | ||
method = dir2.get_real_method(obj, self.print_method) | ||
if method is not None: | ||
method() | ||
return True | ||
return True |
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.
Can't we call super
here instead of inlining that code?
extensions/positron-python/python_files/posit/positron/positron_ipkernel.py
Outdated
Show resolved
Hide resolved
@catch_format_error | ||
def __call__(self, obj): | ||
"""Compute the format for an object.""" | ||
try: |
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.
Should this also be wrapped in if self.enabled
? I'm not really sure how these work.
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.
Looking into this! I am also seeing different plots than anticipated for the retina setting in plotnine, which is maybe related 👀
…n_ipkernel.py Co-authored-by: Wasim Lorgat <[email protected]> Signed-off-by: Isabel Zimmerman <[email protected]>
Release Notes
New Features
Bug Fixes
plotnine
plots throw: "Error rendering plot to 'Auto' size: RPC timed out..." #6393 Fixes plotnine bug where every plot gives RPC timeout errorQA Notes
pip install plotnine
Should create 1 plot with no errors. You can also check that in the logs, the plot comms are being used, rather than
display_data