-
-
Notifications
You must be signed in to change notification settings - Fork 654
Run sage doc server for jupyterlab #37878
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
Run sage doc server for jupyterlab #37878
Conversation
Documentation preview for this PR (built with commit 1617269; changes) is ready! 🎉 |
eb1fb4a
to
22025a8
Compare
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 do you use 8000 for the default port? That is the http port > 1024 which is most likely to be used by another local http server. If you use 0 as the default port then the system will assign a random unused port > 1024. That way you won't have to worry about port conflicts.
I also would recommend using 127.0.0.1 in the url, rather than localhost. The reason is that a (rogue) DNS nameserver could, in principle, assign an arbitrary IP address to the name localhost. But the IP address 127.0.0.1 always refers to the loopback interface and would never trigger a DNS lookup.
But then how can I know the port randomly assigned? |
More precisely, how |
|
Done. Thanks for the tips! |
Looks like a reasonable approach. After #36730, one might discuss if the doc server should be the responsibility of the sagemath_doc_html distribution, but for now this looks good. |
Thanks!! |
Bump up priority since the original poster of the issue regards it as a bug. |
sagemathgh-37878: Run sage doc server for jupyterlab <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> Reopen sagemath#35139 because of the renewed interest: https://groups.google.com/g/sage-devel/c/kzSWB8ps7VA New environment variables added to `sage.env`: ``` SAGE_DOC_SERVER_URL = var("SAGE_DOC_SERVER_URL") SAGE_DOC_LOCAL_PORT = var("SAGE_DOC_LOCAL_PORT", "0") ``` When Jupyter notebook launches, - If `SAGE_DOC_SERVER_URL` is set, the url is used; - else if local sage documentation is installed, a doc http server with port `SAGE_DOC_LOCAL_PORT` starts. If the port is 0 (the default), then a random port is selected by the system and stored to the environment variable; - else the online official documentation website https://doc.sagemath.org is used for the help menu of the Jupyter notebook. Fixes sagemath#34794. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37878 Reported by: Kwankyu Lee Reviewer(s): Kwankyu Lee, Marc Culler
sagemathgh-38005: Fix Help menu breakdown in external jupyterlab case <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> sagemath#37878 introduced a local documentation server for jupyterlab. But it missed a case for which the Help menu of jupyterlab may break down. In the setup explained in https://doc.sagemath.org/html/en/installation/launching.html#setting-up- sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or- jupyterlab-installation, external jupyterlab is launched and connected to sage kernel. In this case, the local doc server does not run, but the Help menu of the jupyterlab still expects a local doc server, and thus the Help menu does not work well. In this PR, local doc server is detected by testing the port number, and the Help menu uses the online official documentation if local doc server is not running. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38005 Reported by: Kwankyu Lee Reviewer(s):
sagemathgh-38005: Fix Help menu breakdown in external jupyterlab case <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> sagemath#37878 introduced a local documentation server for jupyterlab. But it missed a case for which the Help menu of jupyterlab may break down. In the setup explained in https://doc.sagemath.org/html/en/installation/launching.html#setting-up- sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or- jupyterlab-installation, external jupyterlab is launched and connected to sage kernel. In this case, the local doc server does not run, but the Help menu of the jupyterlab still expects a local doc server, and thus the Help menu does not work well. In this PR, local doc server is detected by testing the port number, and the Help menu uses the online official documentation if local doc server is not running. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38005 Reported by: Kwankyu Lee Reviewer(s):
sagemathgh-38005: Fix Help menu breakdown in external jupyterlab case <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> sagemath#37878 introduced a local documentation server for jupyterlab. But it missed a case for which the Help menu of jupyterlab may break down. In the setup explained in https://doc.sagemath.org/html/en/installation/launching.html#setting-up- sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or- jupyterlab-installation, external jupyterlab is launched and connected to sage kernel. In this case, the local doc server does not run, but the Help menu of the jupyterlab still expects a local doc server, and thus the Help menu does not work well. In this PR, local doc server is detected by testing the port number, and the Help menu uses the online official documentation if local doc server is not running. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#38005 Reported by: Kwankyu Lee Reviewer(s):
Reopen #35139 because of the renewed interest: https://groups.google.com/g/sage-devel/c/kzSWB8ps7VA
New environment variables added to
sage.env
:When Jupyter notebook launches,
SAGE_DOC_SERVER_URL
is set, the url is used;SAGE_DOC_LOCAL_PORT
starts. If the port is 0 (the default), then a random port is selected by the system and stored to the environment variable;for the help menu of the Jupyter notebook.
Fixes #34794.
📝 Checklist
⌛ Dependencies