Robbe created BEAM-6395:
---------------------------
Summary: Opcounters sampling test fails for some random seeds on
Python3
Key: BEAM-6395
URL: https://issues.apache.org/jira/browse/BEAM-6395
Project: Beam
Issue Type: Sub-task
Components: sdk-py-core
Reporter: Robbe
Assignee: Ahmet Altay
test_should_sample
(apache_beam.runners.worker.opcounters_test.OperationCountersTest) fails on
Python 3 for the specified random seed (1717), but succeeds for other random
seeds (eg. 1718).
It is not clear if this test fails due to Python 3, or because it is not stable
for all random seeds.
According to the [random.seed
docs|https://docs.python.org/3/library/random.html#random.seed], reproducing
random sequences from older versions of Python should be possible by providing
a 'version' argument. However, both with and without this argument, the results
differ between python 2 and python 3.
Using the following test:
{code}
import random
random.seed(1717)
results = []
for i in range(10):
results.append(round(random.random(), 2))
results.append(random.randint(1, 50))
print(results)
{code}
The obtained results are:
Python 2:
[0.78, 12, 0.94, 6, 0.54, 31, 0.53, 28, 0.44, 33, 0.36, 45, 0.47, 22, 0.71,
40, 0.45, 35, 0.0, 1]
Python 3:
[0.78, 15, 0.94, 14, 0.12, 35, 0.22, 10, 0.53, 36, 0.45, 42, 0.65, 12, 0.9,
31, 0.78, 2, 0.71, 50]
Python 3 with version=1:
[0.78, 15, 0.94, 14, 0.12, 35, 0.22, 10, 0.53, 36, 0.45, 42, 0.65, 12, 0.9,
31, 0.78, 2, 0.71, 50]
The Python 3 result does not change due to the 'version' argument, since
according to the docs, it only has effect on str or bytes type seeds.
Relevant test output:
{noformat}
======================================================================
FAIL: test_should_sample
(apache_beam.runners.worker.opcounters_test.OperationCountersTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/robbe/workspace/beam/sdks/python/apache_beam/runners/worker/opcounters_test.py",
line 207, in test_should_sample
buckets[i] / (10.0 * total_runs / i)))
AssertionError: False is not true : i=256, buckets[i]=167, expected=117,
ratio=1.425067{noformat}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)