Ejemplo n.º 1
0
def main():
    """Execution of the SCOOP module. Parses its command-line arguments and
    launch needed resources."""
    # Generate a argparse parser and parse the command-line arguments
    parser = makeParser()
    args = parser.parse_args()

    # Get a list of resources to launch worker(s) on
    hosts = utils.getHosts(args.hostfile, args.hosts)

    if args.n:
        n = args.n
    else:
        n = utils.getWorkerQte(hosts)
    assert n >= 0, (
            "Scoop couldn't determine the number of worker to start.\n"
            "Use the '-n' flag to set it manually."
    )

    if not args.external_hostname:
        args.external_hostname = [utils.externalHostname(hosts)]

    # Launch SCOOP
    thisScoopApp = ScoopApp(hosts, n, args.b,
                            args.verbose if not args.quiet else 0,
                            args.python_interpreter,
                            args.external_hostname[0],
                            args.executable, args.args, args.tunnel,
                            args.path, args.debug, args.nice,
                            utils.getEnv(), args.profile, args.pythonpath[0],
                            args.prolog[0], args.backend, args.rsh,
                            args.ssh_executable)

    rootTaskExitCode = False
    interruptPreventer = Thread(target=thisScoopApp.close)
    try:
        rootTaskExitCode = thisScoopApp.run()
    except Exception as e:
        logging.error('Error while launching SCOOP subprocesses:')
        logging.error(traceback.format_exc())
        rootTaskExitCode = -1
    finally:
        # This should not be interrupted (ie. by a KeyboadInterrupt)
        # The only cross-platform way to do it I found was by using a thread.
        interruptPreventer.start()
        interruptPreventer.join()

    # Exit with the proper exit code
    if rootTaskExitCode:
        sys.exit(rootTaskExitCode)
Ejemplo n.º 2
0
def main():
    """Execution of the SCOOP module. Parses its command-line arguments and
    launch needed resources."""
    # Generate a argparse parser and parse the command-line arguments
    parser = makeParser()
    args = parser.parse_args()

    # Get a list of resources to launch worker(s) on
    hosts = utils.getHosts(args.hostfile, args.hosts)

    if args.n:
        n = args.n
    else:
        n = utils.getWorkerQte(hosts)
    assert n >= 0, (
            "Scoop couldn't determine the number of worker to start.\n"
            "Use the '-n' flag to set it manually."
    )

    if not args.external_hostname:
        args.external_hostname = [utils.externalHostname(hosts)]

    # Launch SCOOP
    thisScoopApp = ScoopApp(hosts, n, args.b,
                            args.verbose if not args.quiet else 0,
                            args.python_interpreter,
                            args.external_hostname[0],
                            args.executable, args.args, args.tunnel,
                            args.path, args.debug, args.nice,
                            utils.getEnv(), args.profile, args.pythonpath[0],
                            args.prolog[0], args.backend, args.rsh)

    rootTaskExitCode = False
    interruptPreventer = Thread(target=thisScoopApp.close)
    try:
        rootTaskExitCode = thisScoopApp.run()
    except Exception as e:
        logging.error('Error while launching SCOOP subprocesses:')
        logging.error(traceback.format_exc())
        rootTaskExitCode = -1
    finally:
        # This should not be interrupted (ie. by a KeyboadInterrupt)
        # The only cross-platform way to do it I found was by using a thread.
        interruptPreventer.start()
        interruptPreventer.join()

    # Exit with the proper exit code
    if rootTaskExitCode:
        sys.exit(rootTaskExitCode)
Ejemplo n.º 3
0
 def test_getWorkerQtePBS(self):
     os.environ.update(PBS_ENV)
     self.assertEqual(utils.getWorkerQte(utils.getHosts()), 16)
Ejemplo n.º 4
0
 def test_getWorkerQteFile(self):
     self.assertEqual(utils.getWorkerQte(utils.getHosts("hostfilesim.txt")), 16)
Ejemplo n.º 5
0
 def test_getWorkerQteFile(self):
     self.assertEqual(utils.getWorkerQte(utils.getHosts("hostfilesim.txt")),
                      16)
Ejemplo n.º 6
0
 def test_getWorkerQteSGE(self):
     os.environ.update(SGE_ENV)
     self.assertEqual(utils.getWorkerQte(utils.getHosts()), 16)