Skip to content

Commit 1429fd1

Browse files
authored
fix: DOC-1016: VS Code - Python Remote File Sourcing (#261)
I ran into some confusing issues while trying to document Python Remote File Sourcing: - VS Code was sometimes sourcing the .venv from a different workspace when I was starting pip servers. I added logging so we can easily know which Python interpreter is being used for Pip servers - Managed server list did not always refresh when using the refresh button in the treeview. I added a flag to force this ### Testing - Open a workspace in VS Code (can be empty) - Create a new Python .venv - Install deephaven-server package in the .venv ```sh pip install deephaven-server ``` - In Deephaven view, if the "Managed" node doesn't show, click the refresh button in the SERVERS treeview. It should show up - In the `Output -> Deephaven Debug` panel, should see some entries for `[PipServerController] DEBUG` showing the Python interpreter path for the workspace - Delete the Python `.venv` folder - Refresh the treeview again. The "Managed" node should disappear
1 parent 9174cb5 commit 1429fd1

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/controllers/ExtensionController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ export class ExtensionController implements IDisposable {
10311031
};
10321032

10331033
onRefreshServerStatus = async (): Promise<void> => {
1034-
await this._pipServerController?.syncManagedServers();
1034+
await this._pipServerController?.syncManagedServers({ forceCheck: true });
10351035
await this._serverManager?.updateStatus();
10361036
};
10371037

src/controllers/PipServerController.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ export class PipServerController implements IDisposable {
9696

9797
const pythonInterpreterPath = await this.getPythonInterpreterPath();
9898
if (pythonInterpreterPath == null) {
99+
logger.debug('Python interpreter path not found');
99100
return { isAvailable: false };
100101
}
101102

103+
logger.debug('Using Python interpreter:', pythonInterpreterPath);
104+
102105
try {
103106
execFileSync(pythonInterpreterPath, ['-c', 'import deephaven_server']);
104107
return { isAvailable: true, interpreterPath: pythonInterpreterPath };
@@ -130,7 +133,7 @@ export class PipServerController implements IDisposable {
130133
}
131134

132135
if (this._serverUrlTerminalMap.size > 0) {
133-
await this.syncManagedServers(true);
136+
await this.syncManagedServers({ preferExistingPsk: true });
134137

135138
for (const port of this._serverUrlTerminalMap.keys()) {
136139
await this.pollUntilServerStarts(port);
@@ -323,12 +326,20 @@ export class PipServerController implements IDisposable {
323326

324327
/**
325328
* Sync current managed server state with the server manager.
326-
* @param preferExistingPsk If true, use existing PSK if one exists for each
329+
* @param options Optional options:
330+
* - forceCheck If true, force a re-check of pip server availability
331+
* - preferExistingPsk If true, use existing PSK if one exists for each
327332
* server.
328333
* @returns
329334
*/
330-
syncManagedServers = async (preferExistingPsk = false): Promise<void> => {
331-
if (!this._isPipServerInstalled) {
335+
syncManagedServers = async ({
336+
forceCheck = false,
337+
preferExistingPsk = false,
338+
}: {
339+
forceCheck?: boolean;
340+
preferExistingPsk?: boolean;
341+
} = {}): Promise<void> => {
342+
if (forceCheck || !this._isPipServerInstalled) {
332343
this._isPipServerInstalled = (await this.checkPipInstall()).isAvailable;
333344
}
334345

0 commit comments

Comments
 (0)