<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def bulk(iterable, index=INDEX_NAME, doc_type=DOC_TYPE, action='index'):
 """ Wrapper of elasticsearch's bulk method Converts an interable of models to document operations and submits them to Elasticsearch. Returns a count of operations when done. https://elasticsearch-py.readthedocs.io/en/master/api.html#elasticsearch.Elasticsearch.bulk https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html """

    actions = compact(dict_to_op(
        to_dict(model),
        index_name=INDEX_NAME,
        doc_type=DOC_TYPE,
        op_type=action,
    ) for model in iterable)

    # fail fast if there are no actions
    if not actions:
        return 0

    items, _ = es_bulk(es_conn, actions, doc_type=doc_type, index=index)

    return items