pyiron_base.jobs.flex.factory module
- pyiron_base.jobs.flex.factory.create_job_factory(executable_str, write_input_funct=None, collect_output_funct=None, default_input_dict=None)
Create a new job class based on pre-defined write_input() and collect_output() function plus a dictionary of default inputs and an executable string.
- Parameters:
executable_str (str) – Call to an external executable
write_input_funct (callable) – The write input function write_input(input_dict, working_directory)
collect_output_funct (callable) – The collect output function collect_output(working_directory)
default_input_dict (dict/None) – Default input for the newly created job class
Example:
>>> def write_input(input_dict, working_directory="."): >>> with open(os.path.join(working_directory, "input_file"), "w") as f: >>> f.write(str(input_dict["energy"])) >>> >>> >>> def collect_output(working_directory="."): >>> with open(os.path.join(working_directory, "output_file"), "r") as f: >>> return {"energy": float(f.readline())} >>> >>> >>> from pyiron_base import Project, create_job_factory >>> pr = Project("test") >>> create_catjob = create_job_factory( >>> write_input_funct=write_input, >>> collect_output_funct=collect_output, >>> default_input_dict={"energy": 1.0}, >>> executable_str="cat input_file > output_file", >>> ) >>> job = create_catjob(project=pr, job_name="job_test") >>> job.input["energy"] = 2.0 >>> job.run() >>> job.output