Exemple #1
0
def build_structured_cell(ctx,
                          name,
                          inchannels,
                          outchannels,
                          *,
                          fingertip_no_remote,
                          fingertip_no_recompute,
                          mount=None,
                          return_context=False,
                          hash_pattern=None):
    #print("build_structured_cell", name)
    name2 = name + STRUC_ID
    c = context(toplevel=False)
    setattr(ctx, name2, c)
    if mount is not None:
        mount.pop("as_directory", None)
        c.mount(**mount)
    c.data = core_cell("mixed")
    c.data._hash_pattern = hash_pattern
    c.auth = core_cell("mixed")
    c.auth._hash_pattern = hash_pattern
    c.schema = core_cell("plain")
    c.buffer = core_cell("mixed")
    c.buffer._hash_pattern = hash_pattern

    sc = StructuredCell(data=c.data,
                        auth=c.auth,
                        schema=c.schema,
                        buffer=c.buffer,
                        inchannels=inchannels,
                        outchannels=outchannels,
                        hash_pattern=hash_pattern)
    c.example_data = core_cell("mixed")
    c.example_buffer = core_cell("mixed")
    c.example = StructuredCell(c.example_data,
                               buffer=c.example_buffer,
                               schema=c.schema)

    for cc in (c.data, c.buffer, c.schema, c.auth, c.example_data,
               c.example_buffer):
        if fingertip_no_recompute:
            cc._fingertip_recompute = False
        if fingertip_no_remote:
            cc._fingertip_remote = False

    if return_context:
        return sc, c
    else:
        return sc
Exemple #2
0
def reset_backend(share_schemas=True, with_hash_pattern=True):
    hp = hash_pattern if with_hash_pattern else None
    global ctx, s, s2, s3
    if ctx is not None:
        ctx.compute() # makes no difference, but could be easier debugging
        ctx.destroy()
    ctx = context(toplevel=True)
    ctx.data = cell("mixed", hash_pattern=hp)
    ctx.buffer = cell("mixed", hash_pattern=hp)
    ctx.schema = cell("plain")
    ctx.sc = StructuredCell(
        buffer=ctx.buffer,
        data=ctx.data,
        schema=ctx.schema,
        hash_pattern=hp
    )
    s = ctx.sc.handle
    ctx.data2 = cell("mixed", hash_pattern=hp)
    ctx.buffer2 = cell("mixed", hash_pattern=hp)
    if share_schemas:
        schema2 = ctx.schema
    else:
        ctx.schema2 = cell("plain")
        schema2 = ctx.schema2
    ctx.sc2 = StructuredCell(
        buffer=ctx.buffer2,
        data=ctx.data2,
        schema=schema2,
        hash_pattern=hp
    )
    s2 = ctx.sc2.handle
    hp3 = None # never use hash pattern for this one
    ctx.data3 = cell("mixed", hash_pattern=hp3)
    ctx.buffer3 = cell("mixed", hash_pattern=hp3)
    if share_schemas:
        schema3 = ctx.schema
    else:
        ctx.schema3 = cell("plain")
        schema3 = ctx.schema3
    ctx.sc3 = StructuredCell(
        buffer=ctx.buffer3,
        data=ctx.data3,
        schema=schema3,
        hash_pattern=hp3
    )
    s3 = ctx.sc3.handle
Exemple #3
0
 def recreate(ctx, name0, with_buffer, with_schema, inchannels):
     name = "." + name0
     ctx.struc = context(name="struc", context=ctx)
     ctx.struc.storage = libcell(name + ".storage")
     ctx.struc.form = libcell(name + ".form")
     ctx.struc.data = libmixedcell(
         name + ".data",
         form_cell=ctx.struc.form,
         storage_cell=ctx.struc.storage,
     )
     schema = None
     if with_schema:
         ctx.struc.schema = libcell(name + ".schema")
         schema = ctx.struc.schema
     bufferwrapper = None
     if with_buffer:
         ctx.struc.buffer_storage = libcell(name + ".buffer_storage")
         ctx.struc.buffer_form = libcell(name + ".buffer_form")
         ctx.struc.buffer_data = libmixedcell(
             name + ".buffer_data",
             form_cell=ctx.struc.buffer_form,
             storage_cell=ctx.struc.buffer_storage,
         )
         bufferwrapper = BufferWrapper(ctx.struc.buffer_data,
                                       ctx.struc.buffer_storage,
                                       ctx.struc.buffer_form)
     ctx.hub = StructuredCell(
         "hub",
         ctx.struc.data,
         storage=ctx.struc.storage,
         form=ctx.struc.form,
         schema=schema,
         buffer=bufferwrapper,
         inchannels=inchannels,
         outchannels=[],
     )
