Spaces:
Running on Zero
Running on Zero
File size: 3,484 Bytes
d1f1097 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | import pytest
from tests.functional_tests.python_test_utils import common
def pytest_addoption(parser):
"""
Additional command-line arguments passed to pytest.
"""
parser.addoption(
"--allow-nondeterministic-algo",
action="store_true",
default=False,
help="If set, test system checks for approximate results.",
)
parser.addoption("--golden-values-path", action="store", help="Path to golden values")
parser.addoption("--actual-values-path", action="store", help="Path to actual values")
parser.addoption("--actual-values-first-run-path", action="store", help="Path to actual values")
parser.addoption(
"--actual-values-second-run-path", action="store", help="Path to actual values"
)
parser.addoption("--scope", action="store", help="Test scope (MR, weekly, prerelease, release)")
parser.addoption(
"--train-iters", action="store", default=100, help="Number of train iters", type=int
)
parser.addoption("--test-values-path", action="store", help="Path to tensorboard records")
parser.addoption("--tensorboard-path", action="store", help="Path to tensorboard records")
parser.addoption("--model-config-path", action="store", help="Path to model_config.yaml")
@pytest.fixture
def compare_approximate_results(request) -> bool:
"""Simple fixture returning whether to check against results approximately."""
return request.config.getoption("--allow-nondeterministic-algo") is True
@pytest.fixture
def golden_values_path(request):
"""Simple fixture returning golden values."""
return request.config.getoption("--golden-values-path")
@pytest.fixture
def golden_values(request):
"""Simple fixture returning golden values."""
return common.read_golden_values_from_json(request.config.getoption("--golden-values-path"))
@pytest.fixture
def actual_values(request):
"""Simple fixture returning golden values."""
return common.read_golden_values_from_json(request.config.getoption("--actual-values-path"))
@pytest.fixture
def actual_values_first_run(request):
"""Simple fixture returning actual values."""
return common.read_golden_values_from_json(
request.config.getoption("--actual-values-first-run-path")
)
@pytest.fixture
def actual_values_second_run(request):
"""Simple fixture returning actual values."""
return common.read_golden_values_from_json(
request.config.getoption("--actual-values-second-run-path")
)
@pytest.fixture
def scope(request):
"""Simple fixture returning golden values."""
return request.config.getoption("--scope")
@pytest.fixture
def train_iters(request):
"""Simple fixture returning number of train iters."""
return request.config.getoption("--train-iters")
@pytest.fixture
def tensorboard_logs(request, train_iters):
"""Simple fixture returning tensorboard metrics."""
return common.read_tb_logs_as_list(
request.config.getoption("--tensorboard-path"), train_iters=train_iters
)
@pytest.fixture
def test_values_path(request):
return request.config.getoption("--test-values-path")
@pytest.fixture
def tensorboard_path(request):
"""Simple fixture returning path to tensorboard logs."""
return request.config.getoption("--tensorboard-path")
@pytest.fixture
def model_config_path(request):
"""Simple fixture returning path to model_config.yaml."""
return request.config.getoption("--model-config-path")
|