Exemplo n.º 1
0
def test_phony_force_stale(tmpdir):
    """Make a missing file phony and force it to stale."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])
    d.phony('3')

    all = '1 2 3 4 5 6 7'.split()
    touch(all, 0)
    delete('3')
    d.stale('3')
    d.run()

    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 0, '6': 1, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])
    d.phony('3')

    all = '1 2 3 4 5 6 7'.split()
    touch(all, 0)
    delete('3')
    d.stale('4')
    d.run()

    truth = {'1': 1, '2': 0, '3': 1, '4': 1, '5': 0, '6': 1, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth
Exemplo n.º 2
0
def test_hash(): 
  """Check stale when file hashes change."""
  import dagger
  all = '1 2 3 4 5 6 7'.split()
  fill(all,'')
  
  db = dagger.hashdb('tmp.db')
  for f in all: db.update(f)
  db.export()

  fill(['5'], 'test')
  
  d = dagger.dagger('tmp.db')
  d.hashall = True
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  
  d.run()
  truth = {'1':1, '2':0, '3':1, '4':0, '5':1, '6':1, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  return 1
Exemplo n.º 3
0
def test_run_allpaths():
  """Check all graph paths possible."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])

  all = '1 2 3 4 5 6 7'.split()
  fill(all)
  
  d.run(allpaths=True)
  
  truth = {
  '1': None,
  '2':[['1']],
  '3':[['1'], ['6']],
  '4':[['3','1'], ['3','6']],
  '5':[['3','1'], ['3','6']],
  '6': None,
  '7':[['6']],
  }
  if not paths_equal(d, all, truth):
    return False
  
  return True
Exemplo n.º 4
0
def draw_graph(nodes, filename):
    dag = dagger.dagger()
    _recursive_add(dag, nodes)
    dag.run()
    dotfile = "{}.dot".format(filename)
    dag.dot(dotfile)
    os.system("dot -Tpng {} > {}.png".format(dotfile, filename))
