Skip to content

Commit c87cafd

Browse files
Update docs to include instructions for multiple interpreter sessions (#87)
* Update docs to include instructions for multiple interpreter sessions * Describe session context in relation to code execution * Add another screenshot placeholder * Add screenshots and update instructions to match * Use posit style guide term for popup * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Update interpreters.qmd Co-authored-by: Julia Silge <julia.silge@gmail.com> * Rename file to be more descriptive * Limit the number of images to reduce screenshot burden * Minimize screenshots and utilize icons --------- Co-authored-by: Julia Silge <julia.silge@gmail.com>
1 parent 3fc30c2 commit c87cafd

File tree

7 files changed

+176
-94
lines changed

7 files changed

+176
-94
lines changed

_quarto.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ website:
6161
- add-to-path.qmd
6262
- section: "Interpreters"
6363
contents:
64-
- interpreters.qmd
64+
- managing-interpreters.qmd
65+
- interpreter-startup.qmd
6566
- r-installations.qmd
6667
- keyboard-shortcuts.qmd
6768
- data-explorer.qmd
386 KB
Loading
2.49 KB
Loading

interpreter-startup.qmd

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "Interpreter Startup"
3+
---
4+
5+
## First run
6+
7+
When Positron starts for the first time in a new workspace, it will start a Python and/or R interpreter session based on your workspace characteristics and whether there is evidence of RStudio being used recently.
8+
9+
Typically when starting Python or R without other clues about which version to start, Positron will start the most recent version of the interpreter (e.g. if you have R 4.2 and R 4.3 installed, it'll start R 4.3).
10+
11+
If you are an R user, see the [R discovery](r-installations.qmd) guide for more information on available installations.
12+
13+
### RStudio detection
14+
15+
Positron tries to start R for R users and Python for Python users by checking to see if RStudio is installed and has been recently used. The latter check is done by looking in `~/.local/share/rstudio` for files written less than a month ago. If you do not want Positron to consider you an RStudio user, remove this folder or rename it.
16+
17+
## Subsequent runs
18+
19+
When Positron starts in a workspace that has been used before, it will start the same language interpreter that was running the last time you used the workspace.
20+
21+
In the case of R, there is some additional subtlety:
22+
When Positron records which R version was most recently used in a workspace, it also notes whether that R version is the system's default R version.
23+
In subsequent runs, Positron will launch the system's default R version, even if that is a different version number from the last-used R version.
24+
We believe this behaviour is the least surprising for most users.
25+
If you want to use a specific, non-default R version in a workspace, select it explicitly once and it will be launched in future runs.
26+
27+
If Positron starts an interpreter you don't need, just delete the session, and it will stop starting automatically in that workspace.
28+
29+
## Implicit startup
30+
31+
In addition to starting up an interpreter session when the workspace is first opened, Positron will also automatically start an interpreter session when it looks like one is needed. For example, a Python session will start:
32+
33+
- When you open a `.py` file
34+
- When you execute Python code
35+
36+
## Configuring interpreter startup
37+
38+
If the interpreter that Positron uses by default isn't a good fit, you can customize and configure how interpreter sessions are started using the `interpreters.startupBehavior` settings.
39+
40+
### Per-language interpreter startup behavior
41+
42+
In the Settings UI, search for `@lang:r interpreters.startupBehavior` or `@lang:python interpreters.startupBehavior`, and choose the desired configuration. The selected startup behavior will be applied to the corresponding language.
43+
44+
For example, if you only ever use Python and never want R to start, set `@lang:r interpreters.startupBehavior` to `"disabled"` to hide R interpreters from the Positron UI altogether. You can specify this at either the user or workspace level, and your configuration will appear in your `settings.json` as:
45+
46+
```json
47+
{
48+
"[r]": {
49+
"interpreters.startupBehavior": "disabled"
50+
}
51+
}
52+
```
53+
Alternatively, if you are mainly an R user, but occasionally use Python, you can set `@lang:python interpreters.startupBehavior` to `"manual"` to prevent Python interpreter sessions from starting automatically. This still allows you to start a Python interpreter session manually:
54+
55+
```json
56+
{
57+
"[python]": {
58+
"interpreters.startupBehavior": "manual"
59+
}
60+
}
61+
```
62+
63+
### General interpreter startup behavior
64+
65+
In the Settings UI, search for the setting `interpreters.startupBehavior` without a language key, and choose the desired configuration. The selected startup behavior will be applied to _all_ interpreters.
66+
67+
Note that if any per-language startup behavior is set, it takes precedence over the general interpreter startup behavior setting.

interpreters.qmd

Lines changed: 0 additions & 86 deletions
This file was deleted.

managing-interpreters.qmd

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: "Managing Interpreters"
3+
---
4+
5+
Positron is designed to support multiple R and Python interpreter sessions. This enables workflows that span multiple environments, and allows you to switch between them easily within a single workspace. Interpreter sessions are managed primarily through the Interpreter picker and Console pane.
6+
7+
At any given time, one interpreter session is designated as the **active interpreter session**. This is the language environment currently in use for interactive and language-specific features within the IDE.
8+
9+
10+
## Active interpreter session
11+
12+
The active interpreter session is the language environment currently in use. It provides the execution context for various panes within the IDE such as the Console, Variables, Plots, and Editor panes. Language-specific features such as code execution, completion, and diagnostics are all scoped to the active interpreter session.
13+
14+
The active interpreter session can always be identified in the Interpreter picker located in the top right. The active interpreter is highlighted in the Console pane list.
15+
16+
![Active interpreter session](images/active-interpreter-session.png)
17+
18+
### Documents in the Editor pane
19+
20+
The active interpreter session provides the execution context for documents in the Editor pane. However, a document is not permanently tied to a specific interpreter session.
21+
22+
When you execute code from a document, Positron determines which interpreter session to use based on the following priority:
23+
24+
1. **Active session compatibility**: If the active interpreter session matches the document language, Positron uses that session.
25+
2. **Fallback selection**: If the active interpreter session does not match the document language, Positron uses the most recently created interpreter session for the language.
26+
3. **New session creation**: If no interpreter session exists for the document language, Positron starts a new interpreter session. See the [Interpreter startup](interpreter-startup.qmd) guide for information on how Positron handles interpreter startup for you.
27+
28+
### Language-specific features
29+
30+
The active interpreter session drives several language-specific features:
31+
32+
**Code completion**: The active interpreter session provides the context for code completions in the Editor pane. To get accurate completions, ensure the appropriate interpreter session for the language of your document is active.
33+
34+
**Diagnostics**: Error checking and code analysis use the active session environment. Diagnostics include syntax errors, import issues, and variable references. The active interpreter session determines which packages and variables are available for diagnostic checks.
35+
36+
### Managing multiple interpreter sessions of the same language
37+
38+
When working with multiple interpreter sessions for the same language, keep these practices in mind:
39+
40+
**Session identification**: Use descriptive names to distinguish between interpreter sessions. [Rename interpreter sessions](#rename-an-interpreter-session) to reflect their purpose.
41+
42+
**Active session awareness**: Check which interpreter session is active before executing code. The session name is always visible in the Interpreter picker.
43+
44+
## View running interpreter sessions
45+
46+
You can view a list of running interpreter sessions from the Console pane. The active interpreter is highlighted. Alternatively, you can select the Interpreter picker to view a list of the running interpreter sessions.
47+
48+
## Change the active interpreter session
49+
50+
Select an interpreter session from the list in the Console pane to make it the active interpreter. Alternatively, you can select the Interpreter picker and then select a running interpreter session from the list.
51+
52+
## Create a new interpreter session
53+
54+
Select the Interpreter picker and choose "New Interpreter Session..." to see a list of all the registered interpreters. Select an interpreter from the list to start an instance of it.
55+
56+
Alternatively, you can select the {{<fa chevron-down>}} icon next to the {{<fa plus>}} icon in the Console pane. The dropdown lists the most recently used interpreters. The **Start Another...** option will display a list of all the registered interpreters. Select an interpreter from either list to start an instance.
57+
58+
::: {.callout-tip}
59+
You can select the {{<fa plus>}} icon to create a new interpreter session for the currently active interpreter.
60+
:::
61+
62+
## Delete an interpreter session
63+
64+
When you delete an interpreter session, the state of the session will be lost, including any variables you've defined.
65+
66+
Select the {{<fa trash-can>}} icon when *hovering* over the Console pane list to shut down and dispose of the session.
67+
68+
## Restart an interpreter session
69+
70+
When you restart an interpreter session, the session and variables state is cleared.
71+
72+
Select the {{<fa rotate-right>}} icon from the Console action bar to restart a session.
73+
74+
## Rename an interpreter session
75+
76+
Renaming interpreter sessions is a useful tool to distinguish sessions for the same interpreter version.
77+
78+
Right-click an interpreter session form the Console pane list and select the **Rename...** option.
79+
80+
## View interpreter session metadata
81+
82+
Select the info icon from the Console action bar to view information about the active interpreter session.
83+
84+
The pop-up window displays the following information about the active interpreter session:
85+
86+
* **Name**: The display name of the interpreter session, which you can customize by renaming a session.
87+
* **Id**: The unique identifier assigned to the interpreter session by Positron.
88+
* **Status**: The current execution status of the interpreter.
89+
* **Interpreter path**: The file system location of the interpreter executable.
90+
* **Interpreter source**: The method used to discover the interpreter (for example, system PATH, conda environment, or manual configuration).
91+
92+
::: {.callout-tip}
93+
The popup includes shortcuts to relevant output channels for the interpreter session. Select one to view the logs for that channel.
94+
:::
95+
96+
### Interpreter session status
97+
98+
The Console pane list displays an execution status indicator next to each interpreter session.
99+
100+
An interpreter session can be in one of the following states:
101+
102+
* **Idle (green)**: The interpreter session is available to run code
103+
* **Busy (blue)**:: The console session is busy with a task
104+
* **Shutdown (red)**: The console session has shutdown
105+
106+
![Interpreter session status icons from Console pane](images/console-pane-interpreter-session-status.png)

r-installations.qmd

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
title: "Discovering R Installations"
33
---
44

5-
:::{.callout-note}
6-
This information applies to the **Public Beta** release of Positron.
7-
The rules governing interpreter discovery are under active development.
8-
This guide is intended to help you understand the current behavior.
9-
:::
10-
11-
This guide pertains to the R versions in the top-right interpreter chooser (internally known as the Top Bar Interpreter dropdown).
5+
This guide pertains to how R installations are discoverd and show up in the Interpreter picker.
126

137
## R installation discovery
148

0 commit comments

Comments
 (0)