Ejemplo n.º 1
0
 def mk_cache(spec):
   Subsystem.reset()
   self.set_options_for_scope(CacheSetup.subscope(DummyTask.options_scope),
                              read_from=spec, compression=1)
   self.context(for_task_types=[DummyTask])  # Force option initialization.
   cache_factory = CacheSetup.create_cache_factory_for_task(DummyTask)
   return cache_factory.get_read_cache()
Ejemplo n.º 2
0
 def mk_cache(spec, resolver=None):
   Subsystem.reset()
   self.set_options_for_scope(CacheSetup.subscope(DummyTask.options_scope),
                              read_from=spec, compression=1)
   self.context(for_task_types=[DummyTask])  # Force option initialization.
   cache_factory = CacheSetup.create_cache_factory_for_task(DummyTask,
                                                            pinger=self.pinger,
                                                            resolver=resolver)
   return cache_factory.get_read_cache()
Ejemplo n.º 3
0
 def mk_cache(spec):
     Subsystem.reset()
     self.set_options_for_scope(CacheSetup.subscope(
         DummyTask.options_scope),
                                read_from=spec,
                                compression=1)
     self.context(for_task_types=[DummyTask
                                  ])  # Force option initialization.
     cache_factory = CacheSetup.create_cache_factory_for_task(
         DummyTask,
         pinger=MockPinger({
             'host1': 5,
             'host2:666': 3,
             'host3': 7
         }))
     return cache_factory.get_read_cache()
Ejemplo n.º 4
0
    def __init__(self, context, workdir):
        """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.
    """
        super(TaskBase, self).__init__()
        self.context = context
        self._workdir = workdir
        # TODO: It would be nice to use self.get_options().cache_key_gen_version here, because then
        # we could have a separate value for each scope if we really wanted to. However we can't
        # access per-task options in Task.__init__ because GroupTask.__init__ calls it with the
        # group task's scope, which isn't currently in the known scopes we generate options for.
        self._cache_key_generator = CacheKeyGenerator(
            self.context.options.for_global_scope().cache_key_gen_version)

        self._cache_key_errors = set()

        self._build_invalidator_dir = os.path.join(
            self.context.options.for_global_scope().pants_workdir,
            'build_invalidator', self.stable_name())

        self._cache_factory = CacheSetup.create_cache_factory_for_task(self)

        self._options_fingerprinter = OptionsFingerprinter(
            self.context.build_graph)
        self._fingerprint = None
Ejemplo n.º 5
0
Archivo: task.py Proyecto: wonlay/pants
  def __init__(self, context, workdir):
    """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.

    :API: public
    """
    super(TaskBase, self).__init__()
    self.context = context
    self._workdir = workdir

    self._cache_key_errors = set()

    self._build_invalidator_dir = os.path.join(
      self.context.options.for_global_scope().pants_workdir,
      'build_invalidator',
      self.stable_name())

    self._cache_factory = CacheSetup.create_cache_factory_for_task(self)

    self._options_fingerprinter = OptionsFingerprinter(self.context.build_graph)
Ejemplo n.º 6
0
    def __init__(self, context, workdir):
        """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.
    """
        super(TaskBase, self).__init__()
        self.context = context
        self._workdir = workdir
        # TODO: It would be nice to use self.get_options().cache_key_gen_version here, because then
        # we could have a separate value for each scope if we really wanted to. However we can't
        # access per-task options in Task.__init__ because GroupTask.__init__ calls it with the
        # group task's scope, which isn't currently in the known scopes we generate options for.
        self._cache_key_generator = CacheKeyGenerator(self.context.options.for_global_scope().cache_key_gen_version)

        self._cache_key_errors = set()

        self._build_invalidator_dir = os.path.join(
            self.context.options.for_global_scope().pants_workdir, "build_invalidator", self.stable_name()
        )

        self._cache_factory = CacheSetup.create_cache_factory_for_task(self)
Ejemplo n.º 7
0
    def __init__(self, context, workdir):
        """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.

    :API: public
    """
        super(TaskBase, self).__init__()
        self.context = context
        self._workdir = workdir

        self._cache_key_errors = set()

        self._build_invalidator_dir = os.path.join(
            self.context.options.for_global_scope().pants_workdir,
            'build_invalidator', self.stable_name())

        self._cache_factory = CacheSetup.create_cache_factory_for_task(self)

        self._options_fingerprinter = OptionsFingerprinter(
            self.context.build_graph)
Ejemplo n.º 8
0
 def subsystem_dependencies(cls):
   # NB: `Goal.Options` implements `SubsystemClientMixin` in order to allow v1 `Tasks` to
   # depend on v2 Goals, and for `Goals` to declare a deprecated dependency on a `CacheSetup`
   # instance for backwards compatibility purposes. But v2 Goals should _not_ have subsystem
   # dependencies: instead, the @rules participating (transitively) in a Goal should directly
   # declare their Subsystem deps.
   if outer_cls.deprecated_cache_setup_removal_version:
     dep = CacheSetup.scoped(
         cls,
         removal_version=outer_cls.deprecated_cache_setup_removal_version,
         removal_hint='Goal `{}` uses an independent caching implementation, and ignores `{}`.'.format(
           cls.options_scope,
           CacheSetup.subscope(cls.options_scope),
         )
       )
     return (dep,)
   return tuple()
