Exemple #1
0
    def __init__(self, id=None, **kwargs):
        if id is None and g.graph_id is None:
            # Create a new graph
            self._graph_db = db.create_graph()
            g.graph_id = self._graph_db.id
        elif id is not None:
            # Get an existing graph
            self._graph_db = db.get_graph(graph_id=id)
        elif g.graph_id is not None:
            # Get an existing graph
            self._graph_db = db.get_graph(graph_id=g.graph_id)

        # Raise an exception if there is no graph created
        if self._graph_db is None:
            raise Exception("Invalid graph id")
Exemple #2
0
def graph_viewer(graph_id):
    graph = db_manager.get_graph(graph_id=graph_id)
    return render_template('graph_viewer.html', graph=graph.__dict__)
Exemple #3
0
def graph_vis(graph_id):
    graph = db_manager.get_graph(graph_id=graph_id)
    ops = db_manager.get_ops(graph_id=graph_id)
    return render_template('graph_vis.html', graph=graph.__dict__, ops=ops)
Exemple #4
0
def find_op():
    op = db.get_incomplete_op()

    if op is not None:
        return op
    else:
        q1 = RavQueue(name=QUEUE_HIGH_PRIORITY)
        q2 = RavQueue(name=QUEUE_LOW_PRIORITY)

        while True:
            op_id1 = None
            op_id2 = None

            if q1.__len__() > 0:
                op_id1 = q1.get(0)
            elif q2.__len__() > 0:
                op_id2 = q2.get(0)

            if op_id1 is None and op_id2 is None:
                return None

            ops = [op_id1, op_id2]

            for index, op_id in enumerate(ops):
                if op_id is None:
                    continue

                op = db.get_op(op_id=op_id)

                if op.graph_id is not None:
                    if db.get_graph(op.graph_id).status == "failed":
                        # Change this op's status to failed
                        if op.status != "failed":
                            db.update_op(op, status=OpStatus.FAILED.value)
                            continue

                    elif db.get_graph(op.graph_id).status == "computed":
                        if index == 0:
                            q1.pop()
                        elif index == 1:
                            q2.pop()
                        continue

                r = db.get_op_readiness(op)
                if r == "ready":
                    if index == 0:
                        q1.pop()
                    elif index == 1:
                        q2.pop()

                    return op
                elif r == "parent_op_failed":
                    if index == 0:
                        q1.pop()
                    elif index == 1:
                        q2.pop()

                    # Change this op's status to failed
                    if op.status != "failed":
                        db.update_op(op, status=OpStatus.FAILED.value)

            return None