def _reload(self): pr = Project(path=self._job_project_path) self._job = pr.load(self._job_name) self._job.interactive_open() self._job.interactive_initialize_interface() self._job.calc_static() self._job.run(run_again=True)
def _initialize(self, ref_job_full_path, structure): loc = self.get_graph_location() name = loc + '_job' project_path, ref_job_path = split(ref_job_full_path) pr = Project(path=project_path) ref_job = pr.load(ref_job_path) job = ref_job.copy_to(project=pr, new_job_name=name, input_only=True, new_database_entry=True) if structure is not None: job.structure = structure if isinstance(job, GenericInteractive): job.interactive_open() if isinstance(job, LammpsInteractive) and self._fast_lammps_mode: # Note: This might be done by default at some point in LammpsInteractive, and could then be removed here job.interactive_flush_frequency = 10**10 job.interactive_write_frequency = 10**10 self._disable_lmp_output = True job.calc_static() job.run(run_again=True) # TODO: Running is fine for Lammps, but wasteful for DFT codes! Get the much cheaper interface # initialization working -- right now it throws a (passive) TypeError due to database issues else: raise TypeError('Job of class {} is not compatible.'.format( ref_job.__class__)) self._job = job self._job_name = name self._job_project_path = project_path
def command_line(argv): """ Parse the command line arguments. Args: argv: Command line arguments """ input_path = None output_path = None try: opts, args = getopt.getopt(argv, "i:o:h", ["input_path=", "output_path=", "help"]) except getopt.GetoptError: print( 'python -m pyiron.base.job.reloadfile -i <inputpath> -o <outputpath>' ) sys.exit() else: for opt, arg in opts: if opt in ("-i", "--input_path"): input_path = os.path.abspath(arg) if opt in ("-o", "--output_path"): output_path = os.path.abspath(arg) with h5py.File(input_path, 'r') as f: job_name = list(f.keys())[0] project_path = os.path.join(os.path.abspath('.'), job_name + '.h5') shutil.copy(input_path, project_path) file = os.path.basename(project_path) job_name = os.path.splitext(file)[0] db_project_path = s.top_path(project_path) project = os.path.dirname(project_path) db_project = (project + '/').replace(db_project_path, '') job_reload = Project(project).load_from_jobpath(job_id=None, db_entry={ 'id': 1000, 'status': '', 'chemicalformula': '', 'job': job_name, 'subjob': '/' + job_name, 'projectpath': db_project_path, 'project': db_project, 'hamilton': '', 'hamversion': '', 'parentid': None, 'masterid': None }, convert_to_object=True) job_reload.status.initialized = True job_reload.server.run_mode.modal = True job_reload.run() shutil.copy(project_path, output_path) sys.exit()
def command_line(argv): """ Parse the command line arguments. Args: argv: Command line arguments """ input_path = None output_path = None try: opts, args = getopt.getopt(argv, "i:o:h", ["input_path=", "output_path=", "help"]) except getopt.GetoptError: print( "python -m pyiron.base.job.reloadfile -i <inputpath> -o <outputpath>" ) sys.exit() else: for opt, arg in opts: if opt in ("-i", "--input_path"): input_path = os.path.abspath(arg) if opt in ("-o", "--output_path"): output_path = os.path.abspath(arg) with h5py.File(input_path, "r") as f: job_name = list(f.keys())[0] project_path = os.path.join(os.path.abspath("."), job_name + ".h5") shutil.copy(input_path, project_path) file = os.path.basename(project_path) job_name = os.path.splitext(file)[0] db_project_path = s.top_path(project_path) project = os.path.dirname(project_path) db_project = (project + "/").replace(db_project_path, "") job_reload = Project(project).load_from_jobpath( job_id=None, db_entry={ "id": 1000, "status": "", "chemicalformula": "", "job": job_name, "subjob": "/" + job_name, "projectpath": db_project_path, "project": db_project, "hamilton": "", "hamversion": "", "parentid": None, "masterid": None, }, convert_to_object=True, ) job_reload.status.initialized = True job_reload.server.run_mode.modal = True job_reload.run() shutil.copy(project_path, output_path) sys.exit()
import sys from pyiron import Project, __version__ pr = Project("tests/static/backwards/") for job in pr.iter_jobs(recursive=True, convert_to_object=False): if job.name == "sphinx": job = job.to_object() job.run() print("job {} loaded from {}".format(job.id, sys.argv[0]))
def tearDownClass(cls): cls.execution_path = os.path.dirname(os.path.abspath(__file__)) project = Project(os.path.join(cls.execution_path, "test_project")) project.remove_jobs_silently(recursive=True) project.remove(enable=True)
def setUpClass(cls): cls.execution_path = os.path.dirname(os.path.abspath(__file__)) # print(cls.execution_path) cls.project = Project(os.path.join(cls.execution_path, "test_project"))
import sys from pyiron import Project, __version__ pr = Project( "tests/static/backwards/V{}".format(__version__).replace(".", "_") ) structure = pr.create_ase_bulk("Al") job = pr.create_job(pr.job_type.Sphinx, "sphinx") job.structure = structure job.save() print("job {} saved from {}".format(job.id, sys.argv[0]))