| 219 | return { file: Uri.file(tempFile), dispose: () => swallowExceptions(() => fs.unlinkSync(tempFile)) }; |
| 220 | }, |
| 221 | async startJupyterServer( |
| 222 | options: { |
| 223 | token?: string; |
| 224 | port?: number; |
| 225 | useCert?: boolean; |
| 226 | jupyterLab?: boolean; |
| 227 | password?: string; |
| 228 | detached?: boolean; |
| 229 | standalone?: boolean; |
| 230 | } = {} |
| 231 | ): Promise<{ url: string } & IDisposable> { |
| 232 | if (IS_REMOTE_NATIVE_TEST()) { |
| 233 | if (options.standalone) { |
| 234 | return JupyterServer.instance.startJupyter(options); |
| 235 | } |
| 236 | if (!remoteUrisCleared) { |
| 237 | await commands.executeCommand('deepnote.clearSavedJupyterUris'); |
| 238 | remoteUrisCleared = true; |
| 239 | } |
| 240 | const url = options.useCert |
| 241 | ? await JupyterServer.instance.startJupyterWithCert() |
| 242 | : await JupyterServer.instance.startJupyterWithToken(); |
| 243 | console.info(`Jupyter started and listening at ${url}`); |
| 244 | try { |
| 245 | await commands.executeCommand('deepnote.selectjupyteruri', Uri.parse(url)); |
| 246 | } catch (ex) { |
| 247 | console.error('Failed to select jupyter server, retry in 1s', ex); |
| 248 | } |
| 249 | // Todo: Fix in debt week, we need to retry, some changes have caused the first connection attempt to fail on CI. |
| 250 | // Possible we're trying to connect before the server is ready. |
| 251 | await sleep(5_000); |
| 252 | await commands.executeCommand('deepnote.selectjupyteruri', Uri.parse(url)); |
| 253 | return { url, dispose: noop }; |
| 254 | } else { |
| 255 | return { url: '', dispose: noop }; |
| 256 | } |
| 257 | }, |
| 258 | async stopJupyterServer() { |
| 259 | if (IS_REMOTE_NATIVE_TEST()) { |
| 260 | return; |