当前位置: 首页>>代码示例>>Python>>正文


Python GraphMaker.full_graph方法代码示例

本文整理汇总了Python中pants.engine.rules.GraphMaker.full_graph方法的典型用法代码示例。如果您正苦于以下问题:Python GraphMaker.full_graph方法的具体用法?Python GraphMaker.full_graph怎么用?Python GraphMaker.full_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pants.engine.rules.GraphMaker的用法示例。


在下文中一共展示了GraphMaker.full_graph方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_full_graph_for_planner_example

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_full_graph_for_planner_example(self):
    symbol_table_cls = TargetTable
    address_mapper = AddressMapper(symbol_table_cls, JsonParser, '*.BUILD.json')
    tasks = create_graph_tasks(address_mapper, symbol_table_cls) + create_fs_tasks()
    intrinsics = create_fs_intrinsics('Let us pretend that this is a ProjectTree!')

    rule_index = RuleIndex.create(tasks, intrinsics)
    graphmaker = GraphMaker(rule_index,
      root_subject_fns={k: lambda p: Select(p) for k in (Address, # TODO, use the actual fns.
                          PathGlobs,
                          SingleAddress,
                          SiblingAddresses,
                          DescendantAddresses,
                          AscendantAddresses
      )})
    fullgraph = graphmaker.full_graph()
    print('---diagnostic------')
    print(fullgraph.error_message())
    print('/---diagnostic------')
    print(fullgraph)


    # Assert that all of the rules specified the various task fns are present
    declared_rules = rule_index.all_rules()
    rules_remaining_in_graph_strs = set(str(r.rule) for r in fullgraph.rule_dependencies.keys())

    declared_rule_strings = set(str(r) for r in declared_rules)
    self.assertEquals(declared_rule_strings,
      rules_remaining_in_graph_strs
    )

    # statically assert that the number of dependency keys is fixed
    self.assertEquals(41, len(fullgraph.rule_dependencies))
开发者ID:mateor,项目名称:pants,代码行数:35,代码来源:test_rules.py

示例2: test_smallest_full_test

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_smallest_full_test(self):
    rules = [
      (Exactly(A), (Select(SubA),), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns={k: lambda p: Select(p) for k in (SubA,)})
    fullgraph = graphmaker.full_graph()

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules: (Exactly(A), (Select(SubA),), noop) of SubA
                                 (Exactly(A), (Select(SubA),), noop) of SubA => (SubjectIsProduct(SubA),)
                               }""").strip(), fullgraph)
开发者ID:ericzundel,项目名称:pants,代码行数:17,代码来源:test_rules.py

示例3: test_multiple_depend_on_same_rule

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_multiple_depend_on_same_rule(self):
    rules = [
      (B, (Select(A),), noop),
      (C, (Select(A),), noop),
      (A, (Select(SubA),), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.full_graph()

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules: (A, (Select(SubA),), noop) of SubA, (B, (Select(A),), noop) of SubA, (C, (Select(A),), noop) of SubA
                                        (A, (Select(SubA),), noop) of SubA => (SubjectIsProduct(SubA),)
                                        (B, (Select(A),), noop) of SubA => ((A, (Select(SubA),), noop) of SubA,)
                                        (C, (Select(A),), noop) of SubA => ((A, (Select(SubA),), noop) of SubA,)
                                      }""").strip(), subgraph)
开发者ID:ericzundel,项目名称:pants,代码行数:21,代码来源:test_rules.py

示例4: test_smallest_full_test_multiple_root_subject_types

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_smallest_full_test_multiple_root_subject_types(self):
    rules = [
      (Exactly(A), (Select(SubA),), noop),
      (Exactly(B), (Select(A),), noop)
    ]
    select_p = lambda p: Select(p)
    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=OrderedDict([(SubA, select_p), (A, select_p)]))
    fullgraph = graphmaker.full_graph()

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA, A,)
                                        root_rules: (Exactly(A), (Select(SubA),), noop) of SubA, (Exactly(B), (Select(A),), noop) of A, (Exactly(B), (Select(A),), noop) of SubA, SubjectIsProduct(A)
                                        (Exactly(A), (Select(SubA),), noop) of SubA => (SubjectIsProduct(SubA),)
                                        (Exactly(B), (Select(A),), noop) of A => (SubjectIsProduct(A),)
                                        (Exactly(B), (Select(A),), noop) of SubA => ((Exactly(A), (Select(SubA),), noop) of SubA,)
                                      }""").strip(),
                                    fullgraph)
开发者ID:ericzundel,项目名称:pants,代码行数:21,代码来源:test_rules.py

示例5: test_noop_removal_full_single_subject_type

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_noop_removal_full_single_subject_type(self):
    intrinsics = {(B, C): BoringRule(C)}
    rules = [
      # C is provided by an intrinsic, but only if the subject is B.
      (Exactly(A), (Select(C),), noop),
      (Exactly(A), tuple(), noop),
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules,
      intrinsic_providers=(IntrinsicProvider(intrinsics),)),
      root_subject_fns=_suba_root_subject_fns)
    fullgraph = graphmaker.full_graph()

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules: (Exactly(A), (), noop) of SubA
                                 (Exactly(A), (), noop) of SubA => (,)
                               }""").strip(), fullgraph)
开发者ID:CaitieM20,项目名称:pants,代码行数:21,代码来源:test_rules.py

示例6: test_noop_removal_full_single_subject_type

# 需要导入模块: from pants.engine.rules import GraphMaker [as 别名]
# 或者: from pants.engine.rules.GraphMaker import full_graph [as 别名]
  def test_noop_removal_full_single_subject_type(self):
    rules = [
      # C is provided by an intrinsic, but only if the subject is B.
      (Exactly(A), (Select(C),), noop),
      (Exactly(A), tuple(), noop),
    ]
    intrinsics = [
      (B, C, noop),
    ]

    graphmaker = GraphMaker(RuleIndex.create(rules, intrinsics),
                            root_subject_fns=_suba_root_subject_fns)
    fullgraph = graphmaker.full_graph()

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules:
                                 Select(A) for SubA => ((Exactly(A), (), noop) of SubA,)
                                 all_rules:
                                 (Exactly(A), (), noop) of SubA => (,)
                               }""").strip(), fullgraph)
开发者ID:mateor,项目名称:pants,代码行数:24,代码来源:test_rules.py


注:本文中的pants.engine.rules.GraphMaker.full_graph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。