예제 #1
0
        def checkThing2s():
            ensureSubscribedType(Thing2)

            res = Sequence([
                Span("Thing(k=%s).x = %s" % (thing.k, thing.x))
                for thing in Thing2.lookupAll()
            ])

            computed.set()

            return res
    def serviceDisplay(serviceObject,
                       instance=None,
                       objType=None,
                       queryArgs=None):
        ensureSubscribedType(GridValue)

        return Grid(
            colFun=lambda: list(range(COL_COUNT)),
            rowFun=lambda: list(range(ROW_COUNT)),
            headerFun=lambda x: x,
            rowLabelFun=None,
            rendererFun=lambda row, col: Subscribed(
                lambda: GridValue.lookupAny(row_and_col=(row, col)).value))
예제 #3
0
    def serviceDisplay(serviceObject,
                       instance=None,
                       objType=None,
                       queryArgs=None):
        cells.ensureSubscribedType(TaskStatus, lazy=True)

        return cells.Card(
            cells.Subscribed(lambda: cells.Text("Total Tasks: %s" % len(
                TaskStatus.lookupAll()))) +
            cells.Subscribed(lambda: cells.Text("Working Tasks: %s" % len(
                TaskStatus.lookupAll(state='Working')))) + cells.Subscribed(
                    lambda: cells.Text("WaitingForSubtasks Tasks: %s" % len(
                        TaskStatus.lookupAll(state='WaitForSubtasks')))) +
            cells.Subscribed(lambda: cells.Text("Unassigned Tasks: %s" % len(
                TaskStatus.lookupAll(state='Unassigned')))))
    def serviceDisplay(serviceObject,
                       instance=None,
                       objType=None,
                       queryArgs=None):
        ensureSubscribedType(TextEditor)

        toEval = Slot("{'x': [1,2,3,4,5], 'y': [1,5,1,5,1]}")

        def onEnter(buffer, selection):
            toEval.set(buffer)
            TextEditor.lookupAny().code = buffer

        def onTextChange(buffer, selection):
            if TextEditor.lookupAny() is not None:
                TextEditor.lookupAny().code = buffer

        ed = CodeEditor(keybindings={'Enter': onEnter},
                        noScroll=True,
                        minLines=50,
                        onTextChange=onTextChange)

        def makePlotData():
            # data must be a list or dict here, but this is checked/asserted
            # down the line in cells. Sending anything that is not a dict/list
            # will break the entire plot.
            try:
                data = ast.literal_eval(toEval.get())
            except (AttributeError, SyntaxError):
                data = {}
            return {'data': data}

        def onCodeChange():
            if TextEditor.lookupAny() is not None:
                if ed.getContents() != TextEditor.lookupAny().code:
                    ed.setContents(TextEditor.lookupAny().code)

        return Columns(ed, Card(
            Plot(makePlotData).height("100%").width("100%"))) + Subscribed(
                onCodeChange)
