コード例 #1
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)
コード例 #2
0
    def __init__(
        self,
        working_directory,
        job_id=None,
        hdf5_file=None,
        h5_path=None,
        submit_on_remote=False,
        debug=False,
        connection_string=None,
    ):
        self.working_directory = working_directory
        self._remote_flag = submit_on_remote
        if connection_string is not None:
            state.database.open_local_sqlite_connection(
                connection_string=connection_string)
        pr = Project(path=os.path.join(working_directory, "..", ".."))
        if job_id is not None:
            self.job = pr.load(int(job_id))
        else:
            projectpath = state.database.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)