Accessing user groups from pre_spawn_hook

For a high level overview, I am writing a web app which allows users to access a hosted version of jupyterhub (I’m using z2jh with an aws cluster (not eks)). I would like my users to select their compute requirements (small, medium, and large) on my website and be directly taken to a server. Through the REST API, I’ve created groups (small, medium, and large) and now wish to spawn servers of the appropriate size given this group. I would like my pre_spawn_hook to look something like this:

 async def set_resources_hook(spawner):
              groups = [group['name'] in spawner.user.groups]
              if "small" in groups:
                      spawner.cpu_limit = 2.0
                      spawner.cpu_guarantee = 1.0
                      spawner.mem_limit = "2G"
                      spawner.mem_guarantee = "1G"
              if {...more code...}
      c.KubeSpawner.pre_spawn_hook = set_resources_hook

However, I have not figured out how to access the user groups from the pre_spawn_hook and would appreciate any pointers.

I fixed this with [ for group in spawner.user.groups]

[ for group in spawner.user.groups]