Beispiel #1
0
 def tearDownClass(cls):
     file_location = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(file_location, 'testing_copyto'))
     sub_project = project.open('sub_project_ex')
     sub_project.remove(enable=True)
     sub_project = project.open('sub_project')
     sub_project.remove(enable=True)
Beispiel #2
0
    def __init__(self, working_directory, job_id, debug=False):
        self.working_directory = working_directory

        pr = Project(path=working_directory)
        self.job = pr.load(int(job_id))

        # setup logger
        self._logger = self.setup_logger(debug=debug)
Beispiel #3
0
 def test_Chemical_Element_to_and_from_hdf_with_None_Parent(self):
     pr = Project(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "test_periodic_table"))
     basis = CrystalStructure(element="Ni",
                              bravais_basis="fcc",
                              lattice_constant=3.7)
     ham = pr.create_job(pr.job_type.Lammps, "lammps_test_2")
     test_ham = pr.create_job(pr.job_type.Lammps, "lammps_test_2")
     ham.structure = basis
     ham.to_hdf()
     test_ham.from_hdf()
     self.assertEqual(test_ham["input/structure/species"][0],
                      ham["input/structure/species"][0])
     ham.remove()
Beispiel #4
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "wrapper_testing"))
     cls.job = cls.project.create_job("ExampleJob", "job_test_run")
     cls.job.input["count"] = 12
     cls.job.server.run_mode.manual = True
     cls.job.run()
Beispiel #5
0
    def __init__(self, db, job_id=None, db_entry=None, user=None):
        if not db_entry:
            db_entry = db.get_item_by_id(job_id)
        if db_entry is None:
            raise ValueError("job ID {0} does not exist!".format(job_id))

        job_name = db_entry["job"]

        h5_path = None
        sub_job = db_entry["subjob"]

        if sub_job is not None:
            if len(sub_job.strip()) > 0:
                h5_path = '/'.join(sub_job.split('/')[:-1])
        hdf5_file = sub_job.split('/')[1] + '.h5'

        gp = GenericPath(root_path=db_entry["projectpath"],
                         project_path=db_entry["project"])
        hdf_project = ProjectHDFio(project=Project(path=gp, user=user),
                                   file_name=hdf5_file,
                                   h5_path=h5_path,
                                   mode="r")
        super(JobPath, self).__init__(hdf_project, job_name)

        self.__name__ = db_entry["hamilton"]
        self.__version__ = db_entry["hamversion"]

        if 'id' in db_entry:
            self._job_id = db_entry["id"]
        self._status = db_entry["status"]
        self._master_id = db_entry["masterid"]
        self._parent_id = db_entry["parentid"]
Beispiel #6
0
 def setUpClass(cls):
     cls.count = 12
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, 'random_testing_non_modal'))
     cls.project.remove_jobs(recursive=True)
     cls.project.set_logging_level('INFO')
 def test_Chemical_Element_to_and_from_hdf(self):
     ni_up = self.pse.add_element("Ni", "Ni_up", spin="up")
     pr = Project(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'test_periodic_table'))
     basis = CrystalStructure(element=ni_up,
                              bravais_basis='fcc',
                              lattice_constant=3.7)
     ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_1')
     test_ham = pr.create_job(pr.job_type.Lammps, 'lammps_test_1')
     ham.structure = basis
     ham.to_hdf()
     test_ham.from_hdf()
     self.assertEqual(test_ham['input/structure/species'][0],
                      ham['input/structure/species'][0])
     ham.remove()
Beispiel #8
0
    def setUpClass(cls):
        cls.execution_path = os.path.dirname(os.path.abspath(__file__))
        cls.project = Project(os.path.join(cls.execution_path, "lammps"))

        structure = Atoms(
            symbols="Fe2",
            positions=np.outer(np.arange(2), np.ones(3)),
            cell=2 * np.eye(3),
        )

        cls.job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="lammps",
        )
        cls.job.server.run_mode.interactive = True
        cls.job.structure = structure

        cls.minimize_job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="minimize_lammps",
        )
        cls.minimize_control_job = Lammps(
            project=ProjectHDFio(project=cls.project, file_name="lammps"),
            job_name="minimize_control_lammps",
        )
Beispiel #9
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "lammps"))
     cls.job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="lammps",
     )
     cls.job_water = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_water"),
         job_name="lammps_water",
     )
     cls.job_water_dump = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_water_dump"),
         job_name="lammps_water_dump",
     )
     cls.job_dump = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_dump_static"),
         job_name="lammps_dump_static",
     )
     cls.job_vcsgc_input = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_vcsgc_input"),
         job_name="lammps_vcsgc_input",
     )
     cls.minimize_job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="minimize_lammps",
     )
     cls.minimize_control_job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="minimize_control_lammps",
     )
 def setUpClass(cls):
     cls.count = 12
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, 'random_testing'))
     cls.job = cls.project.create_job("ExampleJob", "job_test_run")
     cls.job.input['count'] = cls.count
     cls.job.run()
