Skip to content

Commit

Permalink
Remove duplicated class and unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbato committed Jun 8, 2018
1 parent a32b40f commit b555d96
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
4 changes: 0 additions & 4 deletions src/python/pants/init/engine_initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
from pants.engine.rules import SingletonRule
from pants.engine.scheduler import Scheduler
from pants.option.global_options import GlobMatchErrorBehavior
<<<<<<< 84084e918921aec1294ffcb77d8c5d0e69921a38
=======
from pants.option.options_bootstrapper import OptionsBootstrapper
>>>>>>> Remove changed_calculator targets and dependencies
from pants.util.objects import datatype


Expand Down
68 changes: 0 additions & 68 deletions src/python/pants/init/target_roots_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,74 +24,6 @@

logger = logging.getLogger(__name__)

class _DependentGraph(object):
"""A graph for walking dependent addresses of TargetAdaptor objects.
This avoids/imitates constructing a v1 BuildGraph object, because that codepath results
in many references held in mutable global state (ie, memory leaks).
The long term goal is to deprecate the `changed` goal in favor of sufficiently good cache
hit rates, such that rather than running:
./pants --changed-parent=master test
...you would always be able to run:
./pants test ::
...and have it complete in a similar amount of time by hitting relevant caches.
"""

@classmethod
def from_iterable(cls, target_types, adaptor_iter):
"""Create a new DependentGraph from an iterable of TargetAdaptor subclasses."""
inst = cls(target_types)
for target_adaptor in adaptor_iter:
inst.inject_target(target_adaptor)
return inst

def __init__(self, target_types):
self._dependent_address_map = defaultdict(set)
self._target_types = target_types

def inject_target(self, target_adaptor):
"""Inject a target, respecting all sources of dependencies."""
target_cls = self._target_types[target_adaptor.type_alias]

declared_deps = target_adaptor.dependencies
implicit_deps = (Address.parse(s)
for s in target_cls.compute_dependency_specs(kwargs=target_adaptor.kwargs()))

for dep in itertools.chain(declared_deps, implicit_deps):
self._dependent_address_map[dep].add(target_adaptor.address)

def dependents_of_addresses(self, addresses):
"""Given an iterable of addresses, yield all of those addresses dependents."""
seen = set(addresses)
for address in addresses:
for dependent_address in self._dependent_address_map[address]:
if dependent_address not in seen:
seen.add(dependent_address)
yield dependent_address

def transitive_dependents_of_addresses(self, addresses):
"""Given an iterable of addresses, yield all of those addresses dependents, transitively."""
addresses_to_visit = set(addresses)
while 1:
dependents = set(self.dependents_of_addresses(addresses))
# If we've exhausted all dependencies or visited all remaining nodes, break.
if (not dependents) or dependents.issubset(addresses_to_visit):
break
addresses = dependents.difference(addresses_to_visit)
addresses_to_visit.update(dependents)

transitive_set = itertools.chain(
*(self._dependent_address_map[address] for address in addresses_to_visit)
)
for dep in transitive_set:
yield dep



class _DependentGraph(object):
"""A graph for walking dependent addresses of TargetAdaptor objects.
Expand Down

0 comments on commit b555d96

Please sign in to comment.