Beispiel #1
0
    def __init__(self, hosts, n, b, verbose, python_executable,
                 externalHostname, executable, arguments, tunnel, path, debug,
                 nice, env, profile, pythonPath, prolog, backend, rsh):
        # Assure setup sanity
        assert type(hosts) == list and hosts, (
            "You should at least specify one host.")
        self.workersLeft = n if n > 0 else len(hosts)
        self.createdSubprocesses = []

        # launch information
        self.python_executable = python_executable[0]
        self.pythonpath = pythonPath
        self.prolog = prolog
        self.n = n
        self.b = b
        self.tunnel = tunnel
        self.executable = executable
        self.args = arguments
        self.verbose = verbose
        self.path = path
        self.debug = debug
        self.nice = nice
        self.profile = profile
        self.backend = backend
        self.rsh = rsh
        self.errors = None

        # Logging configuration
        if self.verbose > 3:
            self.verbose = 3

        scoop.logger = utils.initLogging(
            verbosity=self.verbose,
            name="launcher",
        )

        # Show runtime information (useful for debugging)
        scoop.logger.info(
            "SCOOP {0} {1} on {2} using Python {3}, API: {4}".format(
                scoop.__version__,
                scoop.__revision__,
                sys.platform,
                sys.version.replace("\n", ""),
                sys.api_version,
            ))

        if env in ["SLURM", "PBS", "SGE"]:
            scoop.logger.info("Detected {0} environment.".format(env))
        scoop.logger.info("Deploying {0} worker(s) over {1} "
                          "host(s).".format(n, len(hosts)))

        # Handling External Hostname
        self.externalHostname = '127.0.0.1' if self.tunnel else externalHostname
        scoop.logger.debug('Using hostname/ip: "{0}" as external broker '
                           'reference.'.format(self.externalHostname))
        scoop.logger.debug(
            'The python executable to execute the program with is: '
            '{0}.'.format(self.python_executable))

        # Create launch lists
        self.broker_hosts = self.divideHosts(hosts[:], self.b)
        self.worker_hosts = self.divideHosts(hosts, self.n)

        # Logging of worker distribution warnings
        maximumWorkers = sum(host[1] for host in hosts)
        if self.n > maximumWorkers:
            scoop.logger.debug(
                "The -n flag is set at {0} workers, which is higher than the "
                "maximum number of workers ({1}) specified by the hostfile.\n"
                "This behavior may degrade the performances of scoop for "
                "cpu-bound operations.".format(qty, maximumWorkers))
        elif self.n < maximumWorkers and self.n > 0:
            scoop.logger.debug(
                "The -n flag is set at {0} workers, which is lower than the "
                "maximum number of workers ({1}) specified by the hostfile."
                "".format(qty, maximumWorkers))

        # Display
        self.showHostDivision(headless=not executable)

        self.workers = []
        self.brokers = []
Beispiel #2
0
    def __init__(self, hosts, n, b, verbose, python_executable,
            externalHostname, executable, arguments, tunnel, path, debug,
            nice, env, profile, pythonPath, prolog, backend, rsh):
        # Assure setup sanity
        assert type(hosts) == list and hosts, (
            "You should at least specify one host.")
        self.workersLeft = n if n > 0 else len(hosts)
        self.createdSubprocesses = []

        # launch information
        self.python_executable = python_executable[0]
        self.pythonpath = pythonPath
        self.prolog = prolog
        self.n = n
        self.b = b
        self.tunnel = tunnel
        self.executable = executable
        self.args = arguments
        self.verbose = verbose
        self.path = path
        self.debug = debug
        self.nice = nice
        self.profile = profile
        self.backend = backend
        self.rsh = rsh
        self.errors = None

        # Logging configuration
        if self.verbose > 3:
            self.verbose = 3

        scoop.logger = utils.initLogging(
            verbosity=self.verbose,
            name="launcher",
        )

        # Show runtime information (useful for debugging)
        scoop.logger.info("SCOOP {0} {1} on {2} using Python {3}, API: {4}".format(
                scoop.__version__,
                scoop.__revision__,
                sys.platform,
                sys.version.replace("\n", ""),
                sys.api_version,
            )
        )

        if env in ["SLURM","PBS", "SGE"]:
            scoop.logger.info("Detected {0} environment.".format(env))
        scoop.logger.info("Deploying {0} worker(s) over {1} "
                      "host(s).".format(
                          n,
                          len(hosts)
                      )
        )

        # Handling External Hostname
        self.externalHostname = '127.0.0.1' if self.tunnel else externalHostname
        scoop.logger.debug('Using hostname/ip: "{0}" as external broker '
                      'reference.'.format(self.externalHostname))
        scoop.logger.debug('The python executable to execute the program with is: '
                     '{0}.'.format(self.python_executable))

        # Create launch lists
        self.broker_hosts = self.divideHosts(hosts[:], self.b)
        self.worker_hosts = self.divideHosts(hosts, self.n)

        # Logging of worker distribution warnings
        maximumWorkers = sum(host[1] for host in hosts)
        if self.n > maximumWorkers:
            scoop.logger.debug(
                "The -n flag is set at {0} workers, which is higher than the "
                "maximum number of workers ({1}) specified by the hostfile.\n"
                "This behavior may degrade the performances of scoop for "
                "cpu-bound operations.", self.n, maximumWorkers
            )
        elif self.n < maximumWorkers and self.n > 0:
            scoop.logger.debug(
                "The -n flag is set at {0} workers, which is lower than the "
                "maximum number of workers ({1}) specified by the hostfile.",
                self.n, maximumWorkers
            )

        # Display
        self.showHostDivision(headless=not executable)

        self.workers = []
        self.brokers = []