Ejemplo n.º 9
0
 def subsystem_dependencies(cls):
   # NB: `Goal.Options` implements `SubsystemClientMixin` in order to allow v1 `Tasks` to
   # depend on v2 Goals, and for `Goals` to declare a deprecated dependency on a `CacheSetup`
   # instance for backwards compatibility purposes. But v2 Goals should _not_ have subsystem
   # dependencies: instead, the @rules participating (transitively) in a Goal should directly
   # declare their Subsystem deps.
   if outer_cls.deprecated_cache_setup_removal_version:
     dep = CacheSetup.scoped(
         cls,
         removal_version=outer_cls.deprecated_cache_setup_removal_version,
         removal_hint='Goal `{}` uses an independent caching implementation, and ignores `{}`.'.format(
           cls.options_scope,
           CacheSetup.subscope(cls.options_scope),
         )
       )
     return (dep,)
   return tuple()
Ejemplo n.º 10
0
Archivo: task.py Proyecto: rkstap/pants
  def __init__(self, context, workdir):
    """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.

    :API: public
    """
    super(TaskBase, self).__init__()
    self.context = context
    self._workdir = workdir

    self._task_name = type(self).__name__
    self._cache_key_errors = set()
    self._cache_factory = CacheSetup.create_cache_factory_for_task(self)
    self._force_invalidated = False
Ejemplo n.º 11
0
  def __init__(self, context, workdir):
    """Subclass __init__ methods, if defined, *must* follow this idiom:

    class MyTask(Task):
      def __init__(self, *args, **kwargs):
        super(MyTask, self).__init__(*args, **kwargs)
        ...

    This allows us to change Task.__init__()'s arguments without
    changing every subclass. If the subclass does not need its own
    initialization, this method can (and should) be omitted entirely.

    :API: public
    """
    super(TaskBase, self).__init__()
    self.context = context
    self._workdir = workdir

    self._task_name = type(self).__name__
    self._cache_key_errors = set()
    self._cache_factory = CacheSetup.create_cache_factory_for_task(self)
    self._force_invalidated = False
Ejemplo n.º 12
0
 def subsystem_dependencies(cls):
     return (super().subsystem_dependencies() +
             (CacheSetup.scoped(cls), BuildInvalidator.Factory,
              SourceRootConfig) +
             ((TargetFilter.scoped(cls), )
              if cls.target_filtering_enabled else tuple()))
Ejemplo n.º 13
0
Archivo: task.py Proyecto: rkstap/pants
 def subsystem_dependencies(cls):
   return (super(TaskBase, cls).subsystem_dependencies() +
           (CacheSetup.scoped(cls), BuildInvalidator.Factory, SourceRootConfig))
Ejemplo n.º 14
0
 def subsystem_dependencies(cls):
     return super(TaskBase, cls).subsystem_dependencies() + (
         CacheSetup.scoped(cls), BuildInvalidator.Factory)
Ejemplo n.º 15
0
 def subsystem_dependencies(cls):
   return super(TaskBase, cls).subsystem_dependencies() + (CacheSetup.scoped(cls),
                                                           BuildInvalidator.Factory)
Ejemplo n.º 16
0
 def subsystem_dependencies(cls):
     return super(TaskBase,
                  cls).subsystem_dependencies() + (CacheSetup.scoped(cls), )
Ejemplo n.º 17
0
 def subsystem_dependencies(cls):
   return (super(TaskBase, cls).subsystem_dependencies() +
           (CacheSetup.scoped(cls), BuildInvalidator.Factory, SourceRootConfig) +
           ((TargetFilter.scoped(cls),) if cls.target_filtering_enabled else tuple()))
Ejemplo n.º 18
0
 def subsystem_dependencies(cls):
   return (super(TaskBase, cls).subsystem_dependencies() +
           (CacheSetup.scoped(cls), BuildInvalidator.Factory, SourceRootConfig))
Ejemplo n.º 19
0
Archivo: task.py Proyecto: wonlay/pants
 def subsystem_dependencies(cls):
   return super(TaskBase, cls).subsystem_dependencies() + (CacheSetup.scoped(cls),)
Ejemplo n.º 20
0
 def subsystem_dependencies(cls):
     dep = CacheSetup.scoped(
         Zinc.Factory,
         removal_version='1.20.0.dev0',
         removal_hint='Cache options for `zinc` should move to `rsc`.')
     return super().subsystem_dependencies() + (Rsc, dep.optionable_cls)