Skip to content
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

Extensions need a writable directory to store and load scripts for usage in a notebook #149868

Closed
rchiodo opened this issue May 18, 2022 · 10 comments
Assignees
Labels
api-proposal info-needed Issue requires more information from poster

Comments

@rchiodo
Copy link
Contributor

rchiodo commented May 18, 2022

Right now when running a cell in a notebook, there are certain directories where scripts can be uploaded from.

These include:

  • Extension root
  • Renderer locations
  • Workspace folders

The problem is that these locations are not always writable.

This location is:

  • Global Storage URI

But globalStorageUri is not allowed as a localResourceRoot.

This feature request is to have a writable location that can be specified as a 'localResourceRoot' in some way.

@rchiodo
Copy link
Contributor Author

rchiodo commented May 18, 2022

Pertinent issue:
microsoft/vscode-jupyter#9984

IPyWidget support requires downloading files and loading them into the notebook output webview.

@rchiodo
Copy link
Contributor Author

rchiodo commented May 19, 2022

Another issue where this is necessary:
microsoft/vscode-jupyter#10060

@mjbvz
Copy link
Collaborator

mjbvz commented May 23, 2022

@rchiodo Can you explain why this is needed? Having the extension download files from a CDN so that these files can be served up inside a webview seems like a hack. It would be better to fix the root issue than add an API that helps workaround it

@rchiodo
Copy link
Contributor Author

rchiodo commented May 23, 2022

JS files exist on a remote jupyter machine. These files need to be loaded into the webview. The web extension can download these files because it has the necessary authentication to get them. The webview doesn't.

In desktop we workaround this problem by downloading the files next to the extension. In the web version, this location isn't writable so we need to add another location that's writable and we can use as a localResourceRoot.

@mjbvz
Copy link
Collaborator

mjbvz commented May 23, 2022

What about using data uris for this?

@rchiodo
Copy link
Contributor Author

rchiodo commented May 23, 2022

I think that might work.

In the widget code it uses requirejs to load the js files. We inject redirects for requires to URIs. I think that the redirect could redirect to a data uri.

@rchiodo
Copy link
Contributor Author

rchiodo commented May 23, 2022

Is there a size limit for a data uri? Or maybe for a message we send to the webview? The js file would have to be base64 encoded and sent as a string.

@jrieken
Copy link
Member

jrieken commented May 24, 2022

I have not heard of a size limit for data uri but you could also use object urls. They wrap around blobs/files and I am pretty sure no limits exists, this is how we use it for some JS scripts

In desktop we workaround this problem by downloading the files next to the extension. In the web version, this location isn't writable so we need to add another location that's writable and we can use as a localResourceRoot.

Ideally you use data/object-urls for desktop too. I believe we aren't super-fans of extension modifying their own installation data.

Also curious what auth issue it is that you are running into? Is this jupyter specific or a scenario that could affect other extensions too?

@mjbvz mjbvz added the info-needed Issue requires more information from poster label Jun 15, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 21, 2022

@rchiodo Just checking, is this is still needed?

@rchiodo
Copy link
Contributor Author

rchiodo commented Jun 21, 2022

I don't think so. We can use object URLs if necessary but I believe I was mistaken. Jupyter doesn't require authentication for nbextension resources at the moment, so the URL should work directly.

@rchiodo rchiodo closed this as completed Jun 21, 2022
@mjbvz mjbvz removed this from the June 2022 milestone Jun 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-proposal info-needed Issue requires more information from poster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants