    async def init_groups(self):
        """Load predefined groups into the database"""
        db = self.db

        if self.authenticator.manage_groups and self.load_groups:
            raise ValueError("Group management has been offloaded to the authenticator")

        for name, contents in self.load_groups.items():
            self.log.debug("Loading group %s", name)
            group = orm.Group.find(db, name)

            if group is None:
                self.log.info(f"Creating group {name}")
                group = orm.Group(name=name)
                db.add(group)
            if isinstance(contents, list):
                self.log.warning(
                    "group config `'groupname': [usernames]` config format is deprecated in JupyterHub 3.2,"
                    " use `'groupname': {'users': [usernames], ...}`"
                )
                contents = {"users": contents}
            if 'users' in contents:
                for username in contents['users']:
                    username = self.authenticator.normalize_username(username)
                    user = await self._get_or_create_user(
                        username, hint=f"group: {name}"
                    )
                    if group not in user.groups:
                        self.log.debug(f"Adding user {username} to group {name}")
                        group.users.append(user)

            if 'properties' in contents:
                group_properties = contents['properties']
                if group.properties != group_properties:
                    # add equality check to avoid no-op db transactions
                    self.log.debug(
                        f"Adding properties to group {name}: {group_properties}"
                    )
                    group.properties = group_properties

        db.commit()
Load predefined groups into the database
jupyterhub/app.py