Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def bulk_update_cgm(cgms, actions=None, op='update', index=None):
index = index or INDEX
if not actions and cgms:
actions = ({
'_op_type': op,
'_index': index,
'_id': cgm._id,
'_type': 'collectionSubmission',
'doc': serialize_cgm(cgm),
'doc_as_upsert': True,
} for cgm in cgms)
try:
helpers.bulk(client(), actions or [], refresh=True, raise_on_error=False)
except helpers.BulkIndexError as e:
raise exceptions.BulkUpdateError(e.errors)