compute_build_graph.py 文件源码

python
阅读 44 收藏 0 点赞 0 评论 0

项目:conda-gitlab-ci 作者: conda 项目源码 文件源码
def order_build(graph, packages=None, level=0, filter_dirty=True):
    '''
    Assumes that packages are in graph.
    Builds a temporary graph of relevant nodes and returns it topological sort.

    Relevant nodes selected in a breadth first traversal sourced at each pkg
    in packages.

    Values expected for packages is one of None, sequence:
       None: build the whole graph
       empty sequence: build nodes marked dirty
       non-empty sequence: build nodes in sequence
    '''

    if not packages:
        packages = graph.nodes()
        if filter_dirty:
            packages = dirty(graph)
    tmp_global = graph.subgraph(packages)

    # copy relevant node data to tmp_global
    for n in tmp_global.nodes_iter():
        tmp_global.node[n] = graph.node[n]

    try:
        order = nx.topological_sort(tmp_global, reverse=True)
    except nx.exception.NetworkXUnfeasible:
        raise ValueError("Cycles detected in graph: {0}".format(nx.find_cycle(tmp_global,
                                                                       orientation='ignore')))

    return tmp_global, order
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号