Beispiel #11
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_quickff"))
     cls.job = cls.project.create_job("QuickFF", "trial")
     cls.job_complete = QuickFF(
         project=ProjectHDFio(project=cls.project, file_name="quickff_complete"),
         job_name="quickff_complete",
     )
Beispiel #12
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location,
                                        'test_murnaghan'))
     cls.basis = CrystalStructure(element="Fe",
                                  bravais_basis='fcc',
                                  lattice_constant=3.5)
     cls.project.remove_jobs(recursive=True)
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, "testing_murnaghan_non_modal"))
     cls.basis = CrystalStructure(element="Fe",
                                  bravais_basis="bcc",
                                  lattice_constant=2.8)
     cls.project.remove_jobs(recursive=True)
Beispiel #14
0
    def __init__(self,
                 working_directory,
                 job_id=None,
                 hdf5_file=None,
                 h5_path=None,
                 submit_on_remote=False,
                 debug=False):
        self.working_directory = working_directory
        self._remote_flag = submit_on_remote
        pr = Project(path=os.path.join(working_directory, '..', '..'))
        if job_id is not None:
            self.job = pr.load(int(job_id))
        else:
            projectpath = s.top_path(hdf5_file)
            if projectpath is None:
                project = os.path.dirname(hdf5_file)
            else:
                project = os.path.relpath(os.path.dirname(hdf5_file),
                                          projectpath)
            job_name = h5_path[1:]
            self.job = pr.load_from_jobpath(
                job_id=None,
                db_entry={
                    "job":
                    job_name,
                    "subjob":
                    h5_path,
                    "projectpath":
                    projectpath,
                    "project":
                    project + '/',
                    "status":
                    get_job_status_from_file(hdf5_file=hdf5_file,
                                             job_name=job_name),
                    "hamilton":
                    get_hamilton_from_file(hdf5_file=hdf5_file,
                                           job_name=job_name),
                    "hamversion":
                    get_hamilton_version_from_file(hdf5_file=hdf5_file,
                                                   job_name=job_name)
                },
                convert_to_object=True)

        # setup logger
        self._logger = self.setup_logger(debug=debug)
Beispiel #15
0
 def setUpClass(cls):
     cls.count = 12
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, 'random_testing_atomistic'))
     cls.job = cls.project.create_job("AtomisticExampleJob", "job_test_atomistic_run")
     cls.job.input['count'] = cls.count
     cls.job.structure = Atoms(positions=[[0, 0, 0], [1, 1, 1]], elements=['Fe', 'Fe'], cell=2*np.eye(3))
     cls.job.interactive_open()
     cls.job.run()
Beispiel #16
0
    def _create_project_from_hdf5(self):
        """
        Internal function to create a pyiron project pointing to the directory where the HDF5 file is located.

        Returns:
            Project: pyiron project object
        """
        from pyiron.base.project.generic import Project
        return Project(path=self.file_path)
Beispiel #17
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "test_vasp"))
     cls.job = cls.project.create_job("Vasp", "trial")
     cls.job_complete = Vasp(
         project=ProjectHDFio(project=cls.project, file_name="vasp_complete"),
         job_name="vasp_complete",
     )
     poscar_file = posixpath.join(
         cls.execution_path, "../static/vasp_test_files/full_job_sample/POSCAR"
     )
     cls.job_complete.structure = read_atoms(poscar_file, species_from_potcar=True)
Beispiel #18
0
class TestProject(unittest.TestCase):
    def setUp(self):
        self.current_dir = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
        self.project = Project(os.path.join(self.current_dir, 'sub_folder'))

    def tearDown(self):
        self.project.remove(enable=True)

    def test_repr(self):
        self.assertEqual([], self.project.list_groups())
        pr_down_one = self.project['..']
        pr_down_two = self.project['../..']
        pr_down_twice = self.project['..']['..']
        self.assertEqual(pr_down_two.__repr__(), pr_down_twice.__repr__())
        self.assertEqual(sorted([directory for directory in os.listdir(self.current_dir)
                                 if not os.path.isfile(os.path.join(self.current_dir, directory))]),
                         pr_down_one.list_groups())
        self.assertEqual(sorted([directory for directory in os.listdir(os.path.join(self.current_dir, '..'))
                                 if not os.path.isfile(os.path.join(self.current_dir, '..', directory))]),
                         pr_down_two.list_groups())
        self.assertEqual(pr_down_two.list_groups(), pr_down_twice.list_groups())
Beispiel #19
0
 def tearDownClass(cls):
     # print('tear down')
     file_location = os.path.dirname(os.path.abspath(__file__))
     project = Project(
         os.path.join(file_location, 'random_testing_non_modal'))
     project.remove_jobs()
     project.remove(enable=True)
