Exemple #1
0
"""
    if not hasattr(self, "kw"):
        self.kw = {}
    n = 0
    while 1:
        n += 1
        c = "cell%d" % n
        if c not in self.kw:
            break
    self.kw[c] = function.path
"""

# 2: obtain graph and zip

ctx0.constructor_code = Cell("code").set(constructor)
ctx0.constructor_params = parameters
ctx0.api_schema = api_schema
ctx0.compute()

graph = ctx0.get_graph()
zip = ctx0.get_zip()

# 5: Save graph and zip

import os, json

currdir = os.path.dirname(os.path.abspath(__file__))
graph_filename = os.path.join(currdir, "../channel.seamless")
json.dump(graph, open(graph_filename, "w"), sort_keys=True, indent=2)

zip_filename = os.path.join(currdir, "../channel.zip")
Exemple #2
0
        "io": "edit"
    },
    "merged": {
        "type": "cell",
        "celltype": "text",
        "io": "output"
    },
    "state": {
        "type": "cell",
        "celltype": "str",
        "io": "output"
    }

}

ctx.constructor_params = constructor_params
ctx.macro_code = Cell("code").set(macro_code)
ctx.code_start = set_resource("cell-merge-START.py")
ctx.code_update = set_resource("cell-merge-UPDATE.py")

ctx.compute()

# 2: obtain graph and zip

graph = ctx.get_graph()
zip = ctx.get_zip()

# 3: Package the contexts in a library

from seamless.highlevel.library import LibraryContainer
mylib = LibraryContainer("mylib")
Exemple #3
0
                subinstance = getattr(subinstance, subpath)
            if not isinstance(subinstance, Cell):
                raise TypeError("Invalid path {} is {} instead of Cell" %
                                (path, type(subinstance)))
            export_cell.connect_from(subinstance, target_path=name)


ctx.constructor_code = Cell("code").set(constructor)
ctx.constructor_params = {
    "template": "context",
    "pattern": "value",
    "ncopies": "value",
    "imports": {
        "type": "celldict",
        "io": "input"
    },
    "exports": {
        "type": "celldict",
        "io": "output"
    },
    "entries": "value",
    "exits": "value",
}

ctx.compute()

# 2: obtain graph and zip

graph = ctx.get_graph()
zip = ctx.get_zip()
Exemple #4
0
    result.connect_from(ctx.result)


ctx.macro_code = Cell("code").set(macro_code)
ctx.constructor_code = Cell("code").set(constructor)
ctx.constructor_params = {
    "language": {
        "type": "value",
        "io": "input",
        "default": "python"
    },
    "code": "value",
    "result": {
        "type": "cell",
        "io": "output"
    },
    "scatter": "value",
    "celltypes": {
        "type": "value",
        "io": "input",
        "default": {}
    },
    "inputpins": {
        "type": "kwargs",
        "io": "input"
    },
}

ctx.compute()

# 2: obtain graph and zip
Exemple #5
0
        setattr(ctx.join_macro, input_name, input_cell)
        inputs[input_name].connect(input_cell)
    ctx.output = ctx.join_macro.output

ctx_switch.switch_code = Cell("code")
ctx_switch.switch_code = switch_func
ctx_switch.constructor_code = Cell("code")
ctx_switch.constructor_code = constructor_switch
ctx_switch.constructor_params = {
    "celltype": "value",
    "input": {
        "type": "cell",
        "io": "input"
    },
    "selected": {
        "type": "cell",
        "io": "input"
    },
    "outputs": {
        "type": "celldict",
        "io": "output"
    },
}
ctx_switch.compute()

ctx_join.join_code = Cell("code")
ctx_join.join_code = join_func
ctx_join.constructor_code = Cell("code")
ctx_join.constructor_code = constructor_join
ctx_join.constructor_params = {
    "celltype": "value",
Exemple #6
0
    ctx.subtract.pins.b.celltype = celltype
    ctx.c = ctx.subtract


ctx.subtract_code = Cell("code")
ctx.subtract_code = subtract_func
ctx.constructor_code = Cell("code")
ctx.constructor_code = constructor
ctx.constructor_params = {
    "celltype": "value",
    "a": {
        "type": "cell",
        "io": "input"
    },
    "b": {
        "type": "cell",
        "io": "input"
    },
    "c": {
        "type": "cell",
        "io": "output"
    },
}
ctx.compute()

# 2: obtain graph and zip

graph = ctx.get_graph()
zip = ctx.get_zip()

# 3: Package the context in a library