-
Notifications
You must be signed in to change notification settings - Fork 338
Fixes related to loading widget scripts #10459
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
Conversation
@@ -379,7 +379,9 @@ export abstract class BaseJupyterSession implements IJupyterSession { | |||
const jupyterLabSerialize = | |||
require('@jupyterlab/services/lib/kernel/serialize') as typeof import('@jupyterlab/services/lib/kernel/serialize'); // NOSONAR | |||
const message = | |||
typeof msg.msg === 'string' ? jupyterLabSerialize.deserialize(msg.msg) : msg.msg; | |||
typeof msg.msg === 'string' || msg.msg instanceof ArrayBuffer |
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 was incorrect, when we were firing this event we weren't deserializing buffers
src/kernels/ipywidgets-message-coordination/cdnWidgetScriptSourceProvider.ts
Show resolved
Hide resolved
} | ||
|
||
private async configureWidgets(): Promise<void> { | ||
if (this.configuredScriptSources.length !== 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.
Moved code related to displaying messages for CDN into the CDN class, instaead of having that elsewhere.
}); | ||
} else if (message === IPyWidgetMessages.IPyWidgets_IsOnline) { | ||
const isOnline = (payload as { isOnline: boolean }).isOnline; | ||
this.isWebViewOnline.resolve(isOnline); |
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.
Helps us determine from exension host whether the webview has access to the internet (i.e. whether we can access CDN resources from webview)
@@ -127,7 +118,7 @@ export class IPyWidgetScriptSource { | |||
} | |||
|
|||
if (!this.kernel) { | |||
this.kernel = await this.kernelProvider.get(this.document.uri); | |||
this.kernel = this.kernelProvider.get(this.document.uri); |
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.
unnecessary await
fc173a3
to
ff42172
Compare
Codecov Report
@@ Coverage Diff @@
## main #10459 +/- ##
=======================================
Coverage 71% 71%
=======================================
Files 480 486 +6
Lines 29003 29157 +154
Branches 4885 4902 +17
=======================================
+ Hits 20640 20756 +116
- Misses 6421 6449 +28
- Partials 1942 1952 +10
|
4431fd5
to
eb4aad2
Compare
@@ -0,0 +1,201 @@ | |||
Apache License |
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 wanted to use the actual extension.js files for tests instead of crafting our own content.
Included the license files along with the extesnsion.js files.
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.
Wondering if some automated check tool is going to flag us for having a different license in the repo. But I guess we'll see if anything like that crops up moving forward.
@@ -379,7 +379,9 @@ export abstract class BaseJupyterSession implements IJupyterSession { | |||
const jupyterLabSerialize = | |||
require('@jupyterlab/services/lib/kernel/serialize') as typeof import('@jupyterlab/services/lib/kernel/serialize'); // NOSONAR | |||
const message = | |||
typeof msg.msg === 'string' ? jupyterLabSerialize.deserialize(msg.msg) : msg.msg; | |||
typeof msg.msg === 'string' || msg.msg instanceof ArrayBuffer |
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.
Bug i found while testing, we weren't deserializing buffers
* Given an widget module name & version, this will attempt to find the Url on a CDN. | ||
* We'll need to stick to the order of preference prescribed by the user. | ||
*/ | ||
export class CDNWidgetScriptSourceProvider implements IWidgetScriptSourceProvider { |
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.
Merged the web and node files into one, we don't need to download the cdn files into the local file system anymore.
If we do that then things will not work, e.g. ipyvolume and a few other widgets don't work with that approach.
If user doesn't have access to the internet from the webview, then we'll not use CDN, this way we're consistent. I.e. we always use CDN when there's network connection, else fallback.
If here's no network access we're now displaying a warning message.
const uri = vscode.Uri.file(filename); | ||
const data = await this.vscfs.readFile(uri); | ||
return Buffer.from(data); | ||
return fs.readFile(filename); |
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.
Using VSC API here is totally unnecessary its very slow.
Since these are local only (the methods are local
, hence easier & more efficient to just use native node modules.
@@ -0,0 +1 @@ | |||
Ensure IPyWidgets get loaded correctly when loading resources from the CDN, Remote Jupyter or local the Python Environment. |
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.
Still requires some more testing, but this is ready for review.
Will look into adding more tests or at least re-enabling some of the widget tests tomorrow.
src/kernels/ipywidgets-message-coordination/localIPyWidgetScriptManager.node.ts
Show resolved
Hide resolved
src/kernels/ipywidgets-message-coordination/nbExtensionsPathProvider.web.ts
Show resolved
Hide resolved
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.
Awesome job. Looks like we're going to have ALL widgets working now.
} | ||
try { | ||
// Value will be an array of the form `['xyz', 'abc']` | ||
const items = (output.text as string) |
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.
Language conversions like this always feel a bit scary. Like I think that , is a valid file path character on linux. I think since you have the logging in the catch case this should be ok.
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.
Agreed,
Also I don't see why it will work not work as we own this code along with the output generated (I could optionally send a JSON output back but that felt a little overkill for me).
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.
Come to think of it, that might be better.
Let me see if I can add the JSON output, at least we know the output is JSON and dpoesn't need to be parsed in this manner.
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.
Doesn't work as expected, not going to spend more time on that.
empty news file |
9ff9753
to
c3730db
Compare
c3730db
to
9aba5b1
Compare
Fixes #10434, #10060, #8834, #10319, #8241