Skip to content

Commit

Permalink
Another attempt to tacke out-of-memory issue on export
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Jun 7, 2017
1 parent d76ac9e commit d05f75e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions website/imports/mutations/__init__.py
Expand Up @@ -280,6 +280,8 @@ def export(self, path=None, only_primary_isoforms=False):
from tqdm import tqdm
export_time = datetime.utcnow()

tick = 0

if not path:
directory = os.path.join('exported', 'mutations')
os.makedirs(directory, exist_ok=True)
Expand Down Expand Up @@ -308,6 +310,7 @@ def export(self, path=None, only_primary_isoforms=False):
f.write('\t'.join(header))

for mutation in tqdm(self.model.query, total=fast_count(db.session.query(self.model))):
tick += 1

m = mutation.mutation

Expand Down Expand Up @@ -348,6 +351,13 @@ def export(self, path=None, only_primary_isoforms=False):

f.write('\n' + '\t'.join(data))

del data

del mutation
if tick % 1000 == 0:
import gc
gc.collect()

def get_or_make_mutation(self, pos, protein_id, alt, is_ptm):
mutation_id = self.base_importer.get_or_make_mutation(
pos, protein_id, alt, is_ptm
Expand Down

0 comments on commit d05f75e

Please sign in to comment.