Example #1
0
def getInstance():
    """Make an instance of the relevant MPI class. Also set the RM instance"""
    scriptname, mpi, found_mpi = whatMPI(sys.argv[0])

    ismpirun = scriptname == 'mpirun'

    mo = MympirunOption(ismpirun=ismpirun)

    if mo.args is None or len(mo.args) == 0:
        mo.parser.print_shorthelp()
        raise ExitException("Exit no args provided")

    sched, found_sched = whatSched(getattr(mo.options, 'schedtype', None))

    found_mpi_names = [x.__name__ for x in found_mpi]
    found_sched_names = [x.__name__ for x in found_sched]

    if mo.options.showmpi:
        setLogLevelInfo()
        _logger.info("Found MPI classes %s" % (", ".join(found_mpi_names)))
        raise ExitException("Exit from showmpi")

    if mo.options.showsched:
        setLogLevelInfo()
        _logger.info("Found Sched classes %s" % (", ".join(found_sched_names)))
        raise ExitException("Exit from showsched")

    if mpi is None:
        mo.parser.print_shorthelp()
        mo.log.raiseException((
            "No MPI class found (scriptname %s; ismpirun %s). Please use mympirun through one "
            "of the direct calls or make sure the mpirun command can be found. "
            "Found MPI %s") % (scriptname, ismpirun,
                               ", ".join(found_mpi_names)))
    else:
        mo.log.debug("Found MPI class %s (scriptname %s; ismpirun %s)" %
                     (mpi.__name__, scriptname, ismpirun))

    if sched is None:
        mo.log.raiseException(
            "No sched class found (options.schedtype %s ; found Sched classes %s)"
            % (mo.options.schedtype, ", ".join(found_sched_names)))
    else:
        mo.log.debug(
            "Found sched class %s from options.schedtype %s (all Sched found %s)"
            % (sched.__name__, mo.options.schedtype,
               ", ".join(found_sched_names)))

    class M(mpi, sched):
        """Temporary class to couple MPI and local sched"""
        def __init__(self, **kwargs):
            self.log = getLogger("%s_%s" % (mpi.__name__, sched.__name__))
            super(M, self).__init__(**kwargs)

    return M(options=mo.options, cmdargs=mo.args)
Example #2
0
def getInstance():
    """Make an instance of the relevant MPI class. Also set the RM instance"""
    scriptname, mpi, found_mpi = whatMPI(sys.argv[0])

    ismpirun = scriptname == 'mpirun'

    mo = MympirunOption(ismpirun=ismpirun)

    if mo.args is None or len(mo.args) == 0:
        mo.parser.print_shorthelp()
        raise ExitException("Exit no args provided")


    sched, found_sched = whatSched(getattr(mo.options, 'schedtype', None))

    found_mpi_names = [x.__name__ for x in found_mpi]
    found_sched_names = [x.__name__ for x in found_sched]

    if mo.options.showmpi:
        setLogLevelInfo()
        _logger.info("Found MPI classes %s" % (", ".join(found_mpi_names)))
        raise ExitException("Exit from showmpi")

    if mo.options.showsched:
        setLogLevelInfo()
        _logger.info("Found Sched classes %s" % (", ".join(found_sched_names)))
        raise ExitException("Exit from showsched")

    if mpi is None:
        mo.parser.print_shorthelp()
        mo.log.raiseException(("No MPI class found (scriptname %s; ismpirun %s). Please use mympirun through one "
                               "of the direct calls or make sure the mpirun command can be found. "
                               "Found MPI %s") % (scriptname, ismpirun, ", ".join(found_mpi_names)))
    else:
        mo.log.debug("Found MPI class %s (scriptname %s; ismpirun %s)" % (mpi.__name__, scriptname, ismpirun))

    if sched is None:
        mo.log.raiseException("No sched class found (options.schedtype %s ; found Sched classes %s)" %
                              (mo.options.schedtype, ", ".join(found_sched_names)))
    else:
        mo.log.debug("Found sched class %s from options.schedtype %s (all Sched found %s)" %
                     (sched.__name__, mo.options.schedtype, ", ".join(found_sched_names)))

    class M(mpi, sched):
        """Temporary class to couple MPI and local sched"""
        def __init__(self, **kwargs):
            self.log = getLogger("%s_%s" % (mpi.__name__, sched.__name__))
            super(M, self).__init__(**kwargs)

    return M(options=mo.options, cmdargs=mo.args)
