def get_multi(keys):
    """Get a set of entities from Datastore by their respective keys.

    Note:
      This uses the adapter that is tied to the first model in the
      list.  If the keys have disparate adapters this function may
      behave in unexpected ways.

    Warning:
      You must pass a **list** and not a generator or some other kind
      of iterable to this function as it has to iterate over the list
      of keys multiple times.

    Parameters:
      keys(list[anom.Key]): The list of keys whose entities to get.

    Raises:
      RuntimeError: If the given set of keys have models that use
        a disparate set of adapters or if any of the keys are
        partial.

    Returns:
      list[Model]: Entities that do not exist are going to be None
      in the result list.  The order of results matches the order
      of the input keys.
    """
    if not keys:
        return []

    adapter = None
    for key in keys:
        if key.is_partial:
            raise RuntimeError(f"Key {key!r} is partial.")

        model = lookup_model_by_kind(key.kind)
        if adapter is None:
            adapter = model._adapter

        model.pre_get_hook(key)

    entities_data, entities = adapter.get_multi(keys), []
    for key, entity_data in zip(keys, entities_data):
        if entity_data is None:
            entities.append(None)
            continue

        # Micro-optimization to avoid calling get_model.  This is OK
        # to do here because we've already proved that a model for
        # that kind exists in the previous block.
        model = _known_models[key.kind]
        entity = model._load(key, entity_data)
        entities.append(entity)
        entity.post_get_hook()

    return entities
def get_multi ( keys ) : if not keys : return [ ] adapter = None for key in keys : if key . is_partial : raise RuntimeError ( f"Key {key!r} is partial." ) model = lookup_model_by_kind ( key . kind ) if adapter is None : adapter = model . _adapter model . pre_get_hook ( key ) entities_data , entities = adapter . get_multi ( keys ) , [ ] for key , entity_data in zip ( keys , entities_data ) : if entity_data is None : entities . append ( None ) continue model = _known_models [ key . kind ] entity = model . _load ( key , entity_data ) entities . append ( entity ) entity . post_get_hook ( ) return entities
Get a set of entities from Datastore by their respective keys.

    Note:
      This uses the adapter that is tied to the first model in the
      list.  If the keys have disparate adapters this function may
      behave in unexpected ways.

    Warning:
      You must pass a **list** and not a generator or some other kind
      of iterable to this function as it has to iterate over the list
      of keys multiple times.

    Parameters:
      keys(list[anom.Key]): The list of keys whose entities to get.

    Raises:
      RuntimeError: If the given set of keys have models that use
        a disparate set of adapters or if any of the keys are
        partial.

    Returns:
      list[Model]: Entities that do not exist are going to be None
      in the result list.  The order of results matches the order
      of the input keys.