Exemple #4
0
def create(ctx, with_buffer, with_schema, inchannels):
    with macro_mode_on():
        ctx.struc = context(name="struc", context=ctx)
        ctx.struc.storage = cell("text")
        ctx.struc.form = cell("json")
        ctx.struc.data = cell(
            "mixed",
            form_cell=ctx.struc.form,
            storage_cell=ctx.struc.storage,
        )
        schema = None
        if with_schema:
            ctx.struc.schema = cell("json")
            schema = ctx.struc.schema
        bufferwrapper = None
        if with_buffer:
            ctx.struc.buffer_storage = cell("text")
            ctx.struc.buffer_form = cell("json")
            ctx.struc.buffer_data = cell(
                "mixed",
                form_cell=ctx.struc.buffer_form,
                storage_cell=ctx.struc.buffer_storage,
            )
            bufferwrapper = BufferWrapper(ctx.struc.buffer_data,
                                          ctx.struc.buffer_storage,
                                          ctx.struc.buffer_form)
        ctx.hub = StructuredCell(
            "hub",
            ctx.struc.data,
            storage=ctx.struc.storage,
            form=ctx.struc.form,
            schema=schema,
            buffer=bufferwrapper,
            inchannels=inchannels,
            outchannels=[],
        )
Exemple #5
0
    )
    ctx.hub_struc.schema = cell("json")
    ctx.hub_struc.buffer_storage = cell("text")
    ctx.hub_struc.buffer_form = cell("json")
    ctx.hub_struc.buffer_data = cell(
        "mixed",
        form_cell=ctx.hub_struc.buffer_form,
        storage_cell=ctx.hub_struc.buffer_storage,
    )
    bufferwrapper = BufferWrapper(ctx.hub_struc.buffer_data,
                                  ctx.hub_struc.buffer_storage,
                                  ctx.hub_struc.buffer_form)
    ctx.hub = StructuredCell("hub",
                             ctx.hub_struc.data,
                             storage=ctx.hub_struc.storage,
                             form=ctx.hub_struc.form,
                             schema=ctx.hub_struc.schema,
                             buffer=bufferwrapper,
                             inchannels=[("m1", ), ("m2", )],
                             outchannels=[()])

    ctx.code = cell("transformer").set("z = x * y")

    ctx.mixer1 = transformer({
        "x": "input",
        "y": "input",
        "z": "output",
    })
    ctx.a = cell("json").set(3)
    ctx.b = cell("json").set(8)
    ctx.code.connect(ctx.mixer1.code)
    ctx.a.connect(ctx.mixer1.x)
Exemple #6
0
with macro_mode_on():
    ctx = context(toplevel=True)
    ctx.mount("/tmp/mount-test",
              persistent=None)  #directory remains, but empty
    ctx.inp_struc = context(name="inp_struc", context=ctx)
    ctx.inp_struc.storage = cell("text")
    ctx.inp_struc.form = cell("json")
    ctx.inp_struc.data = cell(
        "mixed",
        form_cell=ctx.inp_struc.form,
        storage_cell=ctx.inp_struc.storage,
    )
    ctx.inp = StructuredCell("inp",
                             ctx.inp_struc.data,
                             storage=ctx.inp_struc.storage,
                             form=ctx.inp_struc.form,
                             schema=None,
                             buffer=None,
                             inchannels=None,
                             outchannels=[()])
    ctx.tf = transformer({
        "inp": ("input", "copy", "silk"),
        "c": "output",
    })

    ctx.inp.connect_outchannel((), ctx.tf.inp)
    ctx.tf.code.cell().set("c = inp.a * inp.dat + inp.b")

    ctx.result = cell("array")
    ctx.tf.c.connect(ctx.result)

ctx.equilibrate()
# adapted from simple-channels.py
from seamless.core import context, cell, StructuredCell

ctx = context(toplevel=True)
ctx.data = cell("mixed", hash_pattern={"*": "#"})
ctx.sc = StructuredCell(data=ctx.data,
                        inchannels=[()],
                        outchannels=[("a", ), ("b", ), ("c", )],
                        hash_pattern={"*": "#"})
