third_party/blink/tools/blinkpy/web_tests/controllers/web_test_runner.py
def _resize_shards(self, old_shards, max_new_shards, shard_name_prefix):
        """Takes a list of shards and redistributes the tests into no more
        than |max_new_shards| new shards.
        """

        # This implementation assumes that each input shard only contains tests from a
        # single directory, and that tests in each shard must remain together; as a
        # result, a given input shard is never split between output shards.
        #
        # Each output shard contains the tests from one or more input shards and
        # hence may contain tests from multiple directories.

        def divide_and_round_up(numerator, divisor):
            return int(math.ceil(float(numerator) / divisor))

        def extract_and_flatten(shards):
            test_inputs = []
            for shard in shards:
                test_inputs.extend(shard.test_inputs)
            return test_inputs

        def split_at(seq, index):
            return (seq[:index], seq[index:])

        num_old_per_new = divide_and_round_up(len(old_shards), max_new_shards)
        new_shards = []
        remaining_shards = old_shards
        while remaining_shards:
            some_shards, remaining_shards = split_at(remaining_shards,
                                                     num_old_per_new)
            new_shards.append(
                TestShard('%s_%d' % (shard_name_prefix, len(new_shards) + 1),
                          extract_and_flatten(some_shards)))
        return new_shards
Takes a list of shards and redistributes the tests into no more
        than |max_new_shards| new shards.
        
Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards.
Takes a list of shards and redistributes the tests into no more than |max_new_shards| new shards .
def _resize_shards(self, old_shards, max_new_shards, shard_name_prefix):
         Each output shard contains the tests from one or more input shards and
         hence may contain tests from multiple directories.
        def divide_and_round_up(numerator, divisor):
            return int(math.ceil(float(numerator) / divisor))
        def extract_and_flatten(shards):
            test_inputs = []
            for shard in shards:
                test_inputs.extend(shard.test_inputs)
            return test_inputs
        def split_at(seq, index):
            return (seq[:index], seq[index:])
        num_old_per_new = divide_and_round_up(len(old_shards), max_new_shards)
        new_shards = []
        remaining_shards = old_shards
        while remaining_shards:
            some_shards, remaining_shards = split_at(remaining_shards,
                                                     num_old_per_new)
            new_shards.append(
                TestShard('%s_%d' % (shard_name_prefix, len(new_shards) + 1),
                          extract_and_flatten(some_shards)))
        return new_shards
def _resize_shards ( self , old_shards , max_new_shards , shard_name_prefix ) : def divide_and_round_up ( numerator , divisor ) : return int ( math . ceil ( float ( numerator ) / divisor ) ) def extract_and_flatten ( shards ) : test_inputs = [ ] for shard in shards : test_inputs . extend ( shard . test_inputs ) return test_inputs def split_at ( seq , index ) : return ( seq [ : index ] , seq [ index : ] ) num_old_per_new = divide_and_round_up ( len ( old_shards ) , max_new_shards ) new_shards = [ ] remaining_shards = old_shards while remaining_shards : some_shards , remaining_shards = split_at ( remaining_shards , num_old_per_new ) new_shards . append ( TestShard ( '%s_%d' % ( shard_name_prefix , len ( new_shards ) + 1 ) , extract_and_flatten ( some_shards ) ) ) return new_shards
Takes a list of shards and redistributes the tests into no more
than |max_new_shards| new shards.
Takes a list of shards and redistributes the tests into no more than |max_new_shards| new shards .
"""Takes a list of shards and redistributes the tests into no more
        than |max_new_shards| new shards.
        """ # This implementation assumes that each input shard only contains tests from a # single directory, and that tests in each shard must remain together; as a # result, a given input shard is never split between output shards. # # Each output shard contains the tests from one or more input shards and # hence may contain tests from multiple directories.
self
old_shards
max_new_shards
shard_name_prefix