In [1]:
import seamless
from seamless.core import macro_mode_on
from seamless.core import context, cell, transformer

In [2]:
with macro_mode_on():
    ctx = context(toplevel=True)
    ctx.cell1 = cell().set(1)
    ctx.cell2 = cell().set(2)
    ctx.result = cell()
    ctx.tf = transformer({
        "a": "input",
        "b": "input",
        "c": "output"
    })
    ctx.cell1.connect(ctx.tf.a)
    ctx.cell2.connect(ctx.tf.b)
    ctx.code = cell("transformer").set("c = a + b")
    ctx.code.connect(ctx.tf.code)
    ctx.tf.c.connect(ctx.result)
    ctx.result.mount("/tmp/mount-test/myresult", persistent=True, mode="w")
    ctx.mount("/tmp/mount-test", persistent=True)
    ctx.sub = context(toplevel=False)
    ctx.sub.mycell = cell("text").set("This is my cell\nend")

await ctx.computation()


Out[2]:
([], False)

In [3]:
print(ctx.result.value)
ctx.cell1.set(10)
await ctx.computation()
print(ctx.result.value)
print(ctx.result.value)
ctx.code.set("c = float(a) + float(b) + 1000")
await ctx.computation()
print(ctx.result.value)
print(ctx.status)


3
12
12
1012.0
Status: OK

In [4]:
ctx.code.value


Out[4]:
'c = float(a) + float(b) + 1000'

In [5]:
await ctx.computation()


Out[5]:
([], False)