示例#1
0
    def __init__(
        self, makefile_root_path: Optional[Path] = None, makefile_name: None = None
    ) -> None:
        """
        Call the make file.

        Parameters
        ----------
        makefile_root_path : None or Path or str
            Root path of make file
            If None, the path of the root caller of MakeProject will be called
        makefile_name : None or str
            If set to None, it tries the following names, in order:
            'GNUmakefile', 'makefile' and 'Makefile'
        """
        if makefile_root_path is None:
            makefile_root_path = get_caller_dir()
        self.makefile_root_path = Path(makefile_root_path)
        logging.debug("self.makefile_root_path set to %s", makefile_root_path)

        self.makefile_name = makefile_name

        self.makefile_path = get_makefile_path(
            self.makefile_root_path, self.makefile_name
        )
        self.exec_name = get_exec_name(self.makefile_path)
        self.submitter = LocalSubmitter(self.makefile_root_path)
示例#2
0
    def __init__(
        self,
        path: Optional[Path] = None,
        processor_split: Optional[ProcessorSplit] = None,
    ) -> None:
        """
        Set the path from where the calls are made from.

        Parameters
        ----------
        path : Path or str or None
            Directory to run the command from
            If None, the calling directory will be used
        processor_split : ProcessorSplit or None
            Object containing the processor split
            If None, default values will be used
        """
        # NOTE: We are not setting the default as a keyword argument
        #       as this would mess up the paths
        self.__path = Path(
            path).absolute() if path is not None else get_caller_dir()
        self.__process: Optional[subprocess.Popen] = None

        # Attributes with getters
        self.__pid: Optional[int] = None
        self.__return_code: Optional[int] = None
        self.__std_out: Optional[str] = None
        self.__std_err: Optional[str] = None

        self.processor_split = (processor_split if processor_split is not None
                                else ProcessorSplit())
示例#3
0
    def __init__(
        self,
        job_name: Optional[str] = None,
        store_dir: Optional[Path] = None,
        submission_dict: Optional[Dict[str, Optional[str]]] = None,
        processor_split: Optional[ProcessorSplit] = None,
    ) -> None:
        """
        Set the member data.

        Parameters
        ----------
        job_name : str or None
            Name of the job
            If None, a timestamp will be given as job_name
        store_dir : Path or None
            Directory to store the script
            If None, the caller directory will be used as the store directory
        submission_dict : None or dict of str of None or str
            Dict containing optional submission options
            One the form

            >>> {'walltime': None or str,
            ...  'mail': None or str,
            ...  'queue': None or str,
            ...  'account': None or str}

            These options will not be used if the submission_dict is None
        processor_split : ProcessorSplit or None
            Object containing the processor split
            If None, default values will be used
        """
        super().__init__(processor_split)
        if job_name is None:
            self._job_name = datetime.now().strftime("%m-%d-%Y_%H-%M-%S-%f")
        else:
            self._job_name = job_name

        if store_dir is None:
            self._store_dir = get_caller_dir()
        else:
            self._store_dir = store_dir
        self._submission_dict = (
            submission_dict.copy() if submission_dict is not None else dict()
        )
        submission_dict_keys = self._submission_dict.keys()
        for key in ("walltime", "mail", "queue", "account"):
            if key not in submission_dict_keys:
                self._submission_dict[key] = None

        self._log_and_error_base: Path = Path()
        self._waiting_for: List[str] = list()
        self._released = False

        # The following will be set by the implementations
        self._cluster_specific = {"cancel_str": "", "release_str": "", "submit_str": ""}
示例#4
0
    def __init__(
        self,
        run_path: Optional[Path] = None,
        processor_split: Optional[ProcessorSplit] = None,
    ) -> None:
        """
        Set the path from where the calls are made from.

        Parameters
        ----------
        run_path : Path or str or None
            Directory to run the command from
            If None, the calling directory will be used
        processor_split : ProcessorSplit or None
            Object containing the processor split
            If None, default values will be used
        """
        AbstractSubmitter.__init__(self, processor_split)
        # NOTE: We are not setting the default as a keyword argument
        #       as this would mess up the paths
        self.run_path = (Path(run_path).absolute()
                         if run_path is not None else get_caller_dir())
        self.__process: Optional[subprocess.Popen] = None
示例#5
0
    def create_db_path(name: Optional[str],
                       db_root_path: Optional[Path]) -> Path:
        """
        Create the database path.

        Parameters
        ----------
        name : str or None
            Name of the database (excluding .db)
            If set to None, the name of the caller directory will be used
        db_root_path : Path or str or None
            Path to database
            If None is set, the path will be set to $HOME/BOUT_db

        Returns
        -------
        db_path : Path
            Path to the database
        """
        if name is None:
            name = get_caller_dir().name

        if db_root_path is None:
            db_root_path = Path().home().joinpath("BOUT_db")

        db_root_path = Path(db_root_path)

        db_root_path.mkdir(exist_ok=True, parents=True)
        # NOTE: sqlite does not support schemas (except through an
        #       ephemeral ATTACH connection)
        #       Thus we will make one database per project
        # https://www.sqlite.org/lang_attach.html
        # https://stackoverflow.com/questions/30897377/python-sqlite3-create-a-schema-without-having-to-use-a-second-database
        db_path = db_root_path.joinpath(f"{name}.db")

        return db_path
示例#6
0
 def project_path(self, project_path: Optional[Union[Path, str]]) -> None:
     if project_path is None:
         project_path = get_caller_dir()
     project_path = Path(project_path).absolute()
     self.__project_path = project_path
     logging.debug("self.project_path set to %s", project_path)