'If the user is already assigned to a group in user_partition_id, return the
group_id.
If not, assign them to one of the groups, persist that decision, and
return the group_id.
Args:
user_partition_id -- an id of a partition that\'s hopefully in the
runtime.user_partitions list.
Returns:
The id of one of the groups in the specified user_partition_id (as a string).
Raises:
ValueError if the user_partition_id isn\'t found.'

def get_user_group_id_for_partition(self, user, user_partition_id):

    cache_key = 'PartitionService.ugidfp.{}.{}.{}'.format(user.id, self._course_id, user_partition_id)
    if (self._cache and (cache_key in self._cache)):
        return self._cache[cache_key]
    user_partition = self.get_user_partition(user_partition_id)
    if (user_partition is None):
        raise ValueError('Configuration    problem!        No    user_partition    with    id    {0}    in    course    {1}'.format(user_partition_id, self._course_id))
    group = self.get_group(user, user_partition)
    group_id = (group.id if group else None)
    if (self._cache is not None):
        self._cache[cache_key] = group_id
    return group_id
