# Path: graphscale/utils.py
# async def async_list(coros: List[Awaitable[T]]) -> List[T]:
#     """Use to await a list and return a list.
#     Example: list_of_results = await async_list(list_of_gens)
#     """
#     return await asyncio.gather(*coros)


from abc import ABCMeta, abstractmethod
from collections import OrderedDict
from datetime import datetime
from enum import Enum, auto
from typing import Any, Dict, Iterable, List, NamedTuple, Sequence, Optional
from uuid import UUID, uuid4
from graphscale.utils import async_list
            raise Exception('shards > 1 currently not supported')

        shard = self._shards[0]

        new_ids = []
        for _ in range(0, len(datas)):
            new_ids.append(uuid4())

        await shard.gen_insert_objects(new_ids, type_id, datas)
        return new_ids

    async def gen_object(self, obj_id: UUID) -> KvetchData:
        shard = self.get_shard_from_obj_id(obj_id)
        return await shard.gen_object(obj_id)

    async def gen_objects(self, obj_ids: List[UUID]) -> Dict[UUID, KvetchData]:
        # construct dictionary of shard_id to all ids in that shard
        shard_to_ids = {}  # type: Dict[int, List[UUID]]
        for obj_id in obj_ids:
            shard_id = self.get_shard_id_from_obj_id(obj_id)
            if not shard_id in shard_to_ids:
                shard_to_ids[shard_id] = []
            shard_to_ids[shard_id].append(obj_id)

        # construct list of coros (one per shard) in order to fetch in parallel
        unawaited_gens = []
        for shard_id, ids_in_shard in shard_to_ids.items():
            shard = self._shards[shard_id]
            unawaited_gens.append(shard.gen_objects(ids_in_shard))


# Path: graphscale/utils.py
# async def async_list(coros: List[Awaitable[T]]) -> List[T]:
#     """Use to await a list and return a list.
#     Example: list_of_results = await async_list(list_of_gens)
#     """
#     return await asyncio.gather(*coros)


# Path: graphscale/kvetch/kvetch.py
from abc import ABCMeta, abstractmethod
from collections import OrderedDict
from datetime import datetime
from enum import Enum, auto
from typing import Any, Dict, Iterable, List, NamedTuple, Sequence, Optional
from uuid import UUID, uuid4
from graphscale.utils import async_list

            raise Exception('shards > 1 currently not supported')

        shard = self._shards[0]

        new_ids = []
        for _ in range(0, len(datas)):
            new_ids.append(uuid4())

        await shard.gen_insert_objects(new_ids, type_id, datas)
        return new_ids

    async def gen_object(self, obj_id: UUID) -> KvetchData:
        shard = self.get_shard_from_obj_id(obj_id)
        return await shard.gen_object(obj_id)

    async def gen_objects(self, obj_ids: List[UUID]) -> Dict[UUID, KvetchData]:
        # construct dictionary of shard_id to all ids in that shard
        shard_to_ids = {}  # type: Dict[int, List[UUID]]
        for obj_id in obj_ids:
            shard_id = self.get_shard_id_from_obj_id(obj_id)
            if not shard_id in shard_to_ids:
                shard_to_ids[shard_id] = []
            shard_to_ids[shard_id].append(obj_id)

        # construct list of coros (one per shard) in order to fetch in parallel
        unawaited_gens = []
        for shard_id, ids_in_shard in shard_to_ids.items():
            shard = self._shards[shard_id]
            unawaited_gens.append(shard.gen_objects(ids_in_shard))


        obj_dict_per_shard = await async_list(unawaited_gens)