Skip to content

Commit be64f2e

Browse files
authored
correct kernel location (#39)
1 parent 84aa6c2 commit be64f2e

4 files changed

Lines changed: 20 additions & 37 deletions

File tree

‎package-lock.json‎

Lines changed: 0 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/create_notebook_panel.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ISessionContext } from '@jupyterlab/apputils';
22
import { IEditorServices } from '@jupyterlab/codeeditor';
3+
import { PathExt } from '@jupyterlab/coreutils';
34
import { Context, DocumentRegistry } from '@jupyterlab/docregistry';
45
import {
56
INotebookModel,
@@ -34,12 +35,20 @@ class CustomContext extends Context<INotebookModel> {
3435
export async function createNotebookContext(options: {
3536
manager: ServiceManager.IManager;
3637
kernelPreference: ISessionContext.IKernelPreference;
38+
filePath: string;
3739
}): Promise<Context<INotebookModel>> {
3840
const factory = new NotebookModelFactory({
3941
disableDocumentWideUndoRedo: false
4042
});
41-
const { manager, kernelPreference } = options;
42-
const path = UUID.uuid4() + '.ipynb';
43+
const { manager, kernelPreference, filePath } = options;
44+
45+
const pathsWithoutDriver = filePath.split(':');
46+
const dirPath = PathExt.dirname(
47+
pathsWithoutDriver.length > 1
48+
? pathsWithoutDriver[1]
49+
: pathsWithoutDriver[0]
50+
);
51+
const path = PathExt.join(dirPath, UUID.uuid4() + '.ipynb');
4352

4453
await manager.ready;
4554
await manager.kernelspecs.ready;

‎src/document/plugin.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export const spectaOpener: JupyterFrontEndPlugin<void, ILabShell> = {
121121
urlFactory: ISpectaUrlFactory | null
122122
): Promise<void> => {
123123
const urlParams = new URLSearchParams(window.location.search);
124+
const noTree = urlParams.get('no-tree') === 'true';
124125
if (!isSpectaApp()) {
125126
// Not a specta app
126127
const path = urlParams.get('specta-path');
@@ -150,8 +151,10 @@ export const spectaOpener: JupyterFrontEndPlugin<void, ILabShell> = {
150151
// Specta app
151152
const path = urlParams.get('path');
152153
if (!path) {
153-
const browser = createFileBrowser({ defaultBrowser, urlFactory });
154-
app.shell.add(browser, 'main', { rank: 100 });
154+
if (!noTree) {
155+
const browser = createFileBrowser({ defaultBrowser, urlFactory });
156+
app.shell.add(browser, 'main', { rank: 100 });
157+
}
155158
hideAppLoadingIndicator();
156159
} else {
157160
app.restored.then(async () => {

‎src/specta_model.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { ISignal, Signal } from '@lumino/signaling';
3737
export class AppModel {
3838
constructor(private options: AppModel.IOptions) {
3939
this._notebookModelJson = options.context.model.toJSON();
40+
this._filePath = options.context.localPath;
4041
this._kernelPreference = {
4142
shouldStart: true,
4243
canStart: true,
@@ -87,7 +88,8 @@ export class AppModel {
8788
async initialize(): Promise<void> {
8889
this._context = await createNotebookContext({
8990
manager: this._manager,
90-
kernelPreference: this._kernelPreference
91+
kernelPreference: this._kernelPreference,
92+
filePath: this._filePath
9193
});
9294
this._context.model.fromJSON(this._notebookModelJson);
9395

@@ -214,6 +216,7 @@ export class AppModel {
214216
private _manager: ServiceManager.IManager;
215217
private _kernelPreference: ISessionContext.IKernelPreference;
216218
private _fileChanged = new Signal<this, CellList>(this);
219+
private _filePath: string;
217220
}
218221

219222
export namespace AppModel {

0 commit comments

Comments
 (0)