當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。