Last active
August 29, 2015 14:25
-
-
Save dannon/e71b7aa9546fcecf6e9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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