How to Use Two Different Spawners in JupyterHub?

Hello,

I’m trying to use two different spawners in JupyterHub based on certain conditions, such as the user. For example, I want to use KubeSpawner for some users and SlurmSpawner for others. To achieve this, I’ve been trying to modify spawner.__class__ inside the pre_spawn_hook

However, this approach doesn’t seem to work as expected, and I am encountering issues when trying to change the spawner.__class__.

Is there another way to achieve the goal of using two different spawners based on the user, without directly modifying spawner.__class__? I would appreciate any advice or insights on how to approach this issue.

Thank you!

wrapspawner is meant to handle this situation. It’s not a particularly active project, so I’m not sure how up-to-date it is.

2 Likes

We are using a hybrid spawner based on SSH and SLURM spawner in production which is based on wrapspawner. You can look at it here on how to adopt a solution for your use case. In our case, based on the choice from the spawn page, we start either a SSH or SLURM spawner

1 Like