From dbc30945473c2afc9d54b7da21669664828c77fa Mon Sep 17 00:00:00 2001 From: Tara Maria Boland Date: Fri, 9 Aug 2019 10:57:14 -0700 Subject: [PATCH] Update to glue_tasks.py 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. --- atomate/vasp/firetasks/glue_tasks.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/atomate/vasp/firetasks/glue_tasks.py b/atomate/vasp/firetasks/glue_tasks.py index f708a43e2..fb5578757 100644 --- a/atomate/vasp/firetasks/glue_tasks.py +++ b/atomate/vasp/firetasks/glue_tasks.py @@ -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 @@ -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)