Skip to content

Commit

Permalink
Update to glue_tasks.py
Browse files Browse the repository at this point in the history
When using CopyVaspOutputs to copy very large files, like the WAVECAR, current code is both slow and fails to unzip files. Suggested changed to copy_files is faster and does not fail when unzipping large files.
  • Loading branch information
tboland1 authored Aug 9, 2019
1 parent 53f05fa commit dbc3094
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions atomate/vasp/firetasks/glue_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
flow of the workflow, e.g. tasks to check stability or the gap is within a certain range.
"""

import shutil
import gzip
import os
import re
Expand Down Expand Up @@ -128,11 +129,8 @@ def copy_files(self):
# unzip the .gz if needed
if gz_ext in ['.gz', ".GZ"]:
# unzip dest file
f = gzip.open(dest_path + gz_ext, 'rt')
file_content = f.read()
with open(dest_path, 'w') as f_out:
f_out.writelines(file_content)
f.close()
with open(dest_path, 'wb') as f_out, gzip.open(dest_path + gz_ext, 'rb') as f_in:
shutil.copyfileobj(f_in, f_out)
os.remove(dest_path + gz_ext)


Expand Down

0 comments on commit dbc3094

Please sign in to comment.