Exemple #1
0
  def __init__(self,
               loop_args: Union[_for_loop.ItemList,
                                _pipeline_param.PipelineParam],
               parallelism: int = None):
    if parallelism and parallelism < 1:
      raise ValueError(
          'ParallelFor parallism set to < 1, allowed values are > 0')

    self.items_is_pipeline_param = isinstance(loop_args,
                                              _pipeline_param.PipelineParam)

    super().__init__(self.TYPE_NAME, parallelism=parallelism)

    if self.items_is_pipeline_param:
      loop_args = _for_loop.LoopArguments.from_pipeline_param(loop_args)
    elif not self.items_is_pipeline_param and not isinstance(
        loop_args, _for_loop.LoopArguments):
      # we were passed a raw list, wrap it in loop args
      loop_args = _for_loop.LoopArguments(
          loop_args,
          code=str(
              _pipeline.Pipeline.get_default_pipeline().get_next_group_id()),
      )

    self.loop_args = loop_args
Exemple #2
0
    def __init__(self,
                 loop_args: Union[_for_loop.ItemList,
                                  _pipeline_param.PipelineParam],
                 parallelism: int = None):
        if parallelism and parallelism < 1:
            raise ValueError(
                'ParallelFor parallism set to < 1, allowed values are > 0')

        self.items_is_pipeline_param = isinstance(
            loop_args, _pipeline_param.PipelineParam)

        # use a random code to uniquely identify this loop
        code = self._get_unique_id_code()
        group_name = 'for-loop-{}'.format(code)
        super().__init__(self.TYPE_NAME,
                         name=group_name,
                         parallelism=parallelism)

        if self.items_is_pipeline_param:
            loop_args = _for_loop.LoopArguments.from_pipeline_param(loop_args)
        elif not self.items_is_pipeline_param and not isinstance(
                loop_args, _for_loop.LoopArguments):
            # we were passed a raw list, wrap it in loop args
            loop_args = _for_loop.LoopArguments(loop_args, code)

        self.loop_args = loop_args
Exemple #3
0
    def __init__(self, loop_args: _for_loop.ItemList):
        # random code to id this loop
        code = self._get_unique_id_code()
        group_name = 'for-loop-{}'.format(code)
        super().__init__(self.TYPE_NAME, name=group_name)

        if not isinstance(loop_args, _for_loop.LoopArguments):
            loop_args = _for_loop.LoopArguments(loop_args, code)

        self.loop_args = loop_args
  def __init__(self, loop_args: Union[_for_loop.ItemList, _pipeline_param.PipelineParam]):
    self.items_is_pipeline_param = isinstance(loop_args, _pipeline_param.PipelineParam)

    # use a random code to uniquely identify this loop
    code = self._get_unique_id_code()
    group_name = 'for-loop-{}'.format(code)
    super().__init__(self.TYPE_NAME, name=group_name)

    if self.items_is_pipeline_param:
      loop_args = _for_loop.LoopArguments.from_pipeline_param(loop_args)
    elif not self.items_is_pipeline_param and not isinstance(loop_args, _for_loop.LoopArguments):
      # we were passed a raw list, wrap it in loop args
      loop_args = _for_loop.LoopArguments(loop_args, code)

    self.loop_args = loop_args