コード例 #1
0
def test_parent_child(rk):
    execution = next(rk)

    t1 = Task.new({'name': '1', 'execution': execution})

    t2 = Task.new({'name': '2', 'execution': execution})
    t1.childs.add(t2)
    t1.save()
    t2.save()

    assert Task.childs.filter(t1.key) == [t2.key]
    assert Task.parents.filter(t2.key) == [t1.key]
    assert t1.childs.all_tasks() == [t2]
    assert t2.parents.all_names() == [t1.name]
コード例 #2
0
def test_tasks_selected_by_execution_id(rk):
    execution = next(rk)

    for i in range(2):
        t = Task.new({'name': str(i), 'execution': execution})
        t.save()
    another_execution = next(rk)

    for i in range(2):
        t = Task.new({'name': str(i), 'execution': another_execution})
        t.save()

    assert len(Task.execution.filter(execution)) == 2
    assert len(Task.execution.filter(another_execution)) == 2
コード例 #3
0
ファイル: graph.py プロジェクト: loles/solar-1
def save_graph(graph):
    # maybe it is possible to store part of information in AsyncResult backend
    uid = graph.graph['uid']

    # TODO(dshulyak) remove duplication of parameters
    # in solar_models.Task and this object
    for n in nx.topological_sort(graph):
        t = Task.new({
            'name': n,
            'execution': uid,
            'status': graph.node[n].get('status', ''),
            'target': graph.node[n].get('target', '') or '',
            'task_type': graph.node[n].get('type', ''),
            'args': graph.node[n].get('args', []),
            'errmsg': graph.node[n].get('errmsg', '') or '',
            'timelimit': graph.node[n].get('timelimit', 0),
            'retry': graph.node[n].get('retry', 0),
            'timeout': graph.node[n].get('timeout', 0),
            'start_time': 0.0,
            'end_time': 0.0
        })
        graph.node[n]['task'] = t
        for pred in graph.predecessors(n):
            pred_task = graph.node[pred]['task']
            t.parents.add(pred_task)
            pred_task.save()
        t.save()
コード例 #4
0
ファイル: graph.py プロジェクト: loles/solar-1
def save_graph(graph):
    # maybe it is possible to store part of information in AsyncResult backend
    uid = graph.graph['uid']

    # TODO(dshulyak) remove duplication of parameters
    # in solar_models.Task and this object
    for n in nx.topological_sort(graph):
        t = Task.new(
            {'name': n,
             'execution': uid,
             'status': graph.node[n].get('status', ''),
             'target': graph.node[n].get('target', '') or '',
             'task_type': graph.node[n].get('type', ''),
             'args': graph.node[n].get('args', []),
             'errmsg': graph.node[n].get('errmsg', '') or '',
             'timelimit': graph.node[n].get('timelimit', 0),
             'retry': graph.node[n].get('retry', 0),
             'timeout': graph.node[n].get('timeout', 0),
             'start_time': 0.0,
             'end_time': 0.0})
        graph.node[n]['task'] = t
        for pred in graph.predecessors(n):
            pred_task = graph.node[pred]['task']
            t.parents.add(pred_task)
            pred_task.save()
        t.save()
コード例 #5
0
ファイル: graph.py プロジェクト: openstack/solar
def get_graph(uid):
    mdg = nx.MultiDiGraph()
    mdg.graph['uid'] = uid
    mdg.graph['name'] = uid.split(':')[0]
    tasks_by_uid = {t.key: t for t
                    in Task.multi_get(Task.execution.filter(uid))}
    mdg.add_nodes_from(tasks_by_uid.values())
    mdg.add_edges_from([(tasks_by_uid[parent], task) for task in mdg.nodes()
                        for parent in task.parents.all()])
    return mdg
コード例 #6
0
ファイル: graph.py プロジェクト: openstack/solar
def save_graph(graph):
    for n in nx.topological_sort(graph):
        values = {'name': n, 'execution': graph.graph['uid']}
        values.update(graph.node[n])
        t = Task.new(values)
        graph.node[n]['task'] = t
        for pred in graph.predecessors(n):
            pred_task = graph.node[pred]['task']
            t.parents.add(pred_task)
            pred_task.save()
        t.save_lazy()
コード例 #7
0
ファイル: graph.py プロジェクト: aglarendil/solar
def save_graph(graph):
    # maybe it is possible to store part of information in AsyncResult backend
    uid = graph.graph['uid']

    for n in nx.topological_sort(graph):
        t = Task.new(
            {'name': n,
             'execution': uid,
             'status': graph.node[n].get('status', ''),
             'target': graph.node[n].get('target', '') or '',
             'task_type': graph.node[n].get('type', ''),
             'args': graph.node[n].get('args', []),
             'errmsg': graph.node[n].get('errmsg', '') or ''})
        graph.node[n]['task'] = t
        for pred in graph.predecessors(n):
            pred_task = graph.node[pred]['task']
            t.parents.add(pred_task)
            pred_task.save()
        t.save()
コード例 #8
0
ファイル: graph.py プロジェクト: cvieri/solar
def save_graph(graph):
    # maybe it is possible to store part of information in AsyncResult backend
    uid = graph.graph['uid']

    for n in nx.topological_sort(graph):
        t = Task.new({
            'name': n,
            'execution': uid,
            'status': graph.node[n].get('status', ''),
            'target': graph.node[n].get('target', '') or '',
            'task_type': graph.node[n].get('type', ''),
            'args': graph.node[n].get('args', []),
            'errmsg': graph.node[n].get('errmsg', '') or ''
        })
        graph.node[n]['task'] = t
        for pred in graph.predecessors(n):
            pred_task = graph.node[pred]['task']
            t.parents.add(pred_task)
            pred_task.save()
        t.save()