Does tmpauthenticator still work with TLJH?

Hi, I want to host a TLJH instance which lets me demo a custom Jupyter extension without users having to install it first. To do that, I want to use TLJH and have user accounts automatically created (and later destroyed), and also be able to send the user to an existing notebook automatically.

It looks like tmpauthenticator would work for that, but I’m getting errors when starting it.

This is how I installed it:

sudo -E pip install jupyterhub-tmpauthenticator
sudo tljh-config set auth.type tmpauthenticator.TmpAuthenticator
sudo tljh-config reload

However, once I installed it, the homepage (and other pages) just gave me this:

Service Unavailable

Here’s what the logs show:

Dec 10 01:11:12 li840-145 python3[10017]: [C 2018-12-10 01:11:12.901 JupyterHub application:90] Bad config encountered during initialization:
Dec 10 01:11:12 li840-145 python3[10017]: [C 2018-12-10 01:11:12.902 JupyterHub application:91] The 'authenticator_class' trait of <__main__.JupyterHub object at 0x7fbaece787f0> instance must be a type, but 'tmpauthenticator.TmpAuthenticator' could not be imported

I’m able to import tmpauthenticator here:

jupyter-vaughn@li840-145:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tmpauthenticator
>>> from tmpauthenticator import TmpAuthenticator

Do I need to install tmpauthenticator running as root on the machine directly? How do I make sure that I’m installing it for the right python instance that TLJH uses?

Thanks!

Vaughn

Thanks for opening this!

TLJH sets up two environments - a hub one and a user one. There’s some more details here: http://tljh.jupyter.org/en/latest/contributing/packages.html

python and pip by default point to the user environment, rather than the hub one. If you instead use sudo /opt/tljh/hub/bin/pip instead to install tmpauthenticator, that should work fine.

We should probably also add tmpauthenticator the default TLJH install. A PR doing that would also be most welcome :slight_smile:

Agree - this would be a nice use-case to show off. @vaughnkoch if you get this working and can either:

  1. post the configuration / steps it took to get it working here
  2. add a section to the authenticator section of the docs about this use-case

that’d be awesome :slight_smile:

I’ll be happy to contribute this, but I won’t be able to do so for a few months. I’m in super crunch mode until end of March for a project I’m working on.

I did get tmpauthenticator up (thanks @yuvipanda !) and it works great. However, getting rid of old users takes a lot of effort. I found culling on JupyterHub and tried these settings in config.yaml (with tljh-config reload of course)

cull:
  enabled: true
  every: 60
  timeout: 60

I also tried this to no avail:

cull:
  enabled: true

Does culling work for TLJH? I would expect it does since TLJH wraps JH, but maybe I missed something in the docs. Or, if culling is only for pods, is there equivalent functionality for inactive user accounts/servers for TLJH?

hmmm that’s a good question, I didn’t see anything in the guide, but I agree it’d be good to have something about this here: The Littlest JupyterHub — The Littlest JupyterHub documentation

Culling isn’t integrated into TLJH yet unfortunately. https://github.com/jupyterhub/the-littlest-jupyterhub/issues/100 has details.

https://github.com/jupyterhub/jupyterhub/tree/master/examples/cull-idle is the actual code that does the culling. the YAML format and link you found were for Zero to JupyterHub, which is based on Kubernetes. Most of those don’t work with TLJH.

2 Likes