def _validate(self):
        for group, dbs in self.partition_config['groups'].items():
            for db in dbs:
                if db not in self.database_config:
                    raise PartitionValidationError('{} not in found in DATABASES'.format(db))

        shards_seen = set()
        previous_range = None
        for group, shard_range, in sorted(self.partition_config['shards'].items(), key=lambda x: x[1]):
            if not previous_range:
                if shard_range[0] != 0:
                    raise NotZeroStartError('Shard numbering must start at 0')
            else:
                if previous_range[1] + 1 != shard_range[0]:
                    raise NonContinuousShardsError(
                        'Shards must be numbered consecutively: {} -> {}'.format(
                            previous_range[1], shard_range[0]
                        ))

            shards_seen |= set(range(shard_range[0], shard_range[1] + 1))
            previous_range = shard_range

        num_shards = len(shards_seen)

        if not _is_power_of_2(num_shards):
            raise NotPowerOf2Error('Total number of shards must be a power of 2')
dataset/ETHPy150Open dimagi/commcare-hq/corehq/sql_db/config.py/PartitionConfig._validate/original