Exemplo n.º 5
0
def test_phony_hash(tmpdir):
    """Make a missing file phony and ensure stale by stale child (that had old hash)."""
    os.chdir(tmpdir)

    all = '1 2 3 4 5 6 7'.split()
    fill(all, '')

    db = dagger.hashdb('tmp.db')
    for f in all:
        db.update(f)
    db.export()

    fill(['4'], 'test')

    d = dagger.dagger('tmp.db')
    d.hashall = True
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])
    d.phony('6')
    d.run()

    truth = {'1': 1, '2': 0, '3': 1, '4': 1, '5': 0, '6': 1, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth
Exemplo n.º 6
0
def test_missing():
  import os, dagger
  
  # Create empty files.
  fill(['1','2','3'])
  
  # Ensure missing file.
  try: os.remove('missing')
  except: pass
  
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('2', ['missing'])
  d.run(allpaths=True)
  
  it = d.iter()
  next = []

  items = it.next()
  next.extend(items)
  if items: it.remove(items[0])

  items = it.next()
  next.extend(items)
  if items: it.remove(items[0])

  items = it.next()
  next.extend(items)
  if items: it.remove(items[0])
  
  return next == ['missing','2','1']
Exemplo n.º 7
0
def test_iterator(names=[], remove='', nexts=[]):
  import dagger
  
  d = dagger.dagger()
  d.add('1', ['2','3','4'])
  d.add('4', ['5','6'])
  d.add('7', ['6'])
  d.stale('5')
  d.stale('6')
  d.run(allpaths=True)
  
  remove = remove.split()
  
  it = d.iter(names)
  next = it.next(2)
  while remove:
    if next != nexts[0]: return False
    
    try:
      name = remove.pop(0)
      nexts.pop(0)
      it.remove(name)
    except: return False
    
    next = it.next(2)
  
  return True
Exemplo n.º 8
0
def test_phony_hash():
  """Make a missing file phony and ensure stale by stale child (that had old hash)."""
  import dagger
  all = '1 2 3 4 5 6 7'.split()
  fill(all,'')
  
  db = dagger.hashdb('tmp.db')
  for f in all: db.update(f)
  db.export()

  fill(['4'], 'test')
  
  d = dagger.dagger('tmp.db')
  d.hashall = True
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  d.phony('6')
  d.run()
  
  truth = {'1':1, '2':0, '3':1, '4':1, '5':0, '6':1, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  return 1
Exemplo n.º 9
0
def test_run_paths():
  """Check graph depth-first path for each node."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])

  all = '1 2 3 4 5 6 7'.split()
  fill(all)
  d.run(allpaths=False)
  
  truth = {
  '1': None,
  '2':[['1']],
  '3':[['1'], ['6']],
  '4':[['3','1']],
  '5':[['3','1']],
  '6': None,
  '7':[['6']],
  }
  if not paths_equal(d, all, truth):
    return False
  
  return True
Exemplo n.º 10
0
    def __init__(self):
        if not os.path.exists(ROOT):
            os.makedirs(ROOT)
        self.dag = dagger()
        self._ran = False

        with self.dependency_db() as db:
            for key, dependencies in db.items():
                self.dag.add(key, dependencies)
Exemplo n.º 11
0
def test_pathnames():
    d = dagger.dagger()
    d.add('1', ['2', '3'])
    n1 = d.get('1')
    n2 = d.get('2')
    n3 = d.get('3')
    n1.paths = [[n2, n3]]
    p = d.pathnames('1')
    assert p and p == [['2', '3']]
Exemplo n.º 12
0
def test_pathnames():
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  n1 = d.get('1')
  n2 = d.get('2')
  n3 = d.get('3')
  n1.paths = [ [n2,n3] ]
  p = d.pathnames('1'); #print p
  return p and p == [['2','3']]
Exemplo n.º 13
0
def test_force(allpaths=False):
  """Check forcing staleness."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])

  all = '1 2 3 4 5 6 7'.split()
  touch(all)
  
  d.resetnodes()
  d.stale('1',1)
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  touch(all)
  d.resetnodes()
  d.forced.clear()
  d.stale('2',1)
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':1, '3':0, '4':0, '5':0, '6':0, '7':0}
  states2 = stale_dict(d, all)
  if states2 != truth:
    print('states2 =',states2,'<>\ntruth   =',truth,'\n')
    return False
  
  touch(all)
  d.resetnodes()
  d.forced.clear()
  d.stale('3',1)
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':1, '4':0, '5':0, '6':1, '7':0}
  states3 = stale_dict(d, all)
  if states3 != truth:
    print('states3 =',states3,'<>\ntruth   =',truth,'\n')
    return False

  touch(all)
  d.resetnodes()
  d.forced.clear()
  d.stale('5',1)
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':1, '4':0, '5':1, '6':1, '7':0}
  states4 = stale_dict(d, all)
  if states4 != truth:
    print('states4 =',states4,'<>\ntruth   =',truth,'\n')
    return False
  
  return True
Exemplo n.º 14
0
def test_phony_force_stale():
  """Make a missing file phony and force it to stale."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  d.phony('3')
  
  all = '1 2 3 4 5 6 7'.split()
  touch(all,0)
  delete('3')
  d.stale('3')
  d.run()
  
  truth = {'1':1, '2':0, '3':1, '4':0, '5':0, '6':1, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  d.phony('3')
  
  all = '1 2 3 4 5 6 7'.split()
  touch(all,0)
  delete('3')
  d.stale('4')
  d.run()
  
  truth = {'1':1, '2':0, '3':1, '4':1, '5':0, '6':1, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  return 1
Exemplo n.º 15
0
def test_run_order():
  """Check graph walk order."""  
  import dagger
  all = '1 2 3 4 5 6 7'.split()
  fill(all)
  
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  d.run(allpaths=False)
  names = [n.name for n in d.order.list]; #print names
  return names == '2 4 5 3 1 7 6'.split()
Exemplo n.º 16
0
def test_run_order(tmpdir):
    """Check graph walk order."""
    os.chdir(tmpdir)

    all = '1 2 3 4 5 6 7'.split()
    fill(all)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])
    d.run(allpaths=False)
    names = [n.name for n in d.order.list]
    assert names == '2 4 5 3 1 7 6'.split()
Exemplo n.º 17
0
def main():
    dag = dagger.dagger()
    course_file = open(COURSE_JSON_DIR, "r")
    data = json.load(course_file)
    course_file.close()

    # Add nodes and others they depend on
    for course in data["COURSES"]:
        dag.add(course["CODE"], course["PREREQ"])

    # Evaluate the graph
    dag.run()

    # Export for visualizing
    dag.dot(RESULT_DIR)
    dot_file_fixes()
    export()
Exemplo n.º 18
0
def test_hash_missing(tmpdir):
    """Check stale when file hashes missing."""
    os.chdir(tmpdir)

    d = dagger.dagger('tmp.missing')
    d.hashall = True
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    fill(all)

    d.run()
    truth = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states = stale_dict(d, all)
    assert states == truth
Exemplo n.º 19
0
def test_force(tmpdir, allpaths=False):
    """Check forcing staleness."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    touch(all)

    d.resetnodes()
    d.stale('1', 1)
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth

    touch(all)
    d.resetnodes()
    d.forced.clear()
    d.stale('2', 1)
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 1, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states2 = stale_dict(d, all)
    assert states2 == truth

    touch(all)
    d.resetnodes()
    d.forced.clear()
    d.stale('3', 1)
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 0, '6': 1, '7': 0}
    states3 = stale_dict(d, all)
    assert states3 == truth

    touch(all)
    d.resetnodes()
    d.forced.clear()
    d.stale('5', 1)
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 1, '6': 1, '7': 0}
    states4 = stale_dict(d, all)
    assert states4 == truth
