Skip to content

Commit 21f00ed

Browse files
committed
Switch to using kallichore to manage kernel
1 parent 1fc0c98 commit 21f00ed

1 file changed

Lines changed: 5 additions & 63 deletions

File tree

ggsql-vscode/src/manager.ts

Lines changed: 5 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as path from 'path';
1111
import * as cp from 'child_process';
1212
import * as crypto from 'crypto';
1313
import type * as positron from '@posit-dev/positron';
14-
import type { JupyterKernelSpec, JupyterSession, JupyterKernel, PositronSupervisorApi } from './types';
14+
import type { JupyterKernelSpec, PositronSupervisorApi } from './types';
1515
import { log } from './extension';
1616

1717
/** Where a kernel candidate was discovered */
@@ -197,70 +197,16 @@ function generateMetadata(
197197
/**
198198
* Create a Jupyter kernel spec for ggsql-jupyter
199199
*
200-
* Uses the startKernel callback to manually start the kernel process,
201-
* giving us more control over the launch process.
202-
*
203200
* @param kernelPath - Path to the ggsql-jupyter executable
204-
* @param workspacePath - Optional workspace path to use as the kernel's working directory
205201
*/
206-
function createKernelSpec(kernelPath: string, workspacePath?: string): JupyterKernelSpec {
202+
function createKernelSpec(kernelPath: string): JupyterKernelSpec {
207203
return {
208-
// argv is empty when using startKernel callback
209-
argv: [],
204+
argv: [kernelPath, '-f', '{connection_file}'],
210205
display_name: 'ggsql',
211206
language: 'ggsql',
212207
interrupt_mode: 'signal',
213-
env: {},
208+
env: { RUST_LOG: 'error' },
214209
kernel_protocol_version: '5.3',
215-
startKernel: async (session: JupyterSession, kernel: JupyterKernel) => {
216-
kernel.log(`Starting ggsql kernel with connection file: ${session.state.connectionFile}`);
217-
kernel.log(`Working directory: ${workspacePath ?? 'inherited from parent'}`);
218-
219-
const connectionFile = session.state.connectionFile;
220-
221-
// Start the kernel process
222-
const proc = cp.spawn(kernelPath, ['-f', connectionFile], {
223-
stdio: ['ignore', 'pipe', 'pipe'],
224-
detached: false,
225-
cwd: workspacePath
226-
});
227-
228-
// Log stdout and stderr
229-
proc.stdout?.on('data', (data) => {
230-
const msg = data.toString();
231-
kernel.log(msg);
232-
});
233-
234-
proc.stderr?.on('data', (data) => {
235-
const msg = data.toString();
236-
kernel.log(msg);
237-
});
238-
239-
proc.on('error', (err) => {
240-
const msg = `Failed to start kernel: ${err.message}`;
241-
kernel.log(msg);
242-
throw new Error(msg);
243-
});
244-
245-
proc.on('exit', (code, signal) => {
246-
kernel.log(`Kernel exited (code: ${code}, signal: ${signal})`);
247-
});
248-
249-
// Wait a moment for the kernel to start binding sockets
250-
await new Promise(resolve => setTimeout(resolve, 1000));
251-
252-
// Check if process is still running
253-
if (proc.exitCode !== null) {
254-
throw new Error(`Kernel process exited immediately with code ${proc.exitCode}`);
255-
}
256-
257-
kernel.log('Connecting to kernel session...');
258-
259-
// Connect to the session
260-
await kernel.connectToSession(session);
261-
262-
kernel.log('Connected to ggsql kernel');
263-
}
264210
};
265211
}
266212

@@ -441,12 +387,8 @@ export class GgsqlRuntimeManager implements positron.LanguageRuntimeManager {
441387
// Ensure the extension is activated
442388
const supervisorApi = await supervisorExt.activate();
443389

444-
// Get workspace path for kernel's working directory
445-
const workspaceFolders = vscode.workspace.workspaceFolders;
446-
const workspacePath = workspaceFolders?.[0]?.uri.fsPath;
447-
448390
// Create the kernel spec using the runtime's kernel path
449-
const kernelSpec = createKernelSpec(runtimeMetadata.runtimePath, workspacePath);
391+
const kernelSpec = createKernelSpec(runtimeMetadata.runtimePath);
450392

451393
const dynState = createDynState();
452394

0 commit comments

Comments
 (0)