예제 #1
0
    def run_local_mode(self):
        """
        Runs this module in local mode.
        At this point arguments from cmd where parsed and converted.
        We create command arguments and prepare threads.

        If we need to run multiple jobs (for example cpu specification required
        to run this command using 1 AND 2 CPU) we call method run_local_mode_one
        repeatedly otherwise only once
        :rtype: PyPy
        """
        total = len(self.proc)
        result = ResultHolder()

        if total == 1:
            pypy = self.run_local_mode_one(self.proc[0])
            result.add(pypy)
        else:
            # optionally we use counter
            progress = ProgressCounter('Running {:02d} of {total:02d}')
            for p in self.proc:
                progress.next(locals())
                Printer.all.sep()

                with Printer.all.with_level():
                    pypy = self.run_local_mode_one(p)
                result.add(pypy)
                Printer.all.sep()

        return result.singlify()
    def run_local_mode(self):
        """
        Runs this module in local mode.
        At this point arguments from cmd where parsed and converted.
        We create command arguments and prepare threads.

        If we need to run multiple jobs (for example cpu specification required
        to run this command using 1 AND 2 CPU) we call method run_local_mode_one
        repeatedly otherwise only once
        :rtype: PyPy
        """
        total = len(self.proc)
        result = ResultHolder()

        if total == 1:
            pypy = self.run_local_mode_one(self.proc[0])
            result.add(pypy)
        else:
            # optionally we use counter
            progress = ProgressCounter('Running {:02d} of {total:02d}')
            for p in self.proc:
                progress.next(locals())
                Printer.all.sep()

                with Printer.all.with_level():
                    pypy = self.run_local_mode_one(p)
                result.add(pypy)
                Printer.all.sep()

        return result.singlify()
예제 #3
0
def finish_pbs(multijob, finish_method):
    # first update to get more info about multijob jobs
    Printer.all.sep()
    Printer.all.out('Determining job status')
    multijob.update()

    # print jobs statuses
    with Printer.all.with_level():
        multijob.print_status()

    Printer.console.sep()
    Printer.console.dyn(multijob.get_status_line())
    result = ResultHolder()

    # use dynamic sleeper
    sleeper = DynamicSleep(min=300, max=5000, steps=5)

    # wait for finish
    while multijob.is_running():
        Printer.console.dyn('Updating job status')
        multijob.update()
        Printer.console.dyn(multijob.get_status_line())

        # if some jobs changed status add new line to dynamic output remains
        jobs_changed = multijob.get_all(status=JobState.COMPLETED)
        if jobs_changed:
            Printer.console.newline()
            Printer.all.sep()

        # get all jobs where was status update to COMPLETE state
        for job in jobs_changed:
            pypy = finish_method(job, not Printer.batched.is_muted())
            if pypy:
                result.add(pypy)

        if jobs_changed:
            Printer.console.newline()

        # after printing update status lets sleep for a bit
        if multijob.is_running():
            sleeper.sleep()

    Printer.all.sep()
    # print final result
    Printer.all.out(multijob.get_status_line())
    Printer.all.out('All jobs finished')

    return result, multijob
예제 #4
0
def finish_pbs(multijob, finish_method):
    # first update to get more info about multijob jobs
    Printer.all.sep()
    Printer.all.out('Determining job status')
    multijob.update()

    # print jobs statuses
    with Printer.all.with_level():
        multijob.print_status()

    Printer.console.sep()
    Printer.console.dyn(multijob.get_status_line())
    result = ResultHolder()

    # use dynamic sleeper
    sleeper = DynamicSleep(min=300, max=5000, steps=5)

    # wait for finish
    while multijob.is_running():
        Printer.console.dyn('Updating job status')
        multijob.update()
        Printer.console.dyn(multijob.get_status_line())

        # if some jobs changed status add new line to dynamic output remains
        jobs_changed = multijob.get_all(status=JobState.COMPLETED)
        if jobs_changed:
            Printer.console.newline()
            Printer.all.sep()

        # get all jobs where was status update to COMPLETE state
        for job in jobs_changed:
            pypy = finish_method(job, not Printer.batched.is_muted())
            if pypy:
                result.add(pypy)

        if jobs_changed:
            Printer.console.newline()

        # after printing update status lets sleep for a bit
        if multijob.is_running():
            sleeper.sleep()

    Printer.all.sep()
    # print final result
    Printer.all.out(multijob.get_status_line())
    Printer.all.out('All jobs finished')

    return result, multijob