Our use case is that we have two different kinds of exercises: R and Python. We want to have two different images for R and Python. When anyone clicks on R notebook exercise, we want it to open R notebook with R image selected when anyone clicks on python, we want it to open Python notebook with Python image selected?
This pull request by @yuvipanda might work in our use case. My only concern is that the user not being able to access the image directly without using nbgitpuller.
JupyterHub recently started passing the incoming Handler to the Spawner, to allow for exactly this kind of use case. You can check URL params, etc. to change inputs to the Spawner in
class MySpawner(KubeSpawner): async def start(self): if self.handler: profile = self.handler.get_argument('profile', '').lower() if profile and profile == 'r': self.image = 'myrepo/my-r-image:tag' elif profile and profile == 'python': self.image = 'myrepo/my-python-image:tag' elif profile: self.log.warning("Unrecognized profile: %r", profile) return super().start()