Example #1
0
def test_getjobs(nprocs=8, njobs=20):
  """ Test scheduling. """
  from pylada.jobfolder.jobfolder import JobFolder
  from pylada.process.pool import PoolProcess
  from pylada import default_comm
  from functional import Functional

  root = JobFolder()
  for n in xrange(njobs):
    job = root / "a{0}".format(n)
    job.functional = Functional("whatever", [n])
    job.params['sleep'] = 1

  comm = default_comm.copy()
  comm['n'] = nprocs
  def processalloc(job):
    """ returns a random number between 1 and 4 included. """
    from random import randint
    return randint(1, comm['n'])

  for j in xrange(100):
    program = PoolProcess(root, processalloc=processalloc, outdir="whatever")
    program._comm = comm
    for i in xrange(1000):
      jobs = program._getjobs()
      assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
             (jobs, [program._alloc[u] for u in jobs])
Example #2
0
def test_failures():
  """ Tests whether scheduling jobs works on known failure cases. """
  from pylada.jobfolder.jobfolder import JobFolder
  from pylada.process.pool import PoolProcess
  from pylada import default_comm
  from functional import Functional
  root = JobFolder()
  for n in xrange(8):
    job = root / "a{0}".format(n)
    job.functional = Functional("whatever", [n])
    job.params['sleep'] = 1

  comm = default_comm.copy()
  comm['n'] = 4

  d = {'a1': 1, 'a0': 3, 'a3': 3, 'a2': 3, 'a5': 3, 'a4': 2, 'a7': 2, 'a6': 1}
  def processalloc_test1(job):  return d[job.name[1:-1]]

  program = PoolProcess(root, processalloc=processalloc_test1,
          outdir="whatever")
  program._comm = comm
  for i in xrange(10000):
    jobs = program._getjobs()
    assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
           (jobs, [program._alloc[u] for u in jobs])
Example #3
0
def test_getjobs(nprocs=8, njobs=20):
    """ Test scheduling. """
    from pylada.jobfolder.jobfolder import JobFolder
    from pylada.process.pool import PoolProcess
    from pylada import default_comm
    from functional import Functional

    root = JobFolder()
    for n in xrange(njobs):
        job = root / "a{0}".format(n)
        job.functional = Functional("whatever", [n])
        job.params['sleep'] = 1

    comm = default_comm.copy()
    comm['n'] = nprocs

    def processalloc(job):
        """ returns a random number between 1 and 4 included. """
        from random import randint
        return randint(1, comm['n'])

    for j in xrange(100):
        program = PoolProcess(root,
                              processalloc=processalloc,
                              outdir="whatever")
        program._comm = comm
        for i in xrange(1000):
            jobs = program._getjobs()
            assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
                   (jobs, [program._alloc[u] for u in jobs])
Example #4
0
def test_failures(d):
    """ Tests whether scheduling jobs works on known failure cases. """
    from pylada.jobfolder.jobfolder import JobFolder
    from pylada.process.pool import PoolProcess
    from pylada import default_comm
    from functional import Functional
    root = JobFolder()
    for n in xrange(8):
        job = root / "a{0}".format(n)
        job.functional = Functional("whatever", [n])
        job.params['sleep'] = 1

    comm = default_comm.copy()
    comm['n'] = 4

    def processalloc_test1(job):
        return d[job.name[1:-1]]

    program = PoolProcess(root,
                          processalloc=processalloc_test1,
                          outdir="whatever")
    program._comm = comm
    for i in xrange(10000):
        jobs = program._getjobs()
        assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
               (jobs, [program._alloc[u] for u in jobs])
Example #5
0
def test_getjobs(comm, tmpdir, executable, nprocs, njobs):
    """ Test scheduling. """
    root = jobfolders(executable, 0, 8)

    def processalloc(job):
        """ returns a random number between 1 and 4 included. """
        from random import randint
        return randint(1, comm['n'])

    for j in range(100):
        program = PoolProcess(root, processalloc=processalloc, outdir=str(tmpdir))
        program._comm = comm
        for i in range(1000):
            jobs = program._getjobs()
            assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
                (jobs, [program._alloc[u] for u in jobs])
Example #6
0
def test_failures(tmpdir, executable, comm):
    """Tests whether scheduling jobs works on known failure cases."""
    from pylada import default_comm
    root = jobfolders(executable, 0, 8)

    def processalloc_test1(job):
        d = {'1': 1, '0': 3, '3': 3, '2': 3, '5': 3, '4': 2, '7': 2, '6': 1}
        return d[job.name[1:-1]]

    program = PoolProcess(root,
                          processalloc=processalloc_test1,
                          outdir=str(tmpdir))
    program._comm = comm
    for i in range(10000):
        jobs = program._getjobs()
        assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
            (jobs, [program._alloc[u] for u in jobs])
Example #7
0
def test_failures(tmpdir, executable, comm):
    """ Tests whether scheduling jobs works on known failure cases. """
    from pylada import default_comm
    from pylada.process.tests.functional import Functional
    root = jobfolders(executable, 0, 8)

    def processalloc_test1(job):
        d = {'1': 1, '0': 3, '3': 3, '2': 3, '5': 3, '4': 2, '7': 2, '6': 1}
        return d[job.name[1:-1]]

    program = PoolProcess(root, processalloc=processalloc_test1,
                          outdir=str(tmpdir))
    program._comm = comm
    for i in range(10000):
        jobs = program._getjobs()
        assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
            (jobs, [program._alloc[u] for u in jobs])
Example #8
0
def test_getjobs(comm, tmpdir, executable, nprocs, njobs):
    """Test scheduling."""
    root = jobfolders(executable, 0, 8)

    def processalloc(job):
        """returns a random number between 1 and 4 included."""
        from random import randint
        return randint(1, comm['n'])

    for j in range(100):
        program = PoolProcess(root,
                              processalloc=processalloc,
                              outdir=str(tmpdir))
        program._comm = comm
        for i in range(1000):
            jobs = program._getjobs()
            assert sum(program._alloc[u] for u in jobs) <= program._comm['n'],\
                (jobs, [program._alloc[u] for u in jobs])