def send_command(command, verbose=False, inherits=None): if inherits is None: return batch.Function(verbose=verbose) \ .send_command(command) else: return batch.Function(inherits,verbose=verbose) \ .send_command(command)
class Q2a(batch.BatchQ): pipe = batch.Controller(TestPipe1) # Here we indicate that errors should be printed fnc1 = batch.Function(verbose=True).hello_world("Hello error") # Default is not to print errors fnc2 = batch.Function(verbose=False).hello_world("Hello error")
def home_create_dir(directory, wildcard, verbose=False, inherits=None): if inherits is None: return batch.Function(verbose=verbose) \ .home().chdir(wildcard) \ .exists(directory).Qdon(1).mkdir(directory, True) \ .chdir(directory) else: return batch.Function(inherits,verbose=verbose) \ .home().chdir(wildcard) \ .exists(directory).Qdon(1).mkdir(directory, True) \ .chdir(directory)
class CreateFile2(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Pipeline(BashTerminal) create_dir = batch.Function(verbose=True) \ .home().chdir(_) \ .exists(directory).don(1).mkdir(directory, True) \ .chdir(directory) create_file = batch.Function(create_dir) \ .send_command(command)
class Q6(batch.BatchQ): _ = batch.WildCard() _r = batch.WildCard(reverse=True) _l = batch.WildCard(lifo=False) _lr = batch.WildCard(lifo=False, reverse=True) _3 = batch.WildCard(select=3) pipe = batch.Controller(TestPipe4) call_fnc = batch.Function() \ .fnc1() \ .fnc2() \ .fnc3() \ .fnc4() \ .fnc5() test1 = batch.Function(call_fnc) \ .display(_) test2 = batch.Function(call_fnc) \ .display2(_,_) test3 = batch.Function(call_fnc) \ .display2(_r,_r) test4 = batch.Function(call_fnc) \ .display2(_l,_l) test5 = batch.Function(call_fnc) \ .display2(_lr,_lr) test6 = batch.Function(call_fnc) \ .display(_3) display1 = batch.Function().fnc1()
class CreateFileAndDirectory(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) create_dir = batch.Function() \ .home().chdir(_) \ .exists(directory).Qdon(1).mkdir(directory, True) \ .chdir(directory) create_file = batch.Function(create_dir) \ .send_command(command)
class NoHUPStart(batch.BatchQ): _r = batch.WildCard(reverse = True) _ = batch.WildCard() input_directory = batch.Property() working_directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) workdir = batch.Function() \ .home().chdir(_).exists(working_directory) \ .don(1).mkdir(working_directory).chdir(working_directory) _set_copy_dirs = batch.Function(workdir, verbose=False) \ .pjoin(input_directory, "/*").pjoin(working_directory, "/").cp(_r, _r) \ transfer_infiles = batch.Function(_set_copy_dirs , verbose=False) .cp(_r, _r).don(1).throw("Failed to transfer files.")
class CreateFile1(batch.BatchQ): _ = batch.WildCard() directory = batch.Property() command = batch.Property() terminal = batch.Pipeline(BashTerminal) create_file = batch.Function() \ .home().chdir(_) \ .chdir(directory).send_command(command)
class Model(batch.BatchQ): ctrl = batch.Controller(object) fnc1 = batch.Function().Qthrow( exception=StandardError("Custom error class")) fnc2 = batch.Function().Qthrow("Standard error")
class HelloParam(batch.BatchQ): message = batch.Property("Parameter") ctrl = batch.Controller(Pipeline) fnc = batch.Function().hello(message)
class CallIt1(batch.BatchQ): ctrl = batch.Controller(Pipe) fnc1 = batch.Function().display("Hello world") fnc2 = batch.Function().display("Before call").Qcall(fnc1).display("After call") \ .Qprint_stack()
class NoHUP(batch.BatchQ): _r = batch.WildCard(reverse = True) _ = batch.WildCard() input_directory = batch.Property() working_directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) workdir = batch.Function() \ .home().chdir(_).exists(working_directory) \ .don(1).mkdir(working_directory).chdir(working_directory) _set_copy_dirs = batch.Function(workdir, verbose=False) \ .pjoin(input_directory, "/*").pjoin(working_directory, "/").cp(_r, _r) \ transfer_infiles = batch.Function(_set_copy_dirs , verbose=False) \ .cp(_r, _r).don(1).throw("Failed to transfer files.") transfer_outfiles = batch.Function(_set_copy_dirs, verbose=False) \ .cp(_, _).don(1).throw("Failed to transfer files.") startjob = batch.Function(workdir) \ .join("(", command, " > .bacthq.output & echo $! > .batchq.pid )").send_command(_) transfer_startjob = batch.Function(transfer_infiles) \ .call(startjob) getpid = batch.Function(workdir) \ .cat(".batchq.pid") isrunning = batch.Function(getpid) \ .isrunning(_) wasstarted = batch.Function(workdir) \ .exists(".batchq.output") log = batch.Function(wasstarted) \ .do(1).cat(".batchq.output") clean = batch.Function(wasstarted) \ .do(1).rm(".batchq.*", force = True)
class Inherits(batch.BatchQ): ctrl = batch.Controller(Pipe) fnc1 = batch.Function().display("Hello world") fnc2 = batch.Function(fnc1).display("Hello world II")
class Q4(batch.BatchQ): pipe = batch.Controller(TestPipe2) fnc1 = batch.Function(verbose=True).hello_world("Hello from FNC1") fnc2 = batch.Function(fnc1, verbose=True).hello_world("Hello from FNC2")
class Q3(batch.BatchQ): message = batch.Property("Hello property") pipe = batch.Controller(TestPipe2) fnc = batch.Function().hello_world(message)
class CallIt2(batch.BatchQ): _ = batch.WildCard() ctrl = batch.Controller(Pipe) fnc1 = batch.Function().display("Hello world") fnc2 = batch.Function().Qjoin(fnc1, " II").display(_)
working_directory = batch.Property() command = batch.Property() terminal = batch.Controller(BashTerminal) workdir = batch.Function() \ .home().chdir(_).exists(working_directory) \ .don(1).mkdir(working_directory).chdir(working_directory) _set_copy_dirs = batch.Function(workdir, verbose=False) \ .pjoin(input_directory, "/*").pjoin(working_directory, "/").cp(_r, _r) \ transfer_infiles = batch.Function(_set_copy_dirs , verbose=False) .cp(_r, _r).don(1).throw("Failed to transfer files.") transfer_outfiles = batch.Function(_set_copy_dirs, verbose=False) \ .cp(_, _).don(1).throw("Failed to transfer files.") startjob = batch.Function(workdir) \ .join("(", command, " > .bacthq.output & echo $! > .batchq.pid )").send_command(_) transfer_startjob = batch.Function(transfer_infiles) \ .call(startjob) getpid = batch.Function(workdir) \ .cat(".batchq.pid") isrunning = batch.Function(get_pid) \ .isrunning(_) wasstarted = batch.Function(workdir) \
class HelloWorld(batch.BatchQ): ctrl = batch.Controller(Pipeline) fnc = batch.Function().hello_world().hello_batchq()
class Q1(batch.BatchQ): pipe = batch.Controller(TestPipe1) fnc = batch.Function().hello_world()