forked from mlflow/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
94 lines (85 loc) · 2.71 KB
/
conftest.py
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
import os
import posixpath
import pytest
def pytest_addoption(parser):
parser.addoption(
"--large-only",
action="store_true",
dest="large_only",
default=False,
help="Run only tests decorated with 'large' annotation",
)
parser.addoption(
"--large",
action="store_true",
dest="large",
default=False,
help="Run tests decorated with 'large' annotation",
)
parser.addoption(
"--release",
action="store_true",
dest="release",
default=False,
help="Run tests decorated with 'release' annotation",
)
parser.addoption(
"--requires-ssh",
action="store_true",
dest="requires_ssh",
default=False,
help="Run tests decorated with 'requires_ssh' annotation. "
"These tests require keys to be configured locally "
"for SSH authentication.",
)
parser.addoption(
"--ignore-flavors",
action="store_true",
dest="ignore_flavors",
default=False,
help="Ignore tests for model flavors.",
)
def pytest_configure(config):
# Override the markexpr argument to pytest
# See https://docs.pytest.org/en/latest/example/markers.html for more details
markexpr = []
if not config.option.large and not config.option.large_only:
markexpr.append("not large")
elif config.option.large_only:
markexpr.append("large")
if not config.option.release:
markexpr.append("not release")
if not config.option.requires_ssh:
markexpr.append("not requires_ssh")
if len(markexpr) > 0:
setattr(config.option, "markexpr", " and ".join(markexpr))
@pytest.hookimpl(hookwrapper=True)
def pytest_ignore_collect(path, config):
outcome = yield
if not outcome.get_result() and config.getoption("ignore_flavors"):
# If not ignored by the default hook and `--ignore-flavors` specified
model_flavors = [
"tests/h2o",
"tests/keras",
"tests/pytorch",
"tests/pyfunc",
"tests/sagemaker",
"tests/sklearn",
"tests/spark",
"tests/tensorflow",
"tests/azureml",
"tests/onnx",
"tests/keras_autolog",
"tests/tensorflow_autolog",
"tests/gluon",
"tests/gluon_autolog",
"tests/xgboost",
"tests/lightgbm",
"tests/spacy",
"tests/spark_autologging",
"tests/fastai",
]
relpath = os.path.relpath(str(path))
relpath = relpath.replace(os.sep, posixpath.sep) # for Windows
if relpath in model_flavors:
outcome.force_result(True)