Constructs a TaskStatisticsContext

        :returns: twilio.rest.autopilot.v1.assistant.task.task_statistics.TaskStatisticsContext
        :rtype: twilio.rest.autopilot.v1.assistant.task.task_statistics.TaskStatisticsContext
352195
def get(self):
        
        return TaskStatisticsContext(
            self._version,
            assistant_sid=self._solution['assistant_sid'],
            task_sid=self._solution['task_sid'],
        )
1048365
def rq_task(self):
        
        task_path = self.task.split('.')
        module_name = '.'.join(task_path[:-1])
        task_name = task_path[-1]

        module = importlib.import_module(module_name)
        return getattr(module, task_name)
1251300
def statistics(self):
        
        if self._statistics is None:
            self._statistics = WorkerStatisticsList(
                self._version,
                workspace_sid=self._solution['workspace_sid'],
                worker_sid=self._solution['sid'],
            )
        return self._statistics
259049
def taskinfo(self):
        

        task_input = {'taskName': 'QueryTask',
                      'inputParameters': {"Task_Name": self._name}}

        info = taskengine.execute(task_input, self._engine, cwd=self._cwd)

        task_def = info['outputParameters']['DEFINITION']

        task_def['name'] = str(task_def.pop('NAME'))
        task_def['description'] = str(task_def.pop('DESCRIPTION'))
        task_def['displayName'] = str(task_def.pop('DISPLAY_NAME'))

        if 'COMMUTE_ON_SUBSET' in task_def:
            task_def['commute_on_subset'] = task_def.pop('COMMUTE_ON_SUBSET')
        if 'COMMUTE_ON_DOWNSAMPLE' in task_def:
            task_def['commute_on_downsample'] = task_def.pop('COMMUTE_ON_DOWNSAMPLE')

        # Convert PARAMETERS into a list instead of a dictionary
        # which matches the gsf side things
        task_def['parameters'] = \
            [v for v in task_def['PARAMETERS'].values()]
        task_def.pop('PARAMETERS')

        parameters = task_def['parameters']
        for parameter in parameters:
            parameter['name'] = str(parameter.pop('NAME'))
            parameter['description'] = str(parameter.pop('DESCRIPTION'))
            parameter['display_name'] = str(parameter.pop('DISPLAY_NAME'))
            parameter['required'] = bool(parameter.pop('REQUIRED'))

            if 'MIN' in parameter:
                parameter['min'] = parameter.pop('MIN')

            if 'MAX' in parameter:
                parameter['max'] = parameter.pop('MAX')

            if parameter['TYPE'].count('['):
                parameter['type'], parameter['dimensions'] = parameter.pop('TYPE').split('[')
                parameter['dimensions'] = '[' + parameter['dimensions']
                parameter['type'] = str(parameter['type'])
            else:
                parameter['type'] = str(parameter.pop('TYPE').split('ARRAY')[0])

            if 'DIMENSIONS' in parameter:
                parameter['dimensions'] = parameter.pop('DIMENSIONS')

            if 'DIRECTION' in parameter:
                parameter['direction'] = parameter.pop('DIRECTION').lower()

            if 'DEFAULT' in parameter:
                if parameter['DEFAULT'] is not None:
                    parameter['default_value'] = parameter.pop('DEFAULT')
                else:
                    parameter.pop('DEFAULT')

            if 'CHOICE_LIST' in parameter:
                if parameter['CHOICE_LIST'] is not None:
                    parameter['choice_list'] = parameter.pop('CHOICE_LIST')
                else:
                    parameter.pop('CHOICE_LIST')

            if 'FOLD_CASE' in parameter:
                parameter['fold_case'] = parameter.pop('FOLD_CASE')

            if 'AUTO_EXTENSION' in parameter:
                parameter['auto_extension'] = parameter.pop('AUTO_EXTENSION')

            if 'IS_TEMPORARY' in parameter:
                parameter['is_temporary'] = parameter.pop('IS_TEMPORARY')

            if 'IS_DIRECTORY' in parameter:
                parameter['is_directory'] = parameter.pop('IS_DIRECTORY')

        return task_def
813316
def build_statistics_item(self):
        
        if self.result is not None:
            stats = dict()
            result = self.get_result()
            info = result['info']
            info = info.split(';')
            info = [entry.split(':') for entry in info]

            prefix = 'blackbird.zabbix_sender'

            for entry in info:
                key = entry[0].strip()
                value = None

                if key == 'processed':
                    value = int(entry[1])
                elif key == 'failed':
                    value = int(entry[1])
                elif key == 'total':
                    value = int(entry[1])
                elif key == 'seconds spent':
                    key = key.replace(' ', '_')
                    value = float(entry[1])
                    value *= 1000
                    value = str(round(value, 6))
                else:
                    log_message = (
                        'Blackbird has never seen {key}. {key} is new key??'
                        ''.format(key=key)
                    )
                    self.logger.info(log_message)

                if value is not None:
                    key = '.'.join([prefix, key])
                    stats[key] = value

            if 'response' in result:
                key = '.'.join([prefix, 'response'])
                stats[key] = result['response']

            for key, value in stats.iteritems():
                stats_key_list = [
                    'blackbird.zabbix_sender.processed',
                    'blackbird.zabbix_sender.failed',
                    'blackbird.zabbix_sender.total',
                ]
                item = BlackbirdStatisticsItem(
                    key=key,
                    value=value,
                    host=self.options['hostname']
                )
                if key in stats_key_list:
                    if self.enqueue(item=item, queue=self.stats_queue):
                        self.logger.debug(
                            'Inserted {0} to the statistics queue'
                            ''.format(item.data)
                        )
                else:
                    if self.enqueue(item=item, queue=self.queue):
                        self.logger.debug(
                            'Inserted {0} to the queue'.format(item.data)
                        )
