當前位置: 首頁>>代碼示例>>Python>>正文


Python GraphMaker.generate_subgraph方法代碼示例

本文整理匯總了Python中pants.engine.rules.GraphMaker.generate_subgraph方法的典型用法代碼示例。如果您正苦於以下問題:Python GraphMaker.generate_subgraph方法的具體用法?Python GraphMaker.generate_subgraph怎麽用?Python GraphMaker.generate_subgraph使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pants.engine.rules.GraphMaker的用法示例。


在下文中一共展示了GraphMaker.generate_subgraph方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_select_dependencies_recurse_with_different_type

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_dependencies_recurse_with_different_type(self):
    rules = [
      (Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop),
      (B, (Select(A),), noop),
      (C, (Select(SubA),), noop),
      (SubA, tuple(), noop)
    ]

    graphmaker = GraphMaker(RuleIndex.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules:
                                        Select(A) for SubA => ((Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of SubA,)
                                        all_rules:
                                        (B, (Select(A),), noop) of C => ((Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of C,)
                                        (B, (Select(A),), noop) of D => ((Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of D,)
                                        (Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of C => ((SubA, (), noop) of C, (B, (Select(A),), noop) of C, (B, (Select(A),), noop) of D,)
                                        (Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of D => ((SubA, (), noop) of D, (B, (Select(A),), noop) of C, (B, (Select(A),), noop) of D,)
                                        (Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop) of SubA => (SubjectIsProduct(SubA), (B, (Select(A),), noop) of C, (B, (Select(A),), noop) of D,)
                                        (SubA, (), noop) of C => (,)
                                        (SubA, (), noop) of D => (,)
                                      }""").strip(),
                                    subgraph)
開發者ID:mateor,項目名稱:pants,代碼行數:29,代碼來源:test_rules.py

示例2: test_noop_removal_transitive

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_noop_removal_transitive(self):
    # If a noop-able rule has rules that depend on it,
    # they should be removed from the graph.
    rules = [
      (Exactly(B), (Select(C),), noop),
      (Exactly(A), (Select(B),), noop),
      (Exactly(A), tuple(), noop),
    ]
    intrinsics = [
      (D, C, BoringRule(C))
    ]
    graphmaker = GraphMaker(RuleIndex.create(rules, intrinsics),
      root_subject_fns=_suba_root_subject_fns,

    )
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    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(), subgraph)
開發者ID:mateor,項目名稱:pants,代碼行數:27,代碼來源:test_rules.py

示例3: test_single_rule_depending_on_subject_selection

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_single_rule_depending_on_subject_selection(self):
    rules = [
      (Exactly(A), (Select(SubA),), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    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(), subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:17,代碼來源:test_rules.py

示例4: test_select_literal

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_literal(self):
    literally_a = A()
    rules = [
      (B, (SelectLiteral(literally_a, A),), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=B)

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules: (B, (SelectLiteral(A(), A),), noop) of SubA
                                 (B, (SelectLiteral(A(), A),), noop) of SubA => (Literal(A(), A),)
                               }""").strip(), subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:18,代碼來源:test_rules.py

示例5: test_select_dependencies_non_matching_subselector_because_of_intrinsic

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_dependencies_non_matching_subselector_because_of_intrinsic(self):
    rules = [
      (Exactly(A), (SelectDependencies(B, SubA, field_types=(D,)),), noop),
    ]
    intrinsics = [
      (C, B, noop),
    ]
    graphmaker = GraphMaker(RuleIndex.create(rules, intrinsics),
                            root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing('{empty graph}', subgraph)
    self.assert_equal_with_printing(dedent("""
                         Rules with errors: 1
                           (Exactly(A), (SelectDependencies(B, SubA, field_types=(D,)),), noop):
                             no matches for Select(B) when resolving SelectDependencies(B, SubA, field_types=(D,)) with subject types: D""").strip(),
                                    subgraph.error_message())
開發者ID:mateor,項目名稱:pants,代碼行數:19,代碼來源:test_rules.py

示例6: test_depends_on_multiple_one_noop

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_depends_on_multiple_one_noop(self):
    rules = [
      (B, (Select(A),), noop),
      (A, (Select(C),), noop),
      (A, (Select(SubA),), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=B)

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules: (B, (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,)
                               }""").strip(), subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:20,代碼來源:test_rules.py

示例7: test_select_dependencies_with_subject_as_first_subselector

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_dependencies_with_subject_as_first_subselector(self):
    rules = [
      (Exactly(A), (SelectDependencies(B, SubA, field_types=(D,)),), noop),
      (B, (Select(D),), noop),
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules: (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(D,)),), noop) of SubA
                                        (B, (Select(D),), noop) of D => (SubjectIsProduct(D),)
                                        (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(D,)),), noop) of SubA => (SubjectIsProduct(SubA), (B, (Select(D),), noop) of D,)
                                      }""").strip(),
                                    subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:20,代碼來源:test_rules.py

示例8: test_one_level_of_recursion

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_one_level_of_recursion(self):
    rules = [
      (Exactly(A), (Select(B),), noop),
      (B, (Select(SubA),), noop)
    ]

    graphmaker = GraphMaker(RuleIndex.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules:
                                 Select(A) for SubA => ((Exactly(A), (Select(B),), noop) of SubA,)
                                 all_rules:
                                 (B, (Select(SubA),), noop) of SubA => (SubjectIsProduct(SubA),)
                                 (Exactly(A), (Select(B),), noop) of SubA => ((B, (Select(SubA),), noop) of SubA,)
                               }""").strip(), subgraph)
開發者ID:mateor,項目名稱:pants,代碼行數:21,代碼來源:test_rules.py

示例9: test_successful_when_one_field_type_is_unfulfillable

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_successful_when_one_field_type_is_unfulfillable(self):
    # NB We may want this to be a warning, since it may not be intentional
    rules = [
      (B, (Select(SubA),), noop),
      (D, (Select(Exactly(B)), SelectDependencies(B, SubA, field_types=(SubA, C))), noop)
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=D)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules: (D, (Select(Exactly(B)), SelectDependencies(B, SubA, u'dependencies', field_types=(SubA, C,))), noop) of SubA
                                        (B, (Select(SubA),), noop) of SubA => (SubjectIsProduct(SubA),)
                                        (D, (Select(Exactly(B)), SelectDependencies(B, SubA, u'dependencies', field_types=(SubA, C,))), noop) of SubA => ((B, (Select(SubA),), noop) of SubA, SubjectIsProduct(SubA), (B, (Select(SubA),), noop) of SubA,)
                                      }""").strip(),
      subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:21,代碼來源:test_rules.py

示例10: test_noop_removal_in_subgraph

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_noop_removal_in_subgraph(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)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                               {
                                 root_subject_types: (SubA,)
                                 root_rules: (Exactly(A), (), noop) of SubA
                                 (Exactly(A), (), noop) of SubA => (,)
                               }""").strip(), subgraph)
開發者ID:CaitieM20,項目名稱:pants,代碼行數:21,代碼來源:test_rules.py

示例11: test_select_projection_simple

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_projection_simple(self):
    rules = [
      (Exactly(A), (SelectProjection(B, D, ('some',), SubA),), noop),
      (B, (Select(D),), noop),
    ]

    graphmaker = GraphMaker(RuleIndex.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules:
                                        Select(A) for SubA => ((Exactly(A), (SelectProjection(B, D, (u'some',), SubA),), noop) of SubA,)
                                        all_rules:
                                        (B, (Select(D),), noop) of D => (SubjectIsProduct(D),)
                                        (Exactly(A), (SelectProjection(B, D, (u'some',), SubA),), noop) of SubA => (SubjectIsProduct(SubA), (B, (Select(D),), noop) of D,)
                                      }""").strip(),
                                    subgraph)
開發者ID:mateor,項目名稱:pants,代碼行數:22,代碼來源:test_rules.py

示例12: test_select_dependencies_with_matching_intrinsic

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_dependencies_with_matching_intrinsic(self):
    rules = [
      (Exactly(A), (SelectDependencies(B, SubA, field_types=(C,)),), noop),
    ]
    intrinsics = [
      (B, C, noop),
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, intrinsics),
                            root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules: (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(C,)),), noop) of SubA
                                        (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(C,)),), noop) of SubA => (SubjectIsProduct(SubA), IntrinsicRule(noop) of C,)
                                        IntrinsicRule(noop) of C => (,)
                                      }""").strip(),
                                    subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:22,代碼來源:test_rules.py

示例13: test_select_dependencies_multiple_field_types_all_resolvable_with_deps

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_select_dependencies_multiple_field_types_all_resolvable_with_deps(self):
    rules = [
      (Exactly(A), (SelectDependencies(B, SubA, field_types=(C, D,)),), noop),
      # for the C type, it'll just be a literal, but for D, it'll traverse one more edge
      (B, (Select(C),), noop),
      (C, (Select(D),), noop),
    ]

    graphmaker = GraphMaker(NodeBuilder.create(rules, tuple()),
      root_subject_fns=_suba_root_subject_fns)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    self.assert_equal_with_printing(dedent("""
                                      {
                                        root_subject_types: (SubA,)
                                        root_rules: (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(C, D,)),), noop) of SubA
                                        (B, (Select(C),), noop) of C => (SubjectIsProduct(C),)
                                        (B, (Select(C),), noop) of D => ((C, (Select(D),), noop) of D,)
                                        (C, (Select(D),), noop) of D => (SubjectIsProduct(D),)
                                        (Exactly(A), (SelectDependencies(B, SubA, u'dependencies', field_types=(C, D,)),), noop) of SubA => (SubjectIsProduct(SubA), (B, (Select(C),), noop) of C, (B, (Select(C),), noop) of D,)
                                      }""").strip(),
                                    subgraph)
開發者ID:ericzundel,項目名稱:pants,代碼行數:24,代碼來源:test_rules.py

示例14: test_noop_removal_in_subgraph

# 需要導入模塊: from pants.engine.rules import GraphMaker [as 別名]
# 或者: from pants.engine.rules.GraphMaker import generate_subgraph [as 別名]
  def test_noop_removal_in_subgraph(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)
    subgraph = graphmaker.generate_subgraph(SubA(), requested_product=A)

    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(), subgraph)
開發者ID:mateor,項目名稱:pants,代碼行數:25,代碼來源:test_rules.py


注:本文中的pants.engine.rules.GraphMaker.generate_subgraph方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。