Exemplo n.º 20
0
def test_phony_time(tmpdir):
    """Make a missing file phony and ensure stale by stale child (that had older child)."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])
    d.phony('6')

    all = '1 2 3 4 5 6 7'.split()
    touch(all, 0)
    touch('4', 1)
    d.run()

    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 0, '6': 1, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth
Exemplo n.º 21
0
def test_iter():
  import dagger
  
  d = dagger.dagger()
  d.add('1', ['2','3','4'])
  d.add('4', ['5','6'])
  d.stale('6')
  d.run(allpaths=True)
  
  iter = d.iter()
  ldict = iter.ldict  
  
  for name in '1 4 6'.split():
    if not ldict.get( d.nodes[name] ): return False
  
  for name in '2 3 5'.split():
    if ldict.get( d.nodes[name] ): return False
  
  return True
Exemplo n.º 22
0
def test_hash_missing(): 
  """Check stale when file hashes missing."""
  import dagger
  d = dagger.dagger('tmp.missing')
  d.hashall = True
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])

  all = '1 2 3 4 5 6 7'.split()
  fill(all)

  d.run()
  truth = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0}
  states = stale_dict(d, all)
  if states != truth:
    print(states,'<>\n',truth,'\n')
    return False

  return 1
Exemplo n.º 23
0
def test_dot():
  """Test exporting dot graph file."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  
  all = '1 2 3 4 5 6 7'.split()
  fill(all)
  touch(all,0)
  touch('5')

  f = 'tmp.dot'
  d.run()
  d.dot(out=f, color=1)
  
  import os
  if not os.path.exists(f): return False
  text = open(f).read()
  return ('1 [fillcolor = "#ff' in text) and ('3 [fillcolor = "#ff' in text) and ('6 [fillcolor = "#ff' in text) and ('5 [fillcolor = white]' in text)
