)]}'
{"swift/common/ring/builder.py":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"5931755a887cc9440dad3f1f03e42efc96837028","unresolved":false,"context_lines":[{"line_number":492,"context_line":"        if random_state:"},{"line_number":493,"context_line":"            # reset random state so that seeds set by unit tests of this module"},{"line_number":494,"context_line":"            # do not cause repeatable results from calls to random elsewhere"},{"line_number":495,"context_line":"            random.setstate(random_state)"},{"line_number":496,"context_line":""},{"line_number":497,"context_line":"        return changed_parts, self.get_balance(), removed_devs"},{"line_number":498,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9a629dbe_a5d0e054","line":495,"updated":"2016-11-08 18:45:46.000000000","message":"Are there any exceptions that could get raised in between setting and restoring random_state? Should this be in a finally block?\n\nIs there a reason that we want to restore the previous state rather than just calling\n\n random.seed()\n\n?","commit_id":"a90d7e3257bcf3528acb3aa818dcbe009d3458ef"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"dc8c4b1037b7ea06c4fce882982e54bb2b85a876","unresolved":false,"context_lines":[{"line_number":492,"context_line":"        if random_state:"},{"line_number":493,"context_line":"            # reset random state so that seeds set by unit tests of this module"},{"line_number":494,"context_line":"            # do not cause repeatable results from calls to random elsewhere"},{"line_number":495,"context_line":"            random.setstate(random_state)"},{"line_number":496,"context_line":""},{"line_number":497,"context_line":"        return changed_parts, self.get_balance(), removed_devs"},{"line_number":498,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"9a629dbe_ceec87bd","line":495,"in_reply_to":"9a629dbe_a5d0e054","updated":"2016-11-11 14:29:57.000000000","message":"good call re try/finally\n\nIIRC I rest the original state to allow unit testing to verify the reset. Maybe if I thought harder I could write a test if I used random.seed() but this seems expedient.","commit_id":"a90d7e3257bcf3528acb3aa818dcbe009d3458ef"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"48d8b23d85a5100b9ec56411a9d2bbe78c84ad8d","unresolved":false,"context_lines":[{"line_number":56,"context_line":"            pass"},{"line_number":57,"context_line":""},{"line_number":58,"context_line":""},{"line_number":59,"context_line":"@contextlib.contextmanager"},{"line_number":60,"context_line":"def _set_random_seed(seed):"},{"line_number":61,"context_line":"    # If random seed is set when entering this context then reset original"},{"line_number":62,"context_line":"    # random state when exiting the context. This avoids a test calling this"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_2ee7c3ac","line":59,"updated":"2016-11-11 14:33:20.000000000","message":"A context manager may be a little over the top but I like the fact that it\u0027s obvious what is happening on entry and exit to/from the context, rather than scrolling down and finding a finally clause.","commit_id":"49792196405bad76b89b12bc4e1b85fd072ef834"}],"test/unit/common/ring/test_builder.py":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"27935cf3af53c19fb742c627b3be1b356e498206","unresolved":false,"context_lines":[{"line_number":1194,"context_line":"        # There\u0027s something like a 11% chance that we won\u0027t be able to get to"},{"line_number":1195,"context_line":"        # a balance of 0 (and a 6% chance that we won\u0027t change anything at all)"},{"line_number":1196,"context_line":"        # Pick a seed to make this pass."},{"line_number":1197,"context_line":"        rb.rebalance(seed\u003d123)"},{"line_number":1198,"context_line":"        self.assertEqual(rb.get_balance(), 0)"},{"line_number":1199,"context_line":""},{"line_number":1200,"context_line":"    def test_multiple_duplicate_device_assignment(self):"}],"source_content_type":"text/x-python","patch_set":4,"id":"bf3e73b7_274545b4","line":1197,"updated":"2017-08-07 19:07:21.000000000","message":"Note that this rebalanced used to be not-random, since we used a seed on line 1098. Continuing to be not-random seems OK?","commit_id":"21fc3743fc34178d4710b8e453aa05ac33a8a1a0"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"27935cf3af53c19fb742c627b3be1b356e498206","unresolved":false,"context_lines":[{"line_number":1618,"context_line":"        # overload is 10% (0.1)."},{"line_number":1619,"context_line":"        rb.set_overload(0.1)"},{"line_number":1620,"context_line":"        rb.pretend_min_part_hours_passed()"},{"line_number":1621,"context_line":"        rb.rebalance(seed\u003d12345)"},{"line_number":1622,"context_line":""},{"line_number":1623,"context_line":"        part_counts \u003d self._partition_counts(rb, key\u003d\u0027zone\u0027)"},{"line_number":1624,"context_line":"        self.assertEqual(part_counts[0], 212)"}],"source_content_type":"text/x-python","patch_set":4,"id":"bf3e73b7_87275113","line":1621,"updated":"2017-08-07 19:07:21.000000000","message":"Again, this used to be not-random; we used a seed on line 1608.","commit_id":"21fc3743fc34178d4710b8e453aa05ac33a8a1a0"}],"test/unit/common/ring/test_ring.py":[{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"27935cf3af53c19fb742c627b3be1b356e498206","unresolved":false,"context_lines":[{"line_number":901,"context_line":"        counting_table \u003d CountingRingTable(r._replica2part2dev_id)"},{"line_number":902,"context_line":"        r._replica2part2dev_id \u003d counting_table"},{"line_number":903,"context_line":""},{"line_number":904,"context_line":"        part \u003d random.randint(0, r.partition_count)"},{"line_number":905,"context_line":"        node_iter \u003d r.get_more_nodes(part)"},{"line_number":906,"context_line":"        next(node_iter)"},{"line_number":907,"context_line":"        self.assertLess(counting_table.count, 14)"}],"source_content_type":"text/x-python","patch_set":4,"id":"bf3e73b7_67f6ad92","line":904,"updated":"2017-08-07 19:07:21.000000000","message":"Because of the seed at L877, this used to be not-random. https://www.xkcd.com/221/","commit_id":"21fc3743fc34178d4710b8e453aa05ac33a8a1a0"},{"author":{"_account_id":15343,"name":"Tim Burke","email":"tburke@nvidia.com","username":"tburke"},"change_message_id":"27935cf3af53c19fb742c627b3be1b356e498206","unresolved":false,"context_lines":[{"line_number":904,"context_line":"        part \u003d random.randint(0, r.partition_count)"},{"line_number":905,"context_line":"        node_iter \u003d r.get_more_nodes(part)"},{"line_number":906,"context_line":"        next(node_iter)"},{"line_number":907,"context_line":"        self.assertLess(counting_table.count, 14)"},{"line_number":908,"context_line":"        # sanity"},{"line_number":909,"context_line":"        self.assertEqual(1, r._num_regions)"},{"line_number":910,"context_line":"        self.assertEqual(2, r._num_zones)"}],"source_content_type":"text/x-python","patch_set":4,"id":"bf3e73b7_47da8917","line":907,"updated":"2017-08-07 19:07:21.000000000","message":"See https://review.openstack.org/#/c/418082/ for a better/more complete way of fixing this test.","commit_id":"21fc3743fc34178d4710b8e453aa05ac33a8a1a0"}]}
