Exemplo n.º 1
0
class LocalQAdapter(JobRunnerAdapter):
    """
    An implementation of `JobRunnerAdapter` running jobs through
    localq (a jobrunner which will schedule jobs on a single node).
    """

    @staticmethod
    def localq2arteria_status(status):
        """
        Convert a localq status to an arteria state
        :param status: to convert
        :return: the arteria state
        """

        if status == localqstatus.Status.COMPLETED:
            return arteria_state.DONE
        elif status == localqstatus.Status.FAILED:
            return arteria_state.ERROR
        elif status == localqstatus.Status.PENDING:
            return arteria_state.PENDING
        elif status == localqstatus.Status.RUNNING:
            return arteria_state.STARTED
        elif status == localqstatus.Status.CANCELLED:
            return arteria_state.CANCELLED
        elif status == localqstatus.Status.NOT_FOUND:
            return arteria_state.NONE
        else:
            return arteria_state.NONE

    # TODO Make configurable
    def __init__(self, nbr_of_cores, interval = 30, priority_method = "fifo"):
        self.nbr_of_cores = nbr_of_cores
        self.server = LocalQServer(nbr_of_cores, interval, priority_method)
        self.server.run()

    def start(self, cmd, nbr_of_cores, run_dir, stdout=None, stderr=None):
        return self.server.add(cmd, nbr_of_cores, run_dir, stdout=stdout, stderr=stderr)

    def stop(self, job_id):
        return self.server.stop_job_with_id(job_id)

    def stop_all(self):
        return self.server.stop_all_jobs()

    def status(self, job_id):
        return LocalQAdapter.localq2arteria_status(self.server.get_status(job_id))

    def status_all(self):
        jobs_and_status = {}
        for k, v in self.server.get_status_all().iteritems():
            jobs_and_status[k] = LocalQAdapter.localq2arteria_status(v)
        return jobs_and_status
Exemplo n.º 2
0
class LocalQAdapter(JobRunnerAdapter):
    """
    An implementation of `JobRunnerAdapter` running jobs through
    localq (a jobrunner which will schedule jobs on a single node).
    """

    @staticmethod
    def localq2arteria_status(status):
        """
        Convert a localq status to an arteria state
        :param status: to convert
        :return: the arteria state
        """

        if status == Status.COMPLETED:
            return arteria_state.DONE
        elif status == Status.FAILED:
            return arteria_state.ERROR
        elif status == Status.PENDING:
            return arteria_state.PENDING
        elif status == Status.RUNNING:
            return arteria_state.STARTED
        elif status == Status.CANCELLED:
            return arteria_state.CANCELLED
        elif status == Status.NOT_FOUND:
            return arteria_state.NONE
        else:
            return arteria_state.NONE

    # TODO Make configurable
    def __init__(self, nbr_of_cores, interval = 30, priority_method = "fifo"):
        self.nbr_of_cores = nbr_of_cores
        self.server = LocalQServer(nbr_of_cores, interval, priority_method)
        self.server.run()

    def start(self, cmd, nbr_of_cores, run_dir, stdout=None, stderr=None):
        return self.server.add(cmd, nbr_of_cores, run_dir, stdout=stdout, stderr=stderr)

    def stop(self, job_id):
        return self.server.stop_job_with_id(job_id)

    def stop_all(self):
        return self.server.stop_all_jobs()

    def status(self, job_id):
        return LocalQAdapter.localq2arteria_status(self.server.get_status(job_id))

    def status_all(self):
        jobs_and_status = {}
        for k, v in self.server.get_status_all().iteritems():
            jobs_and_status[k] = LocalQAdapter.localq2arteria_status(v)
        return jobs_and_status
Exemplo n.º 3
0
 def __init__(self, nbr_of_cores, interval = 30, priority_method = "fifo"):
     self.nbr_of_cores = nbr_of_cores
     self.server = LocalQServer(nbr_of_cores, interval, priority_method)
     self.server.run()
Exemplo n.º 4
0
 def __init__(self, nbr_of_cores, interval = 30, priority_method = "fifo"):
     self.nbr_of_cores = nbr_of_cores
     self.server = LocalQServer(nbr_of_cores, interval, priority_method)
     self.server.run()