예제 #5
0
    def serviceDisplay(serviceObject,
                       instance=None,
                       objType=None,
                       queryArgs=None):
        cells.ensureSubscribedType(Configuration)
        cells.ensureSubscribedType(State)

        c = Configuration.lookupAny()

        if not c:
            return cells.Card("No configuration defined for  AWS")

        def bootCountSetter(state, ct):
            def f():
                state.desired = ct

            return f

        def bootCountSetterSpot(state, ct):
            def f():
                state.spot_desired = ct

            return f

        return cells.Grid(
            colFun=lambda: [
                'Instance Type', 'COST', 'RAM', 'CPU', 'Booted', 'Desired',
                'SpotBooted', 'SpotDesired', 'ObservedLimit',
                'CapacityConstrained', 'Spot-us-east-1', 'a', 'b', 'c', 'd',
                'e', 'f'
            ],
            rowFun=lambda: sorted([
                x for x in State.lookupAll()
                if x.instance_type in instance_types_to_show
            ],
                                  key=lambda s: s.instance_type),
            headerFun=lambda x: x,
            rowLabelFun=None,
            rendererFun=lambda s, field: cells.Subscribed(
                lambda: s.instance_type
                if field == 'Instance Type' else s.booted if field == 'Booted'
                else cells.Dropdown(s.desired, [
                    (str(ct), bootCountSetter(s, ct))
                    for ct in list(range(10)) + list(range(10, 101, 10))
                ]) if field == 'Desired' else s.spot_booted if field ==
                'SpotBooted' else cells.Dropdown(s.spot_desired, [
                    (str(ct), bootCountSetterSpot(s, ct))
                    for ct in list(range(10)) + list(range(10, 101, 10))
                ]) if field == 'SpotDesired' else
                ("" if s.observedLimit is None else s.observedLimit)
                if field == 'ObservedLimit' else
                ("Yes" if s.capacityConstrained else "")
                if field == 'CapacityConstrained' else valid_instance_types[
                    s.instance_type]['COST'] if field == 'COST' else
                valid_instance_types[s.instance_type]['RAM'] if field == 'RAM'
                else valid_instance_types[s.instance_type]['CPU'] if field ==
                'CPU' else s.spotPrices.get('us-east-1' + field, "")
                if field in 'abcdef' else "")) + cells.Card(
                    cells.Text("db_hostname = " + str(c.db_hostname)) +
                    cells.Text("db_port = " + str(c.db_port)) +
                    cells.Text("region = " + str(c.region)) +
                    cells.Text("vpc_id = " + str(c.vpc_id)) +
                    cells.Text("subnet = " + str(c.subnet)) +
                    cells.Text("security_group = " + str(c.security_group)) +
                    cells.Text("keypair = " + str(c.keypair)) +
                    cells.Text("worker_name = " + str(c.worker_name)) +
                    cells.Text("worker_iam_role_name = " +
                               str(c.worker_iam_role_name)) +
                    cells.Text("docker_image = " + str(c.docker_image)) +
                    cells.Text("defaultStorageSize = " +
                               str(c.defaultStorageSize)) +
                    cells.Text("max_to_boot = " + str(c.max_to_boot)))
 def display(self, queryParams=None):
     ensureSubscribedType(Happy)
     return "Happy %s. " % self.i + str(queryParams)
    def serviceDisplay(serviceObject,
                       instance=None,
                       objType=None,
                       queryArgs=None):
        ensureSubscribedType(PointsToShow)
        ensureSubscribedType(Feigenbaum)
        depth = Slot(50)

        def twinned():
            data = {
                'PointsToShow': {
                    'timestamp': [1500000000 + x for x in range(1000)],
                    'y': [numpy.sin(x) for x in range(1000)]
                }
            }
            slot = Slot(None)
            p1 = Plot(lambda: data, xySlot=slot)
            p2 = Plot(lambda: data, xySlot=slot)

            def synchronize():
                if slot.get() is not None:
                    p1.setXRange(*slot.get()[0])
                    p2.setXRange(*slot.get()[0])

            return p1 + p2 + Subscribed(synchronize)

        return Tabs(
            Overlay=Card(
                Plot(
                    lambda: {
                        'single_array': [1, 2, 3, 1, 2, 3],
                        'xy': {
                            'x': [1, 2, 3, 1, 2, 3],
                            'y': [4, 5, 6, 7, 8, 9]
                        },
                    }).width(600).height(400) + Code("HI")),
            AGrid=Grid(colFun=lambda: ['A', 'B', 'B'],
                       rowFun=lambda: ['1', '2', '2'],
                       headerFun=lambda x: x,
                       rowLabelFun=None,
                       rendererFun=lambda row, col: row + col),
            ASheet=Sheet(
                ["A", "B", "C"], 1000000,
                lambda rowIx: ["(%s) ts" % rowIx, rowIx, rowIx + 1, rowIx + 2]
            ).width('calc(100vw - 70px)').height('calc(100vh - 150px)'),
            Timestamps=(
                Button("Add a point!", GraphDisplayService.addAPoint) +
                Card(Plot(
                    GraphDisplayService.chartData)).width(600).height(400)),
            Twinned=Subscribed(twinned),
            feigenbaum=(Dropdown("Depth", [
                (val, depth.setter(val))
                for val in [10, 50, 100, 250, 500, 750, 1000]
            ]) + Dropdown(
                "Polynomial", [1.0, 1.5, 2.0], lambda polyVal: setattr(
                    Feigenbaum.lookupAny(), 'y', float(polyVal))) + Dropdown(
                        "Density", list(range(100, 10000, 100)),
                        lambda polyVal: setattr(Feigenbaum.lookupAny(
                        ), 'density', float(polyVal))) + Card(
                            Plot(lambda graph: GraphDisplayService.feigenbaum(
                                graph, depth.get()))).width(600).height(400)))