Beispiel #1
0
def create_legacy_graph_tasks(symbol_table_cls):
  """Create tasks to recursively parse the legacy graph."""
  symbol_table_constraint = symbol_table_cls.constraint()
  return [
    # Recursively requests HydratedTargets, which will result in an eager, transitive graph walk.
    (HydratedTargets,
     [SelectTransitive(HydratedTarget,
                       Addresses,
                       field_types=(BuildFileAddress,))],
     HydratedTargets),
    (HydratedTarget,
     [Select(symbol_table_constraint),
      SelectDependencies(HydratedField,
                         symbol_table_constraint,
                         'field_adaptors',
                         field_types=(SourcesField, BundlesField,))],
     hydrate_target),
    (HydratedField,
     [Select(SourcesField),
      SelectProjection(Snapshot, PathGlobs, ('path_globs',), SourcesField)],
     hydrate_sources),
    (HydratedField,
     [Select(BundlesField),
      SelectDependencies(Snapshot, BundlesField, 'path_globs_list', field_types=(PathGlobs,))],
     hydrate_bundles),
  ]
Beispiel #2
0
  def test_select_transitive_with_separate_types_for_subselectors(self):
    rules = [
      TaskRule(Exactly(A), [SelectTransitive(B, C, field_types=(D,))], noop),
      TaskRule(B, [Select(D)], noop),
      TaskRule(C, [Select(SubA)], noop)
    ]

    subgraph = self.create_subgraph(A, rules, SubA())

    self.assert_equal_with_printing(dedent("""
                     digraph {
                       // root subject types: SubA
                       // root entries
                         "Select(A) for SubA" [color=blue]
                         "Select(A) for SubA" -> {"(A, (SelectTransitive(B, C, field_types=(D,)),), noop) of SubA"}
                       // internal entries
                         "(A, (SelectTransitive(B, C, field_types=(D,)),), noop) of SubA" -> {"(C, (Select(SubA),), noop) of SubA" "(B, (Select(D),), noop) of D"}
                         "(B, (Select(D),), noop) of D" -> {"SubjectIsProduct(D)"}
                         "(C, (Select(SubA),), noop) of SubA" -> {"SubjectIsProduct(SubA)"}
                     }""").strip(),
      subgraph)
Beispiel #3
0
    def __hash__(self):
        return hash(self.address)


class TransitiveHydratedTargets(Collection.of(HydratedTarget)):
    """A transitive set of HydratedTarget objects."""


class HydratedTargets(Collection.of(HydratedTarget)):
    """An intransitive set of HydratedTarget objects."""


@rule(TransitiveHydratedTargets, [
    SelectTransitive(HydratedTarget,
                     BuildFileAddresses,
                     field_types=(Address, ),
                     field='addresses')
])
def transitive_hydrated_targets(targets):
    """Recursively requests HydratedTarget instances, which will result in an eager, transitive graph walk."""
    return TransitiveHydratedTargets(targets)


@rule(HydratedTargets, [
    SelectDependencies(HydratedTarget,
                       BuildFileAddresses,
                       field_types=(Address, ),
                       field='addresses')
])
def hydrated_targets(targets):
    """Requests HydratedTarget instances."""