Exemplo n.º 24
0
def test_phony_time():
  """Make a missing file phony and ensure stale by stale child (that had older child)."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  d.phony('6')
  
  all = '1 2 3 4 5 6 7'.split()
  touch(all,0)
  touch('4',1)
  d.run()
  
  truth = {'1':1, '2':0, '3':1, '4':0, '5':0, '6':1, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth:
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False

  return 1
Exemplo n.º 25
0
def test_top_stale():
  import os, dagger
  
  all = '1 2 3 4 5 6'.split() 
  touch(all,0)
  
  # Ensure missing file.
  delete('missing')
  
  try: os.remove('6')
  except: pass

  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('2', ['missing'])
  d.add('4', ['5'])
  d.add('5', ['6'])
  d.run(allpaths=True)
  
  it = d.iter(['4'])
  
  return it.next() == ['4']
Exemplo n.º 26
0
def test_run_paths(tmpdir):
    """Check graph depth-first path for each node."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    fill(all)
    d.run(allpaths=False)

    truth = {
        '1': None,
        '2': [['1']],
        '3': [['1'], ['6']],
        '4': [['3', '1']],
        '5': [['3', '1']],
        '6': None,
        '7': [['6']],
    }
    assert paths_equal(d, all, truth)
Exemplo n.º 27
0
def test_top_fresh():
  import os, dagger
  
  all = '1 2 3 4 5 6'.split() 
  touch(all,0)
  
  # Ensure missing file.
  delete('missing')
  
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('2', ['missing'])
  d.add('4', ['5'])
  d.add('5', ['6'])
  d.run(allpaths=True)
  
  it = d.iter(['4'])
  next4 = it.next()

  it = d.iter(['2'])
  next2 = it.next()

  return not next4 and next2 
Exemplo n.º 28
0
def test_run_allpaths(tmpdir):
    """Check all graph paths possible."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    fill(all)

    d.run(allpaths=True)

    truth = {
        '1': None,
        '2': [['1']],
        '3': [['1'], ['6']],
        '4': [['3', '1'], ['3', '6']],
        '5': [['3', '1'], ['3', '6']],
        '6': None,
        '7': [['6']],
    }
    assert paths_equal(d, all, truth)
Exemplo n.º 29
0
def test_dot(tmpdir):
    """Test exporting dot graph file."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    fill(all)
    touch(all, 0)
    touch('5')

    f = 'tmp.dot'
    d.run()
    d.dot(out=f, color=1)

    assert os.path.exists(f)
    text = open(f).read()
    assert '1 [fillcolor = "#ff' in text
    assert '3 [fillcolor = "#ff' in text
    assert '6 [fillcolor = "#ff' in text
    assert '5 [fillcolor = white]' in text
Exemplo n.º 30
0
def test_hash(tmpdir):
    """Check stale when file hashes change."""
    os.chdir(tmpdir)

    all = '1 2 3 4 5 6 7'.split()
    fill(all, '')

    db = dagger.hashdb('tmp.db')
    for f in all:
        db.update(f)
    db.export()

    fill(['5'], 'test')

    d = dagger.dagger('tmp.db')
    d.hashall = True
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    d.run()
    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 1, '6': 1, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth
Exemplo n.º 31
0
opt = GetOpt()
allpaths = opt.get('allpaths')
hash = opt.get('hash')
hashsql = opt.get('hashsql')
cross = opt.get('cross')
levels = int(opt.get('levels'))
dot = opt.get('dot')
width = int(opt.get('width'))

tBuild = 0
tRun = 0

# ---------------------------------------------------------------------
# Build basic graph.
tic = time.clock()
dag = dagger.dagger()

nInner = sum([width**i for i in range(1, levels)])
nOuter = width**levels  # Leaves.
print(f'nodes: inner={nInner} outer={nOuter} total={nInner+nOuter}')

# Add nodes with children.
for p in range(0, nInner):
    dag.add(str(p), map(str, children(p, width)))

# Force last node stale to get side effects.
dag.stale(str(nInner + nOuter - 1))

# Add optional cross links so graph isn't simple k-trees.
if cross:
    for p in range(0, nInner):
