testing/trigger_scripts/perf_device_trigger.py
def _query_swarming_for_last_shard_id(self, shard_index):
        """Per shard, query swarming for the last bot that ran the task.

        Example: swarming.py query -S server-url.com --limit 1 \\
          'tasks/list?tags=os:Windows&tags=pool:chrome.tests.perf&tags=shard:12'
        """
        values = ['%s:%s' % (k, v) for k, v in self._dimensions.items()]
        values.sort()

        # Append the shard as a tag
        values_with_shard = list(values)
        values_with_shard.append('%s:%s' % ('shard', str(shard_index)))
        values_with_shard.sort()

        # TODO(eyaich): For now we are ignoring the state of the returned
        # task (ie completed, timed_out, bot_died, etc) as we are just
        # answering the question "What bot did we last trigger this shard on?"
        # Evaluate if this is the right decision going forward.

        # Query for the last task that ran with these dimensions and this shard.
        # Query with the shard param first. This will sometimes time out for
        # queries we've never done before, so try querying without it if that
        # happens.
        try:
            if not self._sharded_query_failed:
                tasks = self.list_tasks(values_with_shard,
                                        limit='1',
                                        server=self._swarming_server)
        except Exception:
            self._sharded_query_failed = True
        if self._sharded_query_failed:
            tasks = self.list_tasks(values,
                                    limit='1',
                                    server=self._swarming_server)

        if tasks:
            # We queried with a limit of 1 so we could only get back
            # the most recent which is what we care about.
            task = tasks[0]
            if 'bot_id' in task:
                return task['bot_id']
            for tag in task['tags']:
                if tag.startswith('id:'):
                    return tag[len('id:'):]
        # No eligible shard for this bot
        return None
Per shard, query swarming for the last bot that ran the task.

        Example: swarming.py query -S server-url.com --limit 1 \\
          'tasks/list?tags=os:Windows&tags=pool:chrome.tests.perf&tags=shard:12'
        
Per shard, query swarming for the last bot that ran the task.
Per shard query swarming for the last bot that ran the task .
def _query_swarming_for_last_shard_id(self, shard_index):
        values = ['%s:%s' % (k, v) for k, v in self._dimensions.items()]
        values.sort()
        values_with_shard = list(values)
        values_with_shard.append('%s:%s' % ('shard', str(shard_index)))
        values_with_shard.sort()
        try:
            if not self._sharded_query_failed:
                tasks = self.list_tasks(values_with_shard,
                                        limit='1',
                                        server=self._swarming_server)
        except Exception:
            self._sharded_query_failed = True
        if self._sharded_query_failed:
            tasks = self.list_tasks(values,
                                    limit='1',
                                    server=self._swarming_server)
        if tasks:
            task = tasks[0]
            if 'bot_id' in task:
                return task['bot_id']
            for tag in task['tags']:
                if tag.startswith('id:'):
                    return tag[len('id:'):]
        return None
def _query_swarming_for_last_shard_id ( self , shard_index ) : values = [ '%s:%s' % ( k , v ) for k , v in self . _dimensions . items ( ) ] values . sort ( ) values_with_shard = list ( values ) values_with_shard . append ( '%s:%s' % ( 'shard' , str ( shard_index ) ) ) values_with_shard . sort ( ) try : if not self . _sharded_query_failed : tasks = self . list_tasks ( values_with_shard , limit = '1' , server = self . _swarming_server ) except Exception : self . _sharded_query_failed = True if self . _sharded_query_failed : tasks = self . list_tasks ( values , limit = '1' , server = self . _swarming_server ) if tasks : task = tasks [ 0 ] if 'bot_id' in task : return task [ 'bot_id' ] for tag in task [ 'tags' ] : if tag . startswith ( 'id:' ) : return tag [ len ( 'id:' ) : ] return None
Per shard, query swarming for the last bot that ran the task.
Per shard query swarming for the last bot that ran the task .
"""Per shard, query swarming for the last bot that ran the task.

        Example: swarming.py query -S server-url.com --limit 1 \\
          'tasks/list?tags=os:Windows&tags=pool:chrome.tests.perf&tags=shard:12'
        """ # Append the shard as a tag # TODO(eyaich): For now we are ignoring the state of the returned # task (ie completed, timed_out, bot_died, etc) as we are just # answering the question "What bot did we last trigger this shard on?" # Evaluate if this is the right decision going forward. # Query for the last task that ran with these dimensions and this shard. # Query with the shard param first. This will sometimes time out for # queries we've never done before, so try querying without it if that # happens. # We queried with a limit of 1 so we could only get back # the most recent which is what we care about. # No eligible shard for this bot
self
shard_index