ctx.a = cell("int")
ctx.sc.outchannels[("a", )].connect(ctx.a)
ctx.b = cell("mixed")
ctx.sc.outchannels[("b", )].connect(ctx.b)
ctx.c = cell("mixed")
ctx.sc.outchannels[("c", )].connect(ctx.c)

ctx.upstream = cell("mixed").set({"a": 1})
ctx.upstream.connect(ctx.sc.inchannels[()])

ctx.compute()
print(ctx.a.value, ctx.b.value, ctx.c.value)
ctx.upstream.set({"a": 10, "b": {"x": 20}, "c": [1, 2, 3]})
ctx.compute()
print(ctx.a.value, ctx.b.value, ctx.c.value)

# Take 2, make upstream a deep cell now
ctx = context(toplevel=True)
ctx.data = cell("mixed")
ctx.sc = StructuredCell(
    data=ctx.data,
    inchannels=[()],
Exemple #8
0
def create(ctx, mount, state=None):
    with macro_mode_on():
        ctx.hub_struc = context(name="hub_struc", context=ctx)
        ctx.hub_struc.storage = cell("text")
        ctx.hub_struc.form = cell("json")
        ctx.hub_struc.data = cell(
            "mixed",
            form_cell=ctx.hub_struc.form,
            storage_cell=ctx.hub_struc.storage,
        )
        ctx.hub_struc.schema = cell("json")
        ctx.hub_struc.buffer_storage = cell("text")
        ctx.hub_struc.buffer_form = cell("json")
        ctx.hub_struc.buffer_data = cell(
            "mixed",
            form_cell=ctx.hub_struc.buffer_form,
            storage_cell=ctx.hub_struc.buffer_storage,
        )
        bufferwrapper = BufferWrapper(ctx.hub_struc.buffer_data,
                                      ctx.hub_struc.buffer_storage,
                                      ctx.hub_struc.buffer_form)
        ctx.hub = StructuredCell(
            "hub",
            ctx.hub_struc.data,
            storage=ctx.hub_struc.storage,
            form=ctx.hub_struc.form,
            schema=ctx.hub_struc.schema,
            buffer=bufferwrapper,
            inchannels=[("a", "factor1"), ("a", "factor2"), ("b", )],
            outchannels=[("a", ), ("b", ), ("c", )],
            state=state,
        )

        ctx.code = cell("transformer").set(
            "d = a.factor1 * b + a.factor2 * c + a.constant")

        ctx.mixer = transformer({
            "a": ("input", "ref", "silk"),
            "b": ("input", "ref", "object"),
            "c": ("input", "ref", "object"),
            "d": ("output", "ref", "json"),
        })
        ctx.a_factor1 = cell("json")
        ctx.a_factor2 = cell("json")
        ctx.b = cell("json")
        ctx.code.connect(ctx.mixer.code)

        ctx.hub.connect_inchannel(ctx.a_factor1, ("a", "factor1"))
        ctx.hub.connect_inchannel(ctx.a_factor2, ("a", "factor2"))
        ctx.hub.connect_inchannel(ctx.b, ("b", ))

        ctx.hub.connect_outchannel(("a", ), ctx.mixer.a)
        ctx.hub.connect_outchannel(("b", ), ctx.mixer.b)
        ctx.hub.connect_outchannel(("c", ), ctx.mixer.c)

        ctx.result_struc = context(name="result_struc", context=ctx)
        ctx.result_struc.storage = cell("text")
        ctx.result_struc.form = cell("json")
        ctx.result_struc.data = cell(
            "mixed",
            form_cell=ctx.result_struc.form,
            storage_cell=ctx.result_struc.storage,
        )
        ctx.result_struc.schema = cell("json")
        ctx.result_struc.buffer_storage = cell("text")
        ctx.result_struc.buffer_form = cell("json")
        ctx.result_struc.buffer_data = cell(
            "mixed",
            form_cell=ctx.result_struc.buffer_form,
            storage_cell=ctx.result_struc.buffer_storage,
        )
        bufferwrapper = BufferWrapper(ctx.result_struc.buffer_data,
                                      ctx.result_struc.buffer_storage,
                                      ctx.result_struc.buffer_form)
        ctx.result = StructuredCell("result",
                                    ctx.result_struc.data,
                                    storage=ctx.result_struc.storage,
                                    form=ctx.result_struc.form,
                                    schema=ctx.result_struc.schema,
                                    buffer=bufferwrapper,
                                    inchannels=[()],
                                    outchannels=[])

        ctx.result.connect_inchannel(ctx.mixer.d, ())
        if mount:
            ctx.mount("/tmp/mount-test")
Exemple #9
0
import seamless
from seamless.core import macro_mode_on
from seamless.core import context, cell, transformer, pytransformercell, StructuredCell
with macro_mode_on():
    ctx = context(toplevel=True)
    ctx.tf = transformer({"a": "input", "b": "input", "c": "output"})
    ctx.inp_struc = context(name="inp_struc", context=ctx)
    ctx.inp_struc.data = cell("json")
    ctx.inp_struc.form = cell("json")
    ctx.inp = StructuredCell("inp",
                             ctx.inp_struc.data,
                             storage=None,
                             form=ctx.inp_struc.form,
                             schema=None,
                             buffer=None,
                             inchannels=None,
                             outchannels=[("a", ), ("b", )])
    ctx.inp.connect_outchannel(("a", ), ctx.tf.a)
    ctx.inp.connect_outchannel(("b", ), ctx.tf.b)

    ctx.result_struc = context(name="result_struc", context=ctx)
    ctx.result_struc.data = cell("json")
    ctx.result_struc.form = cell("json")
    ctx.result = StructuredCell("result",
                                ctx.result_struc.data,
                                storage=None,
                                form=ctx.result_struc.form,
                                schema=None,
                                buffer=None,
                                inchannels=[("x", ), ("y", )],
                                outchannels=[("y", )])
Exemple #10
0
from seamless.core import context, cell, StructuredCell
from seamless.core.protocol.deep_structure import DeepStructureError
import traceback

ctx = context(toplevel=True)
ctx.data = cell("mixed")
hash_pattern = {"*": "#"}
ctx.data._hash_pattern = hash_pattern
ctx.sc = StructuredCell(data=ctx.data, hash_pattern=hash_pattern)

data = ctx.sc.handle
try:
    data.set(20)
except DeepStructureError:
    traceback.print_exc()
data.set({})

ctx.compute()
print(ctx.data.value)
print(data)
print(ctx.sc.value)

print("START")
data.x = "test"
data.y = "test2"
data.z = "test3"

ctx.compute()
print(ctx.data.value)
print(data)
print(ctx.sc.value)
Exemple #11
0
print(c.data)
c.xyz = -1,0,0
print(c.data, c.xyz)
c.xyz = 0.2,-0.3,0.93
print(c.data, c.xyz)
pprint(c.schema.value)
ctx.compute()

ctx.destroy()
ctx = context(toplevel=True)
ctx.data = cell("mixed")
ctx.buffer = cell("mixed")
ctx.schema = cell("plain")
ctx.sc = StructuredCell(
    buffer=ctx.buffer,
    data=ctx.data,
    schema=ctx.schema
)

Test = ctx.sc.handle # singleton
"""
# will never work for a singleton backed up by a structured cell
def __init__(self, a, b):
    self.a = a
    self.b = b
"""
def __call__(self, c):
    return self.a + self.b + c
#Test.__init__ = __init__
Test.__call__ = __call__
#test = Test(7,8)
Exemple #12
0
from seamless.core import context, cell, StructuredCell

ctx = context(toplevel=True)
ctx.data = cell("mixed")
ctx.sc = StructuredCell(data=ctx.data,
                        inchannels=[("codefield", )],
                        outchannels=[()])

ctx.upstream = cell("python").set("print(42)")
ctx.upstream.connect(ctx.sc.inchannels[("codefield", )])

ctx.compute()
print(ctx.data.value)
ctx.upstream.set("""
print(43)
print(44)
""")
ctx.compute()
print(ctx.data.value)
Exemple #13
0
    ctx = context(toplevel=True)
    ctx.cell1 = cell("json")
    ctx.result = cell("json")
    ctx.tf = transformer({
        "a": "input",
        "b": "input",
        "c": "output"
    })
    ctx.tf.code.cell().set("c = min(a, b+3)")
    ctx.v_form = cell("json")
    ctx.v = StructuredCell(
        "v",
        ctx.cell1,
        storage = None,
        form = ctx.v_form,
        schema = None,
        buffer = None,
        inchannels = [("result",), ("c",)],
        outchannels = [("a",), ("c",)],
        editchannels = [("b",)],
    )
    ctx.v.connect_outchannel(("a",), ctx.tf.a)
    ctx.v.connect_outchannel(("b",), ctx.tf.b)
    ctx.v.connect_inchannel(ctx.tf.c, ("c",))
    ctx.tf.c.connect(ctx.result)

    ctx.rc = reactor({
      "result": "output",
      "b": {"io": "edit", "must_be_defined": False},
      "c": {"io": "input", "must_be_defined": False}
    })
Exemple #14
0
from seamless.core import context, cell, StructuredCell

ctx = context(toplevel=True)
ctx.data = cell("mixed")
ctx.sc = StructuredCell(data=ctx.data,
                        inchannels=[()],
                        outchannels=[("a", ), ("b", ), ("c", )])

ctx.a = cell("int")
ctx.sc.outchannels[("a", )].connect(ctx.a)
ctx.b = cell("mixed")
ctx.sc.outchannels[("b", )].connect(ctx.b)
ctx.c = cell("mixed")
ctx.sc.outchannels[("c", )].connect(ctx.c)

ctx.upstream = cell("mixed").set({"a": 1})
ctx.upstream.connect(ctx.sc.inchannels[()])

ctx.compute()
print(ctx.a.status, ctx.b.status, ctx.c.status, ctx.a.value, ctx.b.value,
      ctx.c.value)
ctx.upstream.set({"a": 10, "b": {"x": 20}, "c": [1, 2, 3]})
ctx.compute()
print(ctx.a.status, ctx.b.status, ctx.c.status, ctx.a.value, ctx.b.value,
      ctx.c.value)
text = ["*" * 1000]
ctx.upstream.set({"a": text.copy(), "b": text.copy(), "c": text.copy()})
ctx.compute()
print(ctx.a.checksum, ctx.b.checksum, ctx.c.checksum)
print(ctx.a.status, ctx.b.status, ctx.c.status)
print(ctx.a.exception)
Exemple #15
0
# adapted from simple-channels.py
from seamless.core import context, cell, StructuredCell

ctx = context(toplevel=True)
ctx.upstream = cell("int")

ctx.sc_auth = cell("mixed")
ctx.sc_buffer = cell("mixed")
ctx.sc_data = cell("mixed")
ctx.sc = StructuredCell(
    data=ctx.sc_data,
    auth=ctx.sc_auth,
    buffer=ctx.sc_buffer,
    inchannels=[("a",)],
    outchannels=[("a",), ("b",), ("c",)],
)
ctx.a = cell("int")
ctx.sc.outchannels[("a",)].connect(ctx.a)
ctx.b = cell("mixed")
ctx.sc.outchannels[("b",)].connect(ctx.b)
ctx.c = cell("mixed")
ctx.sc.outchannels[("c",)].connect(ctx.c)


ctx.upstream.connect(ctx.sc.inchannels[("a"),])
ctx.upstream.set(10)
ctx.compute()
print(ctx.a.value, ctx.b.value, ctx.c.value)
ctx.sc.set({"b": 20, "c": 30})
ctx.compute()
print(ctx.a.value, ctx.b.value, ctx.c.value)
from seamless.core import context, cell, StructuredCell
from seamless.core import macro_mode_on
with macro_mode_on():
    ctx = context(toplevel=True)
    ctx.data = cell("mixed")
    ctx.sc = StructuredCell(data=ctx.data)

data = ctx.sc.handle
data.set(20)
print(data)
ctx.compute()
print(data.data, ctx.data.value)
data.set({})
data.a = "test"
data.b = 12
data.b.set(5)
data.c = {"d": {}}
data.c.d.e = 12.0
print(data)
ctx.compute()
print(data.data, ctx.data.value)
Exemple #17
0
def build_structured_cell(ctx,
                          name,
                          silk,
                          plain,
                          buffered,
                          inchannels,
                          outchannels,
                          state,
                          lib_path0,
                          *,
                          editchannels=[],
                          mount=None,
                          return_context=False):
    #print("build_structured_cell", name, lib_path)
    name2 = name + STRUC_ID
    c = context(name=name2, context=ctx)
    setattr(ctx, name2, c)
    if mount is not None:
        c.mount(**mount)
    lib_path = lib_path0 + "." + name2 if lib_path0 is not None else None
    sovereign = True
    if lib_path:
        path = lib_path + ".form"
        cc = libcell(path)
    else:
        cc = core_cell("json")
        cc._sovereign = sovereign
    c.form = cc
    if plain:
        if lib_path:
            path = lib_path + ".data"
            cc = libcell(path)
        else:
            cc = core_cell("json")
            cc._sovereign = sovereign
        c.data = cc
        storage = None
    else:
        if lib_path:
            path = lib_path + ".storage"
            storage = libcell(path)
        else:
            storage = core_cell("text")
            storage._sovereign = sovereign
        c.storage = storage
        if lib_path:
            path = lib_path + ".data"
            c.data = libmixedcell(path,
                                  form_cell=c.form,
                                  storage_cell=c.storage)
        else:
            c.data = core_cell("mixed",
                               form_cell=c.form,
                               storage_cell=c.storage)
            c.data._sovereign = sovereign
    if silk:
        if lib_path:
            path = lib_path + ".schema"
            schema = libcell(path)
        else:
            schema = core_cell("json")
        c.schema = schema
    else:
        schema = None
    if buffered:
        if lib_path:
            path = lib_path + ".buffer_form"
            cc = libcell(path)
        else:
            cc = core_cell("json")
            cc._sovereign = sovereign
        c.buffer_form = cc
        if plain:
            if lib_path:
                path = lib_path + ".buffer_data"
                cc = libcell(path)
            else:
                cc = core_cell("json")
                cc._sovereign = sovereign
            c.buffer_data = cc
            buffer_storage = None
        else:
            if lib_path:
                path = lib_path + ".buffer_storage"
                buffer_storage = libcell(path)
            else:
                buffer_storage = core_cell("text")
                buffer_storage._sovereign = sovereign
            c.buffer_storage = buffer_storage
            if lib_path:
                path = lib_path + ".buffer_data"
                c.buffer_data = libmixedcell(
                    path,
                    form_cell=c.buffer_form,
                    storage_cell=c.buffer_storage,
                )
            else:
                c.buffer_data = core_cell(
                    "mixed",
                    form_cell=c.buffer_form,
                    storage_cell=c.buffer_storage,
                )
                c.buffer_data._sovereign = sovereign
        bufferwrapper = BufferWrapper(c.buffer_data, buffer_storage,
                                      c.buffer_form)
    else:
        bufferwrapper = None

    sc = StructuredCell(name,
                        c.data,
                        storage=storage,
                        form=c.form,
                        schema=schema,
                        buffer=bufferwrapper,
                        inchannels=inchannels,
                        outchannels=outchannels,
                        state=state,
                        editchannels=editchannels)
    if return_context:
        return sc, c
    else:
        return sc
Exemple #18
0
import seamless
from seamless.core import macro_mode_on
from seamless.core import context, cell, transformer, pytransformercell, StructuredCell
with macro_mode_on():
    ctx = context(toplevel=True)
    ctx.cell1 = cell("json")
    ctx.cell2 = cell("json").set(2)
    ctx.result = cell("json")
    ctx.tf = transformer({"a": "input", "b": "input", "c": "output"})
    ctx.a_form = cell("json")
    ctx.a = StructuredCell("a",
                           ctx.cell1,
                           storage=None,
                           form=ctx.a_form,
                           schema=None,
                           buffer=None,
                           inchannels=None,
                           outchannels=[()])
    ctx.a.connect_outchannel((), ctx.tf.a)
    ctx.cell2.connect(ctx.tf.b)
    ctx.code = pytransformercell().set("c = a + b")
    ctx.code.connect(ctx.tf.code)
    ctx.tf.c.connect(ctx.result)

    ctx.mount("/tmp/mount-test")

ctx.equilibrate()
print(ctx.result.value)

ctx.a.set(1)
Exemple #19
0
    ctx = context(toplevel=True)

    # 1a. Setup of StructuredCells
    ctx.inp_struc = context(name="inp_struc", context=ctx)
    ctx.inp_struc.storage = cell("text")
    ctx.inp_struc.form = cell("json")
    ctx.inp_struc.data = cell(
        "mixed",
        form_cell=ctx.inp_struc.form,
        storage_cell=ctx.inp_struc.storage,
    )
    ctx.inp_struc.schema = cell("json")
    ctx.inp = StructuredCell("inp",
                             ctx.inp_struc.data,
                             storage=ctx.inp_struc.storage,
                             form=ctx.inp_struc.form,
                             schema=ctx.inp_struc.schema,
                             buffer=None,
                             inchannels=[],
                             outchannels=[()])
    ctx.result_struc = context(name="result_struc", context=ctx)
    ctx.result_struc.storage = cell("text")
    ctx.result_struc.form = cell("json")
    ctx.result_struc.data = cell(
        "mixed",
        form_cell=ctx.result_struc.form,
        storage_cell=ctx.result_struc.storage,
    )
    ctx.result_struc.schema = cell("json")
    ctx.result = StructuredCell("result",
                                ctx.result_struc.data,
                                storage=ctx.result_struc.storage,