-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Notebook API Support #12442
Notebook API Support #12442
Conversation
@jonah-iden do you mind resolving the conflicts so we can continue with a review? |
ece1f44
to
b0089c9
Compare
@jonah-iden since I was on vacation when this was discussed in the dev call: what's the story with this PR? Are you looking to merge this code or just looking for feedback? What's the plan for the missing pieces like renderers? |
Hi @tsmaeder , to be honest i'm not sure if it was ever discussed how exactly to proceed with this regarding merging. I disabled most of the stuff through a hardcoded feature flag, so i guess merging would definitely be a good possiblity. The Idea was mostly to start working on this feature to raise interest and maybe secure more financing to actually finish it, or get other parties involved who would like to contribute to this feature. I will continue working on it on my open source time, but that probably won't be a lot. |
@jonah-iden Thanks for the clarification. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jonah-iden. It's awesome to see notebooks finally coming to Theia. I did a first pass over the Code and most of the comments I have are about naming and code structure.
export class NotebookCellActionContribution implements MenuContribution, CommandContribution { | ||
|
||
protected runDeleteAction(notebookModel: NotebookModel, cell: NotebookCellModel): void { | ||
notebookModel.removeCell(notebookModel.cells.indexOf(cell), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not inline this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because the DeleteAction will very likely become more complicated later on. Like having to inform the backend/plugin about the delete
} | ||
|
||
protected requestCellEdit(notebookModel: NotebookModel, cell: NotebookCellModel): void { | ||
cell.requestEdit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not inline this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as for the DeleteAction
packages/notebook/src/browser/notebook-cell-resource-resolver.ts
Outdated
Show resolved
Hide resolved
|
||
// --- serialize/deserialize | ||
|
||
private _handlePool = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a pool: a pool is something you get entities from and return them to after use. Also, why is this a "handle" and not an "id"? My suggestion would be: "nextId".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, my preference would be to use distinct id spaces for the different entities: I find it makes it easier to identify stuff when debugging or analyzing logs.
@@ -96,7 +96,9 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager { | |||
'onFileSystem', | |||
'onCustomEditor', | |||
'onStartupFinished', | |||
'onAuthenticationRequest' | |||
'onAuthenticationRequest', | |||
'onNotebook', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to add something to plugin-activation-events.ts
to make this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i have to take a look at that. I was kind of confused by the onNotebook and onNotebookSerializer events.
@jonah-iden is there a plan of what still needs to be done to consider the feature complete? |
Hi, thanks a lot for your first pass. There currently is no list of things still needed for feature completion, but i can take some time tomorrow to create one |
Testing with the ms jupyter extension gave the following exception, which I think is relevant:
|
Regarding the list of things still needed for full feature completion, as it is in vscode, this is what i could think of right now.
|
@jonah-iden what about custom cell renderers? |
right thats also a feature still missing. Added it to the list |
@jonah-iden I was playing around with the Python notebooks extensions. For an MVP, that can run python notebooks, I would think we would need cell execution & custom renderers, right? My guesstimate is that this would take around a third of the effort already spent. Would you agree with this? MVP+ would be with decent editing support. Just trying to find out when we could have something we can present to users. |
Im not totally sure we need the custom renderers for an MVP but yeah code execution and full Editing support would definitley be needed. I think the code execution could be quite complex so i would say that all 3 would easily need 5PD, if not a little bit more. I think mark estimated initially something like 25-30PD for full support of which we put in about 10. Though of course i have by far not nearly as much expreience as all the core theia team yet. So my 10PD is problably far less than someone with more expreience would have been able to do |
@tsmaeder @jonah-iden Exactly, my initial estimate for the full feature was something along the lines of 25-30 PD, with 10 having been spent on this MVP. I can imagine execution support being implemented (with custom renderers) in roughly 5 days as well. |
9bea3ab
to
ef22665
Compare
4de79bf
to
a79e28a
Compare
82bfd0a
to
4c5025b
Compare
@tsmaeder, @JonasHelming |
Oh and a small general note for testing. There is currently a problem with the python extension. (see #12708 for more details). |
@jonah-iden awesome, thanks. My hope is to get this merged as soon as possible, but it's a big one, and world+dog seems to be on vacation, so it might take a while. |
Thanks @vince-fugnitto for looking into it!
Right, there were in fact multiple memory leaks. Those should hopefully all be fixed now. At least I don't get any event listener warnings anymore when opening and closing the widget multiple times. The latest commit should fix a lot of other smaller issues in general, such as cell document updates in the plugin host and how the cell execution output is handled in the widget (
Looking into this, I have a feeling our saving infrastructure is a bit antiquated. Every model is somehow in charge of managing the |
@vince-fugnitto Thanks for the heads-up, that seems to be a regression from my previous change. I've fixed it 👍 |
I'm currently in the middle of reading through the code. |
await this.delegate?.save(options); | ||
} | ||
|
||
revert?(options?: Saveable.RevertOptions): Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the Saveable
mechanism handle dynamically adding the function members? How would actions like "revert" get enabled when the saveable turns out to support them?
this.dirty = delegate.dirty; | ||
this.onDirtyChangedEmitter.fire(); | ||
}); | ||
this.autoSave = delegate.autoSave; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will users pick up that the autosave setting of the delegate has changed?
|
||
registerNotebookCellStatusBarItemProvider(notebookType: string, provider: theia.NotebookCellStatusBarItemProvider): theia.Disposable { | ||
|
||
const handle = this.currentSerializerHandle++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either use different handle counters or rename currentSerializerHandle
to somethind generic.
|
||
export class NotebooksExtImpl implements NotebooksExt { | ||
|
||
private readonly notebookStatusBarItemProviders = new Map<number, theia.NotebookCellStatusBarItemProvider>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
notebookCellStatusBarItemProviders
const revivedUri = URI.fromComponents(uri); | ||
const document = this.documents.get(revivedUri.toString()); | ||
|
||
if (document) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe warn if we're removing a non-existing document?
} | ||
} | ||
|
||
getNotebookDocument(uri: TheiaURI, relaxed: true): NotebookDocument | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found a call site that uses the "relaxed" parameter. let's remove it.
return result; | ||
} | ||
|
||
private createExtHostEditor(document: NotebookDocument, editorId: string, data: NotebookEditorAddData): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createNotebookEditor
.
@jonah-iden @msujew I've finished reading through the code. There are a couple of architectural issues, a bunch of functional ones, but many of the comments are just about naming. |
We've decided to go ahead and address comments later
@vince-fugnitto Any chance to get an approval today or tomorrow? |
When I install the python & jupyter extensions, the python extension seems to be activated even though I don't work with python files at all: in fact, I'm working on the Theia project itself.
|
I also get "python" and "python language server" channels in the "Output" widget. And error messages when starting up about not being able to start up the language server, etc. |
sure i can take a look later today |
@tsmaeder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with merging the pull-request even with improvements in #12863 and feedback from Thomas not being implemented for the release since it offers functionality that was previously missing in the framework, and is requested by interested parties 👍
I did not notice any regressions with content outside of notebook editors, and CI successfully passes.
@msujew @jonah-iden do you want to organize and preserve some commits, or do you want to squash into a single one? |
I think squashing is fine. There should not be any important information in the single commits |
🥳 🎉 |
What it does
Closes #8395.
Future Improvements: #12863.
This implements the basics of the notebook api for theia. This includes following features:
Also this PR includes some prepared functionality not in use yet but needed for implementations later on.
To keep the size of the PR on the smaller size (it's already gigantic as it is), some less important notebook features haven't been implemented yet. Don't expect everything to work perfectly as expected
see #12442 (comment) for information on known issues and missing features.
How to test
Basic Notebook support is given through the builtin ipynb extension. So execute
yarn download:plugins
once in the project root.For Cell execution the python and juypter extensions are needed.
Make sure that the workspace you're using for testing is trusted or you have disabled the workspace trust feature. Otherwise, some features, such as notebook kernel selection might not work as expected.
Also here is a notebook for testing W39Mon_Lecture8_DemoNotebook.zip
Review checklist
Reminder for reviewers