Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance File Management in store_dft_output #433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions flare/learners/otf.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,17 +595,20 @@ def run_dft(self):
# specified in self.store_dft_output
if self.store_dft_output is not None:
dest = self.store_dft_output[1]
# Ensure the destination directory exists; create it if it doesn't
os.makedirs(dest, exist_ok=True)
target_files = self.store_dft_output[0]
now = datetime.now()
dt_string = now.strftime("%Y.%m.%d:%H:%M:%S:")
if isinstance(target_files, str):
to_copy = [target_files]
else:
to_copy = target_files
# Create a new subfolder under the destination directory named after the current step
new_folder = os.path.join(dest, str(self.curr_step))
os.makedirs(new_folder, exist_ok=True)
for ofile in to_copy:
# if the file is in a subdirectory like dft/OUTCAR, then copy it out
filename = ofile.split("/")[-1]
copyfile(ofile, dest + "/" + dt_string + filename)
# Copy the file to the new folder, preserving its original file name
copyfile(ofile, os.path.join(new_folder, filename))
self.dft_frames.append(self.curr_step)
self.output.write_wall_time(tic, task="Run DFT")

Expand Down
Loading