Commit 6a4fef6e authored by Patrick Shriwise's avatar Patrick Shriwise
Browse files

Adding option to perform run from a specified directory.

parent b859a84f
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
from numbers import Integral
from pathlib import Path
import os
import subprocess

import pygriffin.checkvalue as cv
@@ -24,10 +25,15 @@ class PyGriffin:
        self.n_procs = n_procs
        self.n_threads = n_threads

    def run(self):
    def run(self, cwd=None):
        """
        Execute Griffin

        Parameters
        ----------
        cwd : str or Path
            Directory from which to run Griffin

        Returns
        -------
        int
@@ -47,12 +53,18 @@ class PyGriffin:
        if self.n_threads > 1:
            cmd.append('--n-threads={}'.format(self.n_threads))

        p = subprocess.Popen(cmd, universal_newlines=True)
        cwd = Path(cwd)
        if not cwd.is_dir():
            msg = ("Specified working directory "
            "doesn't exist: {}".format(cwd))
            raise ValueError(msg)

        p = subprocess.Popen(cmd, universal_newlines=True, cwd=str(cwd))

        return p.wait()

    def __call__(self):
        return self.run()
    def __call__(self, cwd=None):
        return self.run(cwd)

    @property
    def input(self):