Retrieves batch child tasks for this task if its a batch task.
        :return: Collection instance.
        :raises SbError if task is not a batch task.
180962
def get_batch_children(self):
        
        if not self.batch:
            raise SbgError("This task is not a batch task.")
        return self.query(parent=self.id, api=self._api)
200937
def task(self) -> Tuple[str, Any]:
        
        try:
            items, = self.configuration.items()
        except ValueError:
            raise MultipleTaskDefinitions(
                'Multiple tasks defined in scenario configuration!',
            )
        return items
757834
def subtasks(self, task, params={}, **options): 
        
        path = "/tasks/%s/subtasks" % (task)
        return self.client.get_collection(path, params, **options)
534401
def next_task(self, item, raise_exceptions=None, **kwargs):
        
        filename = os.path.basename(item)
        batch = self.get_batch(filename)
        tx_deserializer = self.tx_deserializer_cls(
            allow_self=self.allow_self, override_role=self.override_role
        )
        try:
            tx_deserializer.deserialize_transactions(
                transactions=batch.saved_transactions
            )
        except (DeserializationError, TransactionDeserializerError) as e:
            raise TransactionsFileQueueError(e) from e
        else:
            batch.close()
            self.archive(filename)
1144474
def get_task(self, task=None):
        
        # Iterate over the grindstone tasks
        for t in self.grindstone['tasks']:
            # if they key matches the task
            if key_of(t) == task:
                # Return this task
                return t
        # Otherwise return nothing
        return None
887596
def tasks(self):
        
        if self._tasks is None:
            self._tasks = TaskList(self._version, assistant_sid=self._solution['sid'], )
        return self._tasks
760317
def batch_work(self):
        

        while True:
            gen = collect_fragment(self._stop_event, self.config['AGORA'])
            for collector, (t, s, p, o) in gen:
                for task in _batch_tasks:
                    task(collector, (t, s, p, o), self._stop_event)
                if self._stop_event.isSet():
                    return
            for task in _batch_tasks:
                task(None, None, self._stop_event)
            time.sleep(10)
1305969
def _nextTaskLevel(self):
        
        if not self._last_child:
            self._last_child = self._task_level.child()
        else:
            self._last_child = self._last_child.next_sibling()
        return self._last_child
142062
def task_queues(self):
        
        if self._task_queues is None:
            self._task_queues = TaskQueueList(self._version, workspace_sid=self._solution['sid'], )
        return self._task_queues
784235
def projects(self, task, params={}, **options): 
        
        path = "/tasks/%s/projects" % (task)
        return self.client.get_collection(path, params, **options)
788054
def group_tasks(self):
        """"""
        tasks = set()
        for node in walk_tree(self):
            for ctrl in node.controllers.values():
                tasks.update(ctrl.tasks)
        return tasks
594231
def output(self):
        
        if self.task.target_collection_cls is not None:
            cls = self.task.target_collection_cls
        elif self.task.outputs_siblings:
            cls = SiblingFileCollection
        else:
            cls = TargetCollection

        targets = luigi.task.getpaths(self.task.get_branch_tasks())
        collection = cls(targets, threshold=self.threshold(len(targets)))

        return OrderedDict([("collection", collection)])
958657
def get_task_results(self):
        

        results = self.get_task_results_without_format()
        if options.tunnel.string_as_binary:
            return compat.OrderedDict([(k, bytes(result)) for k, result in six.iteritems(results)])
        else:
            return compat.OrderedDict([(k, str(result)) for k, result in six.iteritems(results)])
53571
def get_expired_tasks(self, key_prefix, time, batch_size, client=None):
        
        result = self._get_expired_tasks(args=[key_prefix, time, batch_size],
                                         client=client)

        # [queue1, task1, queue2, task2] -> [(queue1, task1), (queue2, task2)]
        return list(zip(result[::2], result[1::2]))
110288
def parameters(self):
        
        parameters = []
        for task in self.tasks:
            parameters.extend(task.parameters)
        return parameters
474979
def tasks(self):
        
        # We do here some lazy loading.
        if not self._tasks:
            self._tasks = TaskManager(self)
        return self._tasks
2827
def get_batches(qp_pairs, batch_size, need_sort=True):
    '''
    
    '''
    if need_sort:
        qp_pairs = sorted(qp_pairs, key=lambda qp: (
            len(qp['passage_tokens']), qp['id']), reverse=True)
    batches = [{'qp_pairs': qp_pairs[i:(i + batch_size)]}
               for i in range(0, len(qp_pairs), batch_size)]
    shuffle(batches)
    return batches