1187449
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return TaskActionsInstance(
            self._version,
            payload,
            assistant_sid=self._solution['assistant_sid'],
            task_sid=self._solution['task_sid'],
        )
1020435
def statistics(self):
        
        if self._statistics is None:
            self._statistics = WorkspaceStatisticsList(self._version, workspace_sid=self._solution['sid'], )
        return self._statistics
740333
def SampleTaskStatus(self, task, status):
    
    if self._tasks_profiler:
      self._tasks_profiler.Sample(task, status)
954280
async def _report(self):
        
        while True:
            oldstatus = dict(self.status)
            stat = await self._updateq.get()
            if self._update_cb is not None and oldstatus != stat:
                # Each client gets its own copy of the dict.
                self.loop.create_task(self._update_cb(dict(stat)))
967139
def create_tasks_dict(self, ast):
        '''
        
        '''
        tasks = self.find_asts(ast, 'Task')
        for task in tasks:
            self.parse_task(task)
        return self.tasks_dictionary
371532
def _task_table(self, task_id):
        
        assert isinstance(task_id, ray.TaskID)
        message = self._execute_command(task_id, "RAY.TABLE_LOOKUP",
                                        ray.gcs_utils.TablePrefix.RAYLET_TASK,
                                        "", task_id.binary())
        if message is None:
            return {}
        gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry(
            message, 0)

        assert gcs_entries.EntriesLength() == 1

        task_table_message = ray.gcs_utils.Task.GetRootAsTask(
            gcs_entries.Entries(0), 0)

        execution_spec = task_table_message.TaskExecutionSpec()
        task_spec = task_table_message.TaskSpecification()
        task = ray._raylet.Task.from_string(task_spec)
        function_descriptor_list = task.function_descriptor_list()
        function_descriptor = FunctionDescriptor.from_bytes_list(
            function_descriptor_list)

        task_spec_info = {
            "DriverID": task.driver_id().hex(),
            "TaskID": task.task_id().hex(),
            "ParentTaskID": task.parent_task_id().hex(),
            "ParentCounter": task.parent_counter(),
            "ActorID": (task.actor_id().hex()),
            "ActorCreationID": task.actor_creation_id().hex(),
            "ActorCreationDummyObjectID": (
                task.actor_creation_dummy_object_id().hex()),
            "ActorCounter": task.actor_counter(),
            "Args": task.arguments(),
            "ReturnObjectIDs": task.returns(),
            "RequiredResources": task.required_resources(),
            "FunctionID": function_descriptor.function_id.hex(),
            "FunctionHash": binary_to_hex(function_descriptor.function_hash),
            "ModuleName": function_descriptor.module_name,
            "ClassName": function_descriptor.class_name,
            "FunctionName": function_descriptor.function_name,
        }

        return {
            "ExecutionSpec": {
                "Dependencies": [
                    execution_spec.Dependencies(i)
                    for i in range(execution_spec.DependenciesLength())
                ],
                "LastTimestamp": execution_spec.LastTimestamp(),
                "NumForwards": execution_spec.NumForwards()
            },
            "TaskSpec": task_spec_info
        }
655493
def compute_statistic(self, layout):
        
        data = self.data
        if not len(data):
            return type(data)()

        params = self.stat.setup_params(data)
        data = self.stat.use_defaults(data)
        data = self.stat.setup_data(data)
        data = self.stat.compute_layer(data, params, layout)
        self.data = data
134932
def GetStatusInformation(self):
    
    status = processing_status.TasksStatus()

    with self._lock:
      status.number_of_abandoned_tasks = len(self._tasks_abandoned)
      status.number_of_queued_tasks = len(self._tasks_queued)
      status.number_of_tasks_pending_merge = (
          len(self._tasks_pending_merge) + len(self._tasks_merging))
      status.number_of_tasks_processing = len(self._tasks_processing)
      status.total_number_of_tasks = self._total_number_of_tasks

    return status
1175566
def serialize(self):
        
        data = {
            'task_id': self.task_id,
            'retries': self.retries,
            'async': self.async,
            'module': determine_module(self.func),
            'callable': determine_name(self.func),
            'args': self.func_args,
            'kwargs': self.func_kwargs,
            'options': {},
        }

        if self.on_start:
            data['options']['on_start'] = {
                'module': determine_module(self.on_start),
                'callable': determine_name(self.on_start),
            }

        if self.on_success:
            data['options']['on_success'] = {
                'module': determine_module(self.on_success),
                'callable': determine_name(self.on_success),
            }

        if self.on_error:
            data['options']['on_error'] = {
                'module': determine_module(self.on_error),
                'callable': determine_name(self.on_error),
            }

        return json.dumps(data)
113814
def statistics(self):
        
        if self._statistics is None:
            self._statistics = WorkersStatisticsList(
                self._version,
                workspace_sid=self._solution['workspace_sid'],
            )
        return self._statistics
444984
def GetProcessedTaskByIdentifier(self, task_identifier):
    
    with self._lock:
      task = self._tasks_processing.get(task_identifier, None)
      if not task:
        task = self._tasks_queued.get(task_identifier, None)
      if not task:
        task = self._tasks_abandoned.get(task_identifier, None)
      if not task:
        raise KeyError('Status of task {0:s} is unknown'.format(
            task_identifier))

    return task
761929
def get(self):
        
        return TaskActionsContext(
            self._version,
            assistant_sid=self._solution['assistant_sid'],
            task_sid=self._solution['task_sid'],
        )