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

Need to import batchspawner.api in jupyterhub_config.py #126

Closed
dstndstn opened this issue Nov 19, 2018 · 3 comments · Fixed by #130
Closed

Need to import batchspawner.api in jupyterhub_config.py #126

dstndstn opened this issue Nov 19, 2018 · 3 comments · Fixed by #130

Comments

@dstndstn
Copy link

Hi,

I've just got my jupyterhub + profilespawner + batchspawner setup working on a typical academic compute cluster (slurm). Thanks for all your work on this -- it's impressively slick!

I found that I had to add an "import batchspawner.api" to my jupyterhub_config.py file, otherwise the batchspawner's API endpoint didn't get registered. Unless I have done something wrong, it would be worth adding a one-liner to the README file to this effect. (I'll send a PR if you tell me that I'm not wrong.)

Specifically, my jupyterhub_config looks like this, and without the import, the API endpoint gets called but not responded-to!

import batchspawner.api

c.JupyterHub.spawner_class = 'wrapspawner.ProfilesSpawner'
c.Spawner.http_timeout = 120

c.ProfilesSpawner.profiles = [
    ('Head node', 'head', 'sudospawner.SudoSpawner', {}),
    ('Compute node - 4 cores, 4 GB, 8 hours', 'node4c4g8h', 'batchspawner.SlurmSpawner',
              dict(req_nprocs='4', req_partition='defq', req_runtime='8:00:00', req_memory='4gb')),
]

c.SlurmSpawner.batch_submit_cmd = '/home2/jupyterhub/jupyterhub-run/slurmspawner --parsable'

Thanks!

@jd-daniels
Copy link

+1 on this, thanks so much, been banging my head against a wall troubleshooting this.

If you don't do this. You get a 404 from the singleserver auth call back to the hub.

@cmd-ntrf
Copy link
Contributor

I have made some progress on this issue.

batchspawner.api adds the handler to jupyterhub.default_handlers. When we use batchspawner directly in jupyterhub_config, the import of the api file is done before the JupyterHub app is launched and the batchspawner api handler is correctly appended to the Hub list of handlers.

However, when it is configurer through wrapspawner, the import of batchspawner.api come after jupyterhub app is initialized, and it is too late to add content do jupyterhub.default_handlers.

Now that I know what is the issue, I am going to try to find a solution...

@cmd-ntrf
Copy link
Contributor

cmd-ntrf commented Mar 27, 2019

After a few hours of research, it appears that the only way to add a custom handler to JupyterHub except for what I already did in batchspawner.api is to add the api handler in jupyterhub_config.py.

So instead of import batchspawner.api, to solve your initial issue you could add the following line to your jupyterhub_config.py:

c.JupyterHub.extra_handlers = [(r"/api/batchspawner", 'batchspawner.api.BatchSpawnerAPIHandler')]

We will need to add this line to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants