Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ dmypy.json
# Yarn cache
.yarn/

nodpy/tests/nod/**
nodpy/tests/nod/**
demos/**
26 changes: 9 additions & 17 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,16 @@ NODCONFIG

- add restart time to nodConfig? (hmm maybe)

Nod Tracking

- set tracking where?

- notebook()
- NodInfo (but with code transformed)
- NodLog (but with code transformed)
- write request
- Program info before (but with code transformed)
- Program info after (but with code transformed)
- execute cell
- navigate stackframe
- save notebook
- restart
- whether we write or not

TODO

- dont change cwd
- quit if program finishes without calling notebook?
— display all code above
— Highlight editable code on the scrollbar
— Bash command issue
— Multiple Nod instances
— Modules not available higher up in call stack?
- Nod log — quotes around variable name
- add dependency for ipython
- path concat bug
- run restarts in jupyter terminal window?
Expand All @@ -62,7 +54,7 @@ TODO
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

Nice to have

- edit function arguments
- persist lock through reload?
- - clear old kernels from jupyter (get shutdown registering properly??)
- layoutrestorer, restorablepool
Expand Down
Empty file added nodpy/__main__.py
Empty file.
77 changes: 77 additions & 0 deletions nodpy/tests/simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,84 @@

x = 0

# **test comment

# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# **test comment

# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test# **test comment


# test
# test
def baller(a, b: int, c: int):
global x
global z
Expand Down
32 changes: 26 additions & 6 deletions src/codeViewers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import {
} from '@jupyterlab/cells';
import { nodState } from './state';
import { NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
import { Widget } from '@lumino/widgets';
import { IDisposable, DisposableDelegate } from '@lumino/disposable';
import { DocumentRegistry } from '@jupyterlab/docregistry';
import { hasFileInfo } from './types';
import { Widget } from '@lumino/widgets';
// const INPUT_AREA_CLASS = 'jp-InputArea';
// const INPUT_AREA_EDITOR_CLASS = 'jp-InputArea-editor';
const NOD_VIEWER_CLASS = 'jp-nod-viewer';
Expand All @@ -43,14 +43,34 @@ function addCodeViewers(panel: NotebookPanel) {

if (parentNode) {
if (panel.isAttached) {
Widget.attach(header, parentNode, innerPanel);
Widget.attach(func, parentNode, innerPanel);
const ref = panel.content.viewportNode.children[0] as HTMLElement;
header.processMessage(Widget.Msg.BeforeAttach);
func.processMessage(Widget.Msg.BeforeAttach);
footer.processMessage(Widget.Msg.BeforeAttach);
panel.content.viewportNode.insertBefore(header.node, ref);
panel.content.viewportNode.insertBefore(func.node, ref);
Widget.attach(footer, parentNode);
header.node.dataset.windowedListIndex = `-1`;
func.node.dataset.windowedListIndex = `-1`;
footer.node.dataset.windowedListIndex = `-1`;
header.processMessage(Widget.Msg.AfterAttach);
func.processMessage(Widget.Msg.AfterAttach);
footer.processMessage(Widget.Msg.AfterAttach);
} else {
panel.revealed.then(() => {
Widget.attach(header, parentNode, innerPanel);
Widget.attach(func, parentNode, innerPanel);
const ref = panel.content.viewportNode.children[0] as HTMLElement;
header.processMessage(Widget.Msg.BeforeAttach);
func.processMessage(Widget.Msg.BeforeAttach);
footer.processMessage(Widget.Msg.BeforeAttach);
panel.content.viewportNode.insertBefore(header.node, ref);
panel.content.viewportNode.insertBefore(func.node, ref);
Widget.attach(footer, parentNode);
header.node.dataset.windowedListIndex = `-1`;
func.node.dataset.windowedListIndex = `-1`;
footer.node.dataset.windowedListIndex = `-1`;
header.processMessage(Widget.Msg.AfterAttach);
func.processMessage(Widget.Msg.AfterAttach);
footer.processMessage(Widget.Msg.AfterAttach);
});
}
}
Expand Down Expand Up @@ -99,7 +119,7 @@ export function makeCodeViewer(
switch (className) {
case NOD_HEADER_CLASS: {
const text_above = currentFrame.file_info.text_above;
source = text_above.slice(-10).join('').split('\\n').join('\n');
source = text_above.join('').split('\\n').join('\n');
if (source.startsWith('\n')) {
source = source.slice(source.indexOf('\n'));
}
Expand Down
35 changes: 17 additions & 18 deletions src/kernelHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,28 @@ export async function openNotebookWithNodKernel(

await state.app.serviceManager.kernels.refreshRunning();
const nodKernelId = await getNodKernel();

console.log('finding notebook:', notebookFile);
state.tracker.forEach(panel => {
console.log(panel.context.sessionContext.path);
console.log(panel.context.sessionContext.path === notebookFile);
});
const existingNotebook = state.tracker.find(
panel => panel.context.sessionContext.path === notebookFile
panel => panel.context.sessionContext.path === normalized
);
console.log('opening', normalized, nodKernelId);
const newNotebook = docManager.openOrReveal(normalized, 'default', {
name: 'nod',
id: nodKernelId
});
if (existingNotebook) {
console.log('Existing Notebook with Path', existingNotebook);
existingNotebook.sessionContext.kernelPreference = {
// autoStartDefault: false,
name: 'nod',
id: nodKernelId,
shutdownOnDispose: false
};
state.app.shell.activateById(existingNotebook.id);
// state.sessionManager.connectTo
existingNotebook.context.sessionContext.changeKernel({
name: 'nod',
id: state.nodKernelId
});
} else {
console.log('opening', normalized, nodKernelId);
docManager.openOrReveal(normalized, 'default', {
name: 'nod',
id: nodKernelId
newNotebook?.revealed.then(() => {
nodState
.Instance()
.tracker.currentWidget?.content.activeCell!.node.scrollIntoView({
block: 'center'
});
});
}
}
Expand Down
Loading