Beispiel #20
0
 def tearDownClass(cls):
     project = Project(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "random_testing"))
     job = project.load(project.get_job_ids()[0])
     job.remove()
     project.remove(enable=True)
Beispiel #21
0
 def tearDownClass(cls):
     project = Project(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      "hdf5_content"))
     ham = project.load(project.get_job_ids()[0])
     ham.remove()
     project.remove(enable=True)
Beispiel #22
0
 def setUpClass(cls):
     cls.count_run_one = 12
     cls.count_run_two = 12
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(
         os.path.join(cls.file_location, "random_testing_lib"))
     cls.ham = cls.project.create_job("ExampleJob", "job_test_run")
     cls.ham.input["count"] = cls.count_run_one
     cls.ham.server.run_mode.interactive = True
     cls.ham.run()
     cls.ham.input["count"] = cls.count_run_two
     cls.ham.run()
     cls.ham.interactive_close()
Beispiel #23
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, 'lammps'))
     cls.job = Lammps(project=ProjectHDFio(project=cls.project,
                                           file_name='lammps'),
                      job_name='lammps')
     cls.job_water = Lammps(project=ProjectHDFio(project=cls.project,
                                                 file_name='lammps_water'),
                            job_name='lammps_water')
     cls.job_water_dump = Lammps(project=ProjectHDFio(
         project=cls.project, file_name='lammps_water_dump'),
                                 job_name='lammps_water_dump')
     cls.job_dump = Lammps(project=ProjectHDFio(
         project=cls.project, file_name='lammps_dump_static'),
                           job_name='lammps_dump_static')
Beispiel #24
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, "lammps"))
     cls.job = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps"),
         job_name="lammps",
     )
     cls.job_water = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_water"),
         job_name="lammps_water",
     )
     cls.job_water_dump = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_water_dump"),
         job_name="lammps_water_dump",
     )
     cls.job_dump = Lammps(
         project=ProjectHDFio(project=cls.project, file_name="lammps_dump_static"),
         job_name="lammps_dump_static",
     )
Beispiel #25
0
    def __init__(self, job_path):
        job_path_lst = job_path.replace('\\', '/').split('.h5')
        if len(job_path_lst) != 2:
            raise ValueError

        sub_job = job_path_lst[1]
        h5_path = None
        if sub_job is not None:
            if len(sub_job.strip()) > 0:
                h5_path = '/'.join(sub_job.split('/')[:-1])

        hdf_project = ProjectHDFio(
            project=Project(os.path.dirname(job_path_lst[0])),
            file_name=job_path_lst[0].split('/')[-1] + '.h5',
            h5_path=h5_path,
            mode="r")
        super(JobPathBase,
              self).__init__(project=hdf_project,
                             job_name=job_path_lst[1].split('/')[-1])
Beispiel #26
0
 def test_hdf(self):
     pr = Project(self.file_location)
     file_name = os.path.join(self.file_location, 'genericpara.h5')
     hdf = ProjectHDFio(project=pr,
                        file_name=file_name,
                        h5_path="/test",
                        mode="a")
     hdf.create_group('test')
     self.generic_parameters_str.to_hdf(hdf=hdf, group_name='input')
     gp_reload = GenericParameters(table_name='str')
     gp_reload.from_hdf(hdf=hdf, group_name='input')
     self.assertEqual(gp_reload.get("par___1"), 1)
     self.assertEqual(gp_reload.get("par_2"), 'all')
     self.assertEqual(gp_reload.get("count"), 0)
     self.assertTrue(gp_reload.get("write_restart"))
     self.assertFalse(gp_reload.get("read_restart"))
     self.assertEqual(gp_reload.get("dict"), {"a": 1, "b": 2})
     self.assertEqual(gp_reload.get("list"), [1, "s"])
     os.remove(file_name)
Beispiel #27
0
 def tearDownClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     project = Project(os.path.join(cls.execution_path, 'lammps'))
     project.remove_jobs(recursive=True)
     project.remove(enable=True)
Beispiel #28
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, "hdf5_content"))
     cls.ham = cls.project.create_job("ExampleJob", "job_test_run")
     cls.ham.run()
Beispiel #29
0
 def setUpClass(cls):
     cls.execution_path = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.execution_path, 'lammps'))
     cls.job = Lammps(project=ProjectHDFio(project=cls.project, file_name='lammps'), job_name='lammps')
     cls.job.server.run_mode.interactive = True
     cls.job.structure = Atoms(symbols='Fe2', positions=np.outer(np.arange(2), np.ones(3)), cell=2*np.eye(3))
Beispiel #30
0
 def setUpClass(cls):
     cls.file_location = os.path.dirname(os.path.abspath(__file__))
     cls.project = Project(os.path.join(cls.file_location, 'random_testing'))
     cls.ham = cls.project.create_job("ExampleJob", "job_test_run")