Example #3
0
    def _stream_stdouterr(self, isstdout=True, expect_match=True):
        fd, logfn = tempfile.mkstemp()
        # fh will be checked
        fh = os.fdopen(fd, "w")

        _stdout = sys.stdout
        _stderr = sys.stderr

        if isstdout == expect_match:
            sys.stdout = fh
            sys.stderr = open(os.devnull, "w")
        else:
            sys.stdout = open(os.devnull, "w")
            sys.stderr = fh

        fancylogger.setLogLevelInfo()
        name = "test_stream_stdout"
        lh = fancylogger.logToScreen(stdout=isstdout)
        logger = fancylogger.getLogger(name)
        # logfn makes it unique
        msg = "TEST isstdout %s expect_match %s logfn %s" % (isstdout, expect_match, logfn)
        logger.info(msg)

        # restore
        fancylogger.logToScreen(enable=False, handler=lh)
        sys.stdout = _stdout
        sys.stderr = _stderr

        fh2 = open(logfn)
        txt = fh2.read().strip()
        fh2.close()
        reg_exp = re.compile(r"INFO\s+\S+.%s.%s\s+\S+\s+%s" % (name, "_stream_stdouterr", msg))
        match = reg_exp.search(txt) is not None
        self.assertEqual(match, expect_match)

        try:
            fh.close()
            os.remove(logfn)
        except:
            pass
     help="Choose the user to link to (default hpcugent).")
parser.add_option("-r", "--repo", action="store", dest="repo",
     help="Choose the branch to link to (default easybuild-easyconfigs).")
parser.add_option("-p", "--path", action="store", dest="path",
     help="Specify a path inside the repo (default easybuild/easyconfigs).")
parser.add_option("-l", "--local", action="store_true", dest="local",
     help="Use a local path, not on github.com (Default false)")

options, args = parser.parse_args()

# get and configure logger
log = fancylogger.getLogger(__name__)
if options.verbose == 1:
    fancylogger.setLogLevelWarning()
elif options.verbose == 2:
    fancylogger.setLogLevelInfo()
elif options.verbose >= 3:
    fancylogger.setLogLevelDebug()

if options.quiet:
    fancylogger.logToScreen(False)
else:
    fancylogger.logToScreen(True)

# other options
if not options.branch:
    options.branch = "develop"
if not options.username:
    options.username = "******"
if not options.repo:
    options.repo = "easybuild-easyconfigs"
Example #5
0
    dest="path",
    help="Specify a path inside the repo (default easybuild/easyconfigs).")
parser.add_option("-l",
                  "--local",
                  action="store_true",
                  dest="local",
                  help="Use a local path, not on github.com (Default false)")

options, args = parser.parse_args()

# get and configure logger
log = fancylogger.getLogger(__name__)
if options.verbose == 1:
    fancylogger.setLogLevelWarning()
elif options.verbose == 2:
    fancylogger.setLogLevelInfo()
elif options.verbose >= 3:
    fancylogger.setLogLevelDebug()
if options.quiet:
    fancylogger.logToScreen(False)
else:
    fancylogger.logToScreen(True)

# other options
if not options.branch:
    options.branch = "develop"
if not options.username:
    options.username = "******"
if not options.repo:
    options.repo = "easybuild-easyconfigs"
if not options.path:
Example #6
0
        next_idx = (idx + 1) % len(recvbuf)
        if recvbuf[idx]['hostname'] == recvbuf[next_idx]['hostname']:
            if not recvbuf[idx]['affinity'][
                    -1] == recvbuf[next_idx]['affinity'][0] - 1:
                log.error(
                    "No nn on same node for rank %s (aff %s) and next rank %s (aff %s)"
                    % (idx, recvbuf[idx]['affinity'], next_idx,
                       recvbuf[next_idx]['affinity']))
        else:
            if not recvbuf[next_idx]['affinity'][0] == 0:
                log.error(
                    "No nn on different nodes for rank %s (hn %s aff %s) and next rank %s (hn %s aff %s)"
                    % (idx, recvbuf[idx]['hostname'], recvbuf[idx]['affinity'],
                       next_idx, recvbuf[next_idx]['hostname'],
                       recvbuf[next_idx]['affinity']))


if __name__ == '__main__':
    log = getLogger('mympisanity')
    setLogLevelInfo()
    log.info("mympisanity started")

    comm = MPI.COMM_WORLD

    ## gather the info from all processes
    recvbuf = comm.gather(Report(), 0)
    log.info("mympisanity gather report finished")

    if comm.rank == 0:
        check()
Example #7
0
    ## check for mapping
    for idx, x in enumerate(recvbuf):
        next_idx = (idx + 1) % len(recvbuf)
        if recvbuf[idx]['hostname'] == recvbuf[next_idx]['hostname']:
            if not recvbuf[idx]['affinity'][-1] == recvbuf[next_idx]['affinity'][0] - 1:
                log.error("No nn on same node for rank %s (aff %s) and next rank %s (aff %s)" %
                          (idx, recvbuf[idx]['affinity'], next_idx, recvbuf[next_idx]['affinity']))
        else:
            if not recvbuf[next_idx]['affinity'][0] == 0:
                log.error("No nn on different nodes for rank %s (hn %s aff %s) and next rank %s (hn %s aff %s)" %
                           (idx, recvbuf[idx]['hostname'], recvbuf[idx]['affinity'],
                            next_idx, recvbuf[next_idx]['hostname'], recvbuf[next_idx]['affinity'])
                          )


if __name__ == '__main__':
    log = getLogger('mympisanity')
    setLogLevelInfo()
    log.info("mympisanity started")

    comm = MPI.COMM_WORLD

    ## gather the info from all processes
    recvbuf = comm.gather(Report(), 0)
    log.info("mympisanity gather report finished")


    if comm.rank == 0:
        check()