b-data / jupyterlab-python-docker-stack

(GPU accelerated) Multi-arch (linux/amd64, linux/arm64/v8) JupyterLab Python docker images. Please submit Pull Requests to the GitLab repository. Mirror of
https://gitlab.com/b-data/jupyterlab/python/docker-stack
Other
31 stars 6 forks source link

Feature Request Black for JupyterLab #2

Closed agoertz-fls closed 1 year ago

agoertz-fls commented 1 year ago

Hi, first I have to thank you for this grate GPU enabled images. I was wondering if you could add a code-formatter preferably black to the jupyterlab instance. I found that there is a python-lsp-black for the Language Server but I did not manage to get it running from within the image and the docker image building process currently fails on my machine. It would be really nice to have an easy option to reformat cells in the notebook automatically.

Kind regards, Alex

benz0li commented 1 year ago

Hi, first I have to thank you for this grate GPU enabled images.

You are welcome.

I was wondering if you could add a code-formatter preferably black to the jupyterlab instance.

Use the images with the devtools subtag, e.g. glcr.b-data.ch/jupyterlab/cuda/python/scipy:latest-devtools.

https://github.com/b-data/jupyterlab-python-docker-stack/blob/6c3e77553ac3783fb37842a7ec5c7a8b1ba4daee/common/subtags/devtools/latest.Dockerfile#L68

Those include extension Black Formatter.

agoertz-fls commented 1 year ago

Oh, nice but this will require me to use the code server instance right? I tried this but the last time it was't able to open my ipynb files, it showed the markdown outline, but the code was never displayed, so I was hoping for an extension that somehow works with the jupyterlab instance.

benz0li commented 1 year ago

Oh, nice but this will require me to use the code server instance right?

Yes.

I tried this but the last time it was't able to open my ipynb files, it showed the markdown outline, but the code was never displayed, so I was hoping for an extension that somehow works with the jupyterlab instance.

Most likely you are not using HTTPS. This is required for Jupyter notebooks.
ℹ️ Fully qualified domain name (FQDN) required, too. TLS for an IP is not sufficient.

HTTP only works for 127.0.0.1 / localhost.

Cross references:

agoertz-fls commented 1 year ago

Most likely you are not using HTTPS. This is required for Jupyter notebooks. information_source Fully qualified domain name (FQDN) required, too. TLS for an IP is not sufficient.

Yeah I guess this might be the issue as this is behind the firwall up until now I was not bothering with Transport encryption but I will try to set something up to handle TLS, I guess a reverse proxy infront of the docker exposed port will be the easiest option.

benz0li commented 1 year ago

I found that there is a python-lsp-black for the Language Server but I did not manage to get it running from within the image

About customisation:

  1. https://github.com/b-data/jupyterlab-python-docker-stack/blob/main/NOTES.md#customise
  2. Python LSP Server: https://github.com/jupyter-lsp/jupyterlab-lsp#configuring-the-servers

ℹ️ JupyterLab: You should be able to modify at runtime via Settings > Advanced Settings Editor [> JSON Settings Editor].

benz0li commented 1 year ago

Need to fix

https://github.com/b-data/jupyterlab-python-docker-stack/blob/6c3e77553ac3783fb37842a7ec5c7a8b1ba4daee/base/conf/jupyterlab/usr/local/share/jupyter/lab/settings/overrides.json#L8

Should be "@jupyter-lsp/jupyterlab-lsp:plugin": {.

ℹ️ Otherwise the override has no effect.

benz0li commented 1 year ago

I will try to set something up to handle TLS

-e GEN_CERT=yes - Instructs the startup script to generate a self-signed SSL certificate. Configures Jupyter Server to use it to accept encrypted HTTPS connections.

Common Features — Docker Stacks documentation > Additional runtime configurations

Use start-notebook.sh --ServerApp.certfile=~/.local/share/jupyter/notebook.pem as command (without -e GEN_CERT=yes) for further runs if your home directory is persistent.

Common Features — Docker Stacks documentation > SSL Certificates

benz0li commented 1 year ago

Fixed /usr/local/share/jupyter/lab/settings/overrides.json: https://github.com/b-data/jupyterlab-python-docker-stack/commit/1a198366b3ba9f92c6a8efe0da357ff7603d1166

benz0li commented 1 year ago

@agoertz-fls Please close this issue if my information has helped you configuring black (formatter) in JupyterLab and enable TLS encryption.

Thank you.

agoertz-fls commented 1 year ago

Thanks a lot, I will try to customize the image based on that information, if someone comes across this and writes a nice tutorial how to use your images as a base and customize on it by installing additional python packages and overwrites like the one above would be great, I guess I won't find the time in the foreseeable future. Thanks a lot for this quick and helpful support.