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

Support Export in Web #9996

Closed
Tracked by #9574
rebornix opened this issue May 12, 2022 · 1 comment · Fixed by #10069
Closed
Tracked by #9574

Support Export in Web #9996

rebornix opened this issue May 12, 2022 · 1 comment · Fixed by #10069
Assignees
Labels
feature-request Request for new features or functionality

Comments

@rebornix
Copy link
Member

rebornix commented May 12, 2022

This is part of #9574

Currently the Export actions are powered by nbconvert. We will run nbconvert in a separate process and save the converted content in a temporary file on disk. This is not feasible on Web as Jupyter runs in web worker and there is no jupyter/nbconvert in the same environment. To archive the same thing on Web, we would need to ask the remote Jupyter server/service to handle the nbconvert request for us.

There are two ways to run nbconvert on the remote Jupyter server:

  • The first one is directly calling the nbconvert web service, we can construct an url as ${baseUrl}/nbconvert/${type}/${filePath}?token=${token} and fetch this resource in the web extension. However it requires the file to be synced to the remote Jupyter server
  • The second one is calling nbconvert through shell commands
    • We can either run it against files, i.e., !jupyter nbconvert test.ipynb --to python --stdout, but it has the same problem as the first approach
    • Or we can pass in the content through stdin: !echo '{"cells": [], "metadata": {}, "nbformat": 4, "nbformat_minor": 2 }' | jupyter nbconvert --nbformat 4 --stdin --to python --stdout. This is the only approach that doesn't require file to be synced but if the file is large, it will affect the throughput.
    • The catch with running shell commands is it requires us to know the path of the active jupyter executable as it might exist in PATH and it needs to be platform specific. We might need to run {sys.executable} -m jupyter nbconvert
@rebornix rebornix added bug Issue identified by VS Code Team member as probable bug and removed bug Issue identified by VS Code Team member as probable bug labels May 12, 2022
@github-actions github-actions bot added the triage-needed Issue needs to be triaged label May 12, 2022
@rebornix rebornix self-assigned this May 12, 2022
@rchiodo
Copy link
Contributor

rchiodo commented May 12, 2022

We've used the {sys.executable} trick in the past to run python on the jupyter server.

Another idea? Zip the file on the local machine, send zip with jupyter file transfer API, reopen zip in temp folder and run nbconvert on it?

The stdin way sounds plausible but I'm worried about gb size notebooks (that zip up to mbs)

@IanMatthewHuff IanMatthewHuff added vscode-web feature-request Request for new features or functionality and removed triage-needed Issue needs to be triaged labels May 12, 2022
@rebornix rebornix mentioned this issue May 30, 2022
2 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants