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

Add write_input() before transferring files to remote #1511

Merged
merged 10 commits into from
Jul 5, 2024
17 changes: 12 additions & 5 deletions pyiron_base/jobs/job/runfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,16 @@ def write_input_files_from_input_dict(input_dict: dict, working_directory: str):
input_dict (dict): hierarchical input dictionary with files_to_create and files_to_copy.
working_directory (str): path to the working directory
"""
for file_name, content in input_dict["files_to_create"].items():
with open(os.path.join(working_directory, file_name), "w") as f:
f.writelines(content)
for file_name, source in input_dict["files_to_copy"].items():
shutil.copy(source, os.path.join(working_directory, file_name))
if len(os.listdir(working_directory)) == 0:
for file_name, content in input_dict["files_to_create"].items():
with open(os.path.join(working_directory, file_name), "w") as f:
f.writelines(content)
for file_name, source in input_dict["files_to_copy"].items():
shutil.copy(source, os.path.join(working_directory, file_name))
else:
state.logger.info(
"The working directory is not empty, assuming that input has already been written."
)


class CalculateFunctionCaller:
Expand Down Expand Up @@ -493,6 +498,8 @@ def run_job_with_runmode_queue(job):
+ job.project_hdf5.h5_path
+ " --submit"
)
job.project_hdf5.create_working_directory()
job.write_input()
state.queue_adapter.transfer_file_to_remote(
file=job.project_hdf5.file_name, transfer_back=False
)
Expand Down
Loading