How to hook on time when user connect to jupyter server

Hi everyone.

We are using kubespawner (generating a separate single server pod for each user).

Currently we have a requirement to do something when a user connects (via jupyter lab) to the jupyter server:

  1. Initiate an HTTP request to query the list of python files that need to be synchronized
  2. Download the files to the local filesystem from the (S3 compatible) object storage platform.
  3. Imports the files into the kernel as a module that can be used with the available import keyword.

Is there any API or logic in the jupyter server that is called only once before the user connects to the server again, which I am going to use (by modifying the jupyter server code) as a trigger point for our business logic. Or is there any more elegant way to achieve this purpose?

If there is no such trigger points, I’m going to write a jupyterlab plugin and a jupyter server extension and require the user to manually click the button to trigger file synchronization each time before they begin to work.

I think using the hook of jupyterhub authenticator would be more appropriate, but I’m not sure how to send a request from the pod the hub is on to the corresponding user pod.

Thanks ahead.