Skip to content

Instantly share code, notes, and snippets.

@dannon
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannon/e71b7aa9546fcecf6e9e to your computer and use it in GitHub Desktop.
Save dannon/e71b7aa9546fcecf6e9e to your computer and use it in GitHub Desktop.
MAX_META_SIZE = 2000000
ids = sa_session.execute("select id from history_dataset_association where length(metadata) > %s" % MAX_META_SIZE)
ids = [id for id in ids]
print len(ids), " large metadata blobs detected"
for id in ids:
id = id['id']
# Let's see what keys we have.
data = sa_session.query(galaxy.model.HistoryDatasetAssociation).get(id)
for name, spec in data.metadata.spec.items():
# We need to be careful about the attributes we are resetting!
if name in ['bam_header', 'read_groups', 'reference_lengths', 'reference_names']:
print "Stripped %s from hda %s" % (name, id)
del data._metadata[name]
sa_session.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment