ctx.executor_code = set_resource(executor_file) ctx.executor_code._get_hcell()["language"] = "python" ctx.executor_code._get_hcell()["transformer"] = True ctx.executor_code.celltype = "code" ctx.translate() # 2: obtain graph and zip graph = ctx.get_graph() zip = ctx.get_zip() # 3: Run test example ###ctx.mount("/tmp/seamless-test", persistent=False) ctx.testdata = "a\nb\nc\nd\ne\nf\n" ctx.bashcode = "head -$lines testdata > firstdata; mkdir -p RESULT/input; cp firstdata RESULT; cp testdata RESULT/input" ctx.executor = lambda bashcode, testdata, pins_, lines: None pins = ctx.executor.pins pins.bashcode.celltype = "text" pins.pins_.celltype = "plain" ctx.executor.pins_ = ["lines", "testdata"] pins["lines"]["celltype"] = "int" pins["testdata"]["celltype"] = "text" ctx.executor.code = ctx.executor_code ctx.executor.bashcode = ctx.bashcode ctx.executor.testdata = ctx.testdata ctx.executor.lines = 3 ctx.result = ctx.executor ctx.result.celltype = "text" ctx.compute() print(ctx.result.value)
from seamless.highlevel import Context, Cell, stdlib from seamless.highlevel import set_resource executor_file = "executor.py" ctx = Context() ctx.executor_code = set_resource(executor_file) ctx.executor_code._get_hcell()["language"] = "python" ctx.executor_code._get_hcell()["transformer"] = True ctx.executor_code.celltype = "code" ctx.translate() if __name__ == "__main__": #ctx.mount("/tmp/seamless-test", persistent=False) #TODO: persistent=False (does not delete atm) ctx.testdata = "a\nb\nc\nd\ne\nf\n" ctx.bashcode = "head -$lines testdata" ctx.executor = lambda bashcode, testdata, pins: None ctx.executor.pins = ["lines", "testdata"] ctx.executor.code = ctx.executor_code ctx.executor.bashcode = ctx.bashcode ctx.executor.testdata = ctx.testdata ctx.executor.lines = 3 ctx.result = ctx.executor ctx.equilibrate() print(ctx.result.value) ctx.executor_code = ctx.executor_code.value + "\npass" ctx.equilibrate() print(ctx.result.value) else: stdlib.bash_transformer = ctx