Exemplo n.º 32
0
def test_time(allpaths=False):
  """Check stale when file timestamps are old."""
  import dagger
  d = dagger.dagger()
  d.add('1', ['2','3'])
  d.add('3', ['4','5'])
  d.add('6', ['3','7'])
  
  all = '1 2 3 4 5 6 7'.split()
  fill(all)
  touch(all,0)
  touch('1')

  d.run(allpaths=allpaths)
  truth = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0}
  states1 = stale_dict(d, all)
  if states1 != truth: 
    print('states1 =',states1,'<>\ntruth   =',truth,'\n')
    return False
  
  touch(all,0)
  touch('2')

  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0}
  states2 = stale_dict(d, all)
  if states2 != truth:
    print('states2 =',states2,'<>\ntruth   =',truth,'\n')
    return False
  
  touch(all,0)
  touch('3')

  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':0, '4':0, '5':0, '6':1, '7':0}
  states3 = stale_dict(d, all)
  if states3 != truth:
    print('states3 =',states3,'<>\ntruth   =',truth,'\n')
    return False

  touch(all,0)
  touch('4')

  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':1, '4':0, '5':0, '6':1, '7':0}
  states4 = stale_dict(d, all)
  if states4 != truth:
    print('states4 =',states4,'<>\ntruth   =',truth,'\n')
    return False

  touch(all,0)
  touch('5')

  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':1, '2':0, '3':1, '4':0, '5':0, '6':1, '7':0}
  states5 = stale_dict(d, all)
  if states5 != truth:
    print('states5 =',states5,'<>\ntruth   =',truth,'\n')
    return False

  touch(all,0)
  touch('6')
  
  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0}
  states6 = stale_dict(d, all)
  if states6 != truth:
    print('states6 =',states6,'<>\ntruth   =',truth,'\n')
    return False

  touch(all,0)
  touch('7')

  d.resetnodes()
  d.run(allpaths=allpaths)
  truth = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':1, '7':0}
  states7 = stale_dict(d, all)
  if states7 != truth:
    print('states7 =',states7,'<>\ntruth   =',truth,'\n')
    return False

  return True
Exemplo n.º 33
0
try:
    import dagger
    from joblib import Parallel, delayed
    import subprocess
    import multiprocessing
    import os

    outDir = os.environ["DOXYGEN_NOTEBOOK_PATH_PARALLEL"]

    inputs = [input.replace("../../tutorials/", "") for input in subprocess.check_output(["grep",  "-r",  "-l", "/// \\\\notebook\|## \\\\notebook", os.path.expandvars("$DOXYGEN_SOURCE_DIRECTORY/tutorials")]).split()]

    dependenciesgraph = dagger.dagger()

    for element in inputs:
        dependenciesgraph.add(element)

    dependenciesgraph.add("math/testUnfold5d.C",["math/testUnfold5c.C"])
    dependenciesgraph.add("math/testUnfold5c.C",["math/testUnfold5b.C"])
    dependenciesgraph.add("math/testUnfold5b.C",["math/testUnfold5a.C"])
    dependenciesgraph.add("xml/xmlreadfile.C",["xml/xmlnewfile.C"])
    dependenciesgraph.add("roofit/rf503_wspaceread.C",["roofit/rf502_wspacewrite.C"])
    dependenciesgraph.add("io/readCode.C",["io/importCode.C"])
    dependenciesgraph.add("fit/fit1.C",["hist/fillrandom.C"])
    dependenciesgraph.add("fit/myfit.C",["fit/fitslicesy.C"])
    dependenciesgraph.add("foam/foam_demopers.C",["foam/foam_demo.C"])
    dependenciesgraph.add("tree/staff.C",["tree/cernbuild.C"])
    dependenciesgraph.add("tree/cernstaff.C",["tree/cernbuild.C"])
    dependenciesgraph.add("hist/hbars.C",["tree/cernbuild.C"])
    dependenciesgraph.add("pyroot/ntuple1.py",["pyroot/hsimple.py"])
    dependenciesgraph.add("pyroot/h1draw.py",["pyroot/hsimple.py"])
    dependenciesgraph.add("pyroot/fit1.py",["pyroot/fillrandom.py"])
Exemplo n.º 34
0
######################################################################
opt = GetOpt()
allpaths = opt.get('allpaths')
hash = opt.get('hash')
hashsql = opt.get('hashsql')
cross = opt.get('cross')
levels = int( opt.get('levels') )
dot = opt.get('dot')
width = int( opt.get('width') )

tBuild, tRun = 0,0

