def run(fileName=None, touch=False): # instantiate ADMIT a = ad.Admit() # Instantiate the class. This can be done in two ways, both will # work, it just depends if you need 'a0' ('i0' you always need) if True: # the AT, then the ATI a0 = File_AT() i0 = a.addtask(a0) else: # get the ATI via ADMIT, but then grab AT reference for convenience i0 = a.addtask(File_AT()) a0 = a[i0] # set some keys a0.setkey('file', fileName) a0.setkey('touch', False) a0.setkey('exist', True) # run the task(s). This also can be done in two ways. if False: # run only this one task, but it bypassed some checks in FlowManager # so for example, calling it twice, will run it twice # after running, explicit BDPs would need to be saved a0.run() a0[0].write() else: # run the whole ADMIT flow, although it's just one task (a0) # but calling it twice, 2nd run would not run the task since a.run() a.write()
if __name__ == '__main__': n = 3 touch = True subdir = False subdir = True # pick where admit will do its work, any cmdline argument will be the dirname if len(sys.argv) > 1: a = admit.Admit(sys.argv[1]) else: # or else the current directory a = admit.Admit() print 'Flow11: new admit?', a.new a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file', 'Flow1N.dat') a1.setkey('touch', touch) a2 = Flow1N_AT() i2 = a.addtask(a2, [(i1, 0)]) a2.setkey('n', n) a2.setkey('touch', touch) a2.setkey('subdir', subdir) # if True: # continue with a Flow11 for each BDP created by Flow1N from admit.at.Flow11_AT import Flow11_AT a.run() # need to run the flow, otherwise #BDP's unknown n1 = len(a2) # of course n1 = n, but we don't know this
if __name__ == '__main__': n = 3 touch = True subdir = False subdir = True # pick where admit will do its work, any cmdline argument will be the dirname if len(sys.argv) > 1: a = admit.Admit(sys.argv[1]) else: # or else the current directory a = admit.Admit() print 'Flow11: new admit?',a.new a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file','Flow1N.dat') a1.setkey('touch',touch) a2 = Flow1N_AT() i2 = a.addtask(a2, [(i1,0)]) a2.setkey('n',n) a2.setkey('touch',touch) a2.setkey('subdir',subdir) # if True: # continue with a Flow11 for each BDP created by Flow1N from admit.at.Flow11_AT import Flow11_AT a.run() # need to run the flow, otherwise #BDP's unknown n1 = len(a2) # of course n1 = n, but we don't know this
#!/usr/bin/env python import admit from admit.AT import AT import admit.Admit as admit import admit.util.bdp_types as bt import admit.util.PlotControl as pc # AT's we need (we normally don't need BDP's in user code such as this) from admit.at.Flow11_AT import Flow11_AT from admit.at.File_AT import File_AT a = admit.Admit("/tmp",name='testing plot type inheritance') a.plotparams(pc.NOPLOT,pc.PNG) f1 = File_AT(file="/tmp/deleteme_1",touch=False,exist=False) at1 = a.addtask(f1) f2=Flow11_AT(file="/tmp/deleteme_2",touch=False,exist=False) at2 = a.addtask(f2,[(at1,0)]) a.plotparams(pc.INTERACTIVE,pc.PDF) f3=Flow11_AT(file="/tmp/deleteme_3",touch=False,exist=False) at3 = a.addtask(f3 , [(at2,0)]) a.run() print "F1: plotmode = %d plottype = %d" % (f1._plot_mode,f1._plot_type) print "F2: plotmode = %d plottype = %d" % (f2._plot_mode,f2._plot_type) print "F3: plotmode = %d plottype = %d" % (f3._plot_mode,f3._plot_type)
print "Flow11_many:" # pick where admit will do its work if len(sys.argv) > 1: # use the argument as a (new or existing) directory a = admit.Admit(sys.argv[1]) else: # use the current directory a = admit.Admit() print "a.new: ", a.new i = range(n + 1) # dummy array to hold the task ID's i[0] = a.addtask(File_AT()) # first task: File_AT bootstrap a[i[0]].setkey('file', 'Flow11-0.dat') a[i[0]].setkey('touch', touch) a[i[0]].setkey('exist', False) jprev = i[0] for j in range(1, n + 1): # loop over a chain of Flow11_AT's i[j] = a.addtask(Flow11_AT(), [(jprev, 0)]) a[i[j]].setkey('file', 'Flow11-%d.dat' % j) a[i[j]].setkey('touch', touch) # comment out the next line for the puzzling behavior jprev = j # a.run() # print "RUN" a.run()
if len(sys.argv) > 1: a = admit.Admit(sys.argv[1]) else: a = admit.Admit() print 'Flow11: new admit?',a.new if not a.new: print 'LEN:',len(a) print "a[0]._keys:",a[0]._keys print "a[1]._keys:",a[1]._keys a.run() print "run done" a.write() sys.exit(0) a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file','Flow11-0.dat') a1.setkey('touch',True) a1.setkey('exist',False) print "a1._keys:",a1._keys a2 = Flow11_AT() i2 = a.addtask(a2, [(i1,0)]) if subdir: # this is to test if subdirectories work (26-apr, fails to work again on 2nd run) a.mkdir('test') a2.setkey('file','test/Flow11-1.dat') else: a2.setkey('file','Flow11-1.dat') a2.setkey('touch',touch)
from admit.at.File_AT import File_AT from admit.at.FlowN1_AT import FlowN1_AT if __name__ == '__main__': # pick where admit will do its work if len(sys.argv) > 1: # use the argument as a (new or existing) directory a = admit.Admit(sys.argv[1]) else: # use the current directory a = admit.Admit() print 'FlowN1: new admit?', a.new a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file', 'FlowN1-1.dat') a1.setkey('touch', True) a2 = File_AT() i2 = a.addtask(a2) a2.setkey('file', 'FlowN1-2.dat') a2.setkey('touch', True) a3 = File_AT() i3 = a.addtask(a3) a3.setkey('file', 'FlowN1-3.dat') a3.setkey('touch', True) a4 = File_AT()
import admit.Admit as admit from admit.at.File_AT import File_AT from admit.at.Flow11_AT import Flow11_AT if __name__ == '__main__': print "Flow11_again:" # pick a directory where admit will do its work (or else use current directory) if len(sys.argv) > 1: a = admit.Admit(sys.argv[1]) else: a = admit.Admit() print "=== test_Flow_again: first time, just create a File to bootstrap the flow" i1 = a.addtask(File_AT(file='Flow11-0.dat', touch=True, exist=False)) print "NEW TASK", i1 a.run() # Append one more Flow11 to whatever is already there. # To simulate re-running a typical ADMIT script, we still need to # manually re-add ALL prior Flow11 tasks. It should also work to just # update the global task ID instead, but this isn't what a user would do... print "=== test_Flow_again: append a Flow11_AT to the end of the existing flow" # this assumes no tasks were deleted and taskid's were added from 0,1,2,... n = len(a) print "Found %d tasks" % n print "last filename: ", a[n - 1][0].filename tid = 1 while tid <= n:
from admit.at.FlowN1_AT import FlowN1_AT if __name__ == '__main__': # pick where admit will do its work if len(sys.argv) > 1: # use the argument as a (new or existing) directory a = admit.Admit(sys.argv[1]) else: # use the current directory a = admit.Admit() print 'FlowN1: new admit?',a.new a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file','FlowN1-1.dat') a1.setkey('touch',True) a2 = File_AT() i2 = a.addtask(a2) a2.setkey('file','FlowN1-2.dat') a2.setkey('touch',True) a3 = File_AT() i3 = a.addtask(a3) a3.setkey('file','FlowN1-3.dat') a3.setkey('touch',True) a4 = File_AT()
# pick where admit will do its work if len(sys.argv) > 1: # use the argument as a (new or existing) directory a = admit.Admit(sys.argv[1]) else: # use the current directory a = admit.Admit() print 'FlowMN: new admit?', a.new if two_step: # this will use Flow1N_AT and FlowN1_AT # first create a single File_BDP a1 = File_AT() i1 = a.addtask(a1) a1.setkey('file', 'FlowMN-0.dat') a1.setkey('touch', touch) # turn 1 into M a2 = Flow1N_AT() i2 = a.addtask(a2, [(i1, 0)]) a2.setkey('n', m) a2.setkey('file', 'FlowMN-1.dat') a2.setkey('touch', touch) a2.setkey('subdir', subdir) # get a list of BDP's for the next step, but we need to run the flow first a.run() n = len(a2)