jupyterhub / binderhub

Run your code in the cloud, with technology so advanced, it feels like magic!
https://binderhub.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.56k stars 390 forks source link

Things that can break with lab by default #1368

Open minrk opened 3 years ago

minrk commented 3 years ago

Switching to lab by default broke more than I thought. Taking some notes here, to see if there are things we can do to mitigate breakage, or at least point folks to mitigations.

The main information I think we need to surface is ?urlpath=/tree/ or ?urlpath=/notebooks/mynotebook.ipynb allow opt-in to the classic notebook interface, for anyone who wants to preserve that behavior.

Cases that can stop working:

I think the 404s are the harshest ones, and things we should consider trying to fix.

Mitigations:

minrk commented 3 years ago

I think this will work to avoid breakage in most of the cases we've seen so far:

if we change the default launch command to:

["python3", "-c", 
"""
import sys
from distutils.version import LooseVersion as V
try:
  import jupyterlab
  major = int(jupyterlab.__version__.split(".", 1)[0])
except Exception:
  have_lab = False
else:
  have_lab = major >= 3

if have_lab:
  # if recent-enough lab is available, make it the default UI
  sys.argv.insert(1, "--NotebookApp.default_url=/lab/")

# launch the notebook server
os.execv("jupyter-notebook", sys.argv[1:])
""",
]

This moves the default_url selection down one level, out of the chart config (c.Spawner.default_url) into the command (c.Spawner.cmd).

Need to think carefully about where this should go, whether it's in the mixin source or if putting it directly in the singleuser.cmd field in the chart will work, which would be simplest.

hackfin commented 3 years ago

is there a way we could detect availability of jupyterlab before picking default url? This is not hard with a custom entrypoint, but we have very little available to us with custom Dockerfiles. Maybe if we mount an executable from a volume, we could do something without modifying the image?

Mounting a custom launcher like the above looks like the most reasonable 'legacy support' solution to me (I'm one of those evil Dockerfile users).

It appears to be tricky to find other web based fallback solutions (redirects...) to fix a 404 when inside a custom Docker environment. There could maybe be a server extension package just for this purpose, but would require to build new containers.

minrk commented 3 years ago

Yeah, since Binder doesn't add anything to the containers, anything that involves installation doesn't solve the problem (there is also already a package that provides this solution - jupyterlab).