#---------------------------------------------------------------------
# Build basic graph.
tic = time.clock()
dag = dagger.dagger()

nInner = sum([width**i for i in range(1,levels)])
nOuter = width**levels # Leaves.
print('nodes: inner=%s outer=%s total=%s' % (str(nInner), str(nOuter), str(nInner+nOuter)))

# Add nodes with children.
for p in range(0,nInner):
  dag.add( str(p), list(map(str, children(p, width))) )

# Force last node stale to get side effects.
dag.stale(str(nInner+nOuter-1))

# Add optional cross links so graph isn't simple k-trees.
if cross:
  for p in range(0,nInner):
Exemplo n.º 35
0
    from joblib import Parallel, delayed
    import subprocess
    import multiprocessing
    import os

    outDir = os.environ["DOXYGEN_NOTEBOOK_PATH_PARALLEL"]

    inputs = [
        input.replace("../../tutorials/", "")
        for input in subprocess.check_output([
            "grep", "-r", "-l", "/// \\\\notebook\|## \\\\notebook",
            os.path.expandvars("$DOXYGEN_SOURCE_DIRECTORY/tutorials")
        ]).split()
    ]

    dependenciesgraph = dagger.dagger()

    for element in inputs:
        dependenciesgraph.add(element)

    dependenciesgraph.add("math/testUnfold5d.C", ["math/testUnfold5c.C"])
    dependenciesgraph.add("math/testUnfold5c.C", ["math/testUnfold5b.C"])
    dependenciesgraph.add("math/testUnfold5b.C", ["math/testUnfold5a.C"])
    dependenciesgraph.add("xml/xmlreadfile.C", ["xml/xmlnewfile.C"])
    dependenciesgraph.add("roofit/rf503_wspaceread.C",
                          ["roofit/rf502_wspacewrite.C"])
    dependenciesgraph.add("io/readCode.C", ["io/importCode.C"])
    dependenciesgraph.add("fit/fit1.C", ["hist/fillrandom.C"])
    dependenciesgraph.add("fit/myfit.C", ["fit/fitslicesy.C"])
    dependenciesgraph.add("foam/foam_demopers.C", ["foam/foam_demo.C"])
    dependenciesgraph.add("tree/staff.C", ["tree/cernbuild.C"])
Exemplo n.º 36
0
 def draw(self, graph, filename):
     dag = dagger.dagger()
     self.recursive_add(dag, graph.sources)
     dag.run()
     dot_filename = "{}.dot".format(filename)
     dag.dot(dot_filename)
Exemplo n.º 37
0
def test_time(tmpdir, allpaths=False):
    """Check stale when file timestamps are old."""
    os.chdir(tmpdir)

    d = dagger.dagger()
    d.add('1', ['2', '3'])
    d.add('3', ['4', '5'])
    d.add('6', ['3', '7'])

    all = '1 2 3 4 5 6 7'.split()
    fill(all)
    touch(all, 0)
    touch('1')

    d.run(allpaths=allpaths)
    truth = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states1 = stale_dict(d, all)
    assert states1 == truth

    touch(all, 0)
    touch('2')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states2 = stale_dict(d, all)
    assert states2 == truth

    touch(all, 0)
    touch('3')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 0, '4': 0, '5': 0, '6': 1, '7': 0}
    states3 = stale_dict(d, all)
    assert states3 == truth

    touch(all, 0)
    touch('4')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 0, '6': 1, '7': 0}
    states4 = stale_dict(d, all)
    assert states4 == truth

    touch(all, 0)
    touch('5')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 1, '2': 0, '3': 1, '4': 0, '5': 0, '6': 1, '7': 0}
    states5 = stale_dict(d, all)
    assert states5 == truth

    touch(all, 0)
    touch('6')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 0, '7': 0}
    states6 = stale_dict(d, all)
    assert states6 == truth

    touch(all, 0)
    touch('7')

    d.resetnodes()
    d.run(allpaths=allpaths)
    truth = {'1': 0, '2': 0, '3': 0, '4': 0, '5': 0, '6': 1, '7': 0}
    states7 = stale_dict(d, all)
    assert states7 == truth