Skip to content
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

Improve behavior of reticulate Quarto documents (R & Python together) #3865

Open
coatless opened this issue Jul 4, 2024 · 4 comments
Open
Labels
area: quarto Issues related to Quarto category. area: reticulate Issues related to the reticulate extension bug Something isn't working support

Comments

@coatless
Copy link

coatless commented Jul 4, 2024

Positron Version:

Positron Version: 2024.06.1 (Universal) build 54
Code - OSS Version: 1.90.0
Commit: 5115c73
Date: 2024-07-03T03:51:33.756Z
Electron: 29.4.0
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Darwin arm64 23.5.0

Steps to reproduce the issue:

  1. Create a new Quarto Document in a Positron session with both a Python environment & R environment activate
  2. Inside the Quarto document, place:
---
format: html
---

```{r}
plot(1:4, ylab = "some numbers")
```
```{python}
import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
```
  1. Run each chunk individually.
  2. The Python chunk creates a pop-up window under Ark.

What did you expect to happen?

I expected:

  1. the plot window to catch
  2. reticulate plugin to default to the active python environment without needing to setup a default python environment

Unexpected plot pop-up:

Screenshot of the Positron IDE with 2 different code blocks run one R and one Python causing a popup

Expected plot history:

Screenshot 2024-07-03 at 9 14 14 PM

Were there any error messages in the output or Developer Tools console?

N/A

@coatless coatless added the bug Something isn't working label Jul 4, 2024
@juliasilge
Copy link
Contributor

Wow, interesting 👀

Can you say more about how you triggered that call to reticulate::repl_python()? I can't figure out how to get that to happen.

If I have a polyglot .qmd and I use, say, Cmd+Shift+Enter to send lines of code to the console for execution, I see the code execute in the correct console (R in the R console, Python in the Python console) and both plots in the Plots pane:

polyglot

@juliasilge juliasilge added the area: quarto Issues related to Quarto category. label Jul 5, 2024
@coatless
Copy link
Author

coatless commented Jul 5, 2024

A few videos:

When saved in a project:

quarto-graph-bug-and-repl.mp4

Empty/untitled document (this sometimes won't render when saying reticulate environment has "no")

dry-start-positron-quarto-graph-bug.mp4

I suppose another question is: what environment is reticulate using if its not detecting the default being available?

@juliasilge
Copy link
Contributor

Ah, you were clicking the "Run Cell" button! I believe this will take a PR to the Quarto extension sort of along these lines to fix:
quarto-dev/quarto#436
We'll need to navigate whether to go through reticulate at all for interactive code execution. (Rendering the document will of course have to go through reticulate.) Related to the second bullet in #1646 (comment).

As a short term workaround, you can use use Cmd+Shift+Enter to send lines of code to the console for execution, although for Python then you are running into the first bullet at #1646 (comment).

Please do add anything to that other issue that you think is relevant. We'll keep this one open as a specific case to check when we make changes to the Quarto extension.

@juliasilge juliasilge added this to the Release Candidate milestone Jul 5, 2024
@coatless
Copy link
Author

coatless commented Jul 5, 2024

@juliasilge role-playing the student and newly minted DS analyst with a button > keyboard shortcut mindset.

@juliasilge juliasilge added the area: reticulate Issues related to the reticulate extension label Oct 24, 2024
@juliasilge juliasilge changed the title Polygot Quarto document doesn't store python plots in plot pane & prompts for a new reticulate default env instead of using existing Improve behavior of reticulate Quarto documents (R & Python together) Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: quarto Issues related to Quarto category. area: reticulate Issues related to the reticulate extension bug Something isn't working support
Projects
None yet
Development

No branches or pull requests

2 participants