-
Notifications
You must be signed in to change notification settings - Fork 53
/
noxfile.py
163 lines (141 loc) · 4.66 KB
/
noxfile.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""Test with different environment configuration with nox.
Documentation:
https://nox.thea.codes/
"""
import nox
nox.options.error_on_missing_interpreters = False
COMMON_TEST_DEPENDENCIES = (
"beartype==0.17.2",
"expecttest==0.1.6",
"hypothesis",
'numpy==1.24.4; python_version<"3.9"',
'numpy==1.26.4; python_version>="3.9"',
"packaging",
"parameterized",
'psutil; sys_platform != "win32"',
"pytest-cov",
"pytest-randomly",
"pytest-subtests",
"pytest-xdist",
"pytest!=7.1.0",
"pyyaml",
"types-PyYAML",
"typing_extensions",
"ml-dtypes",
)
ONNX = "onnx==1.16"
ONNX_RUNTIME = "onnxruntime==1.17.1"
PYTORCH = "torch==2.3.1"
TORCHVISON = "torchvision==0.18.1"
TRANSFORMERS = "transformers==4.37.2"
ONNX_RUNTIME_NIGHTLY_DEPENDENCIES = (
"flatbuffers",
"coloredlogs",
"sympy",
"numpy",
"packaging",
"protobuf",
)
@nox.session(tags=["build"])
def build(session):
"""Build package."""
session.install("build", "wheel")
session.run("python", "-m", "build")
@nox.session(tags=["test"])
def test(session):
"""Test onnxscript and documentation."""
session.install(
*COMMON_TEST_DEPENDENCIES,
PYTORCH,
TORCHVISON,
ONNX,
ONNX_RUNTIME,
TRANSFORMERS,
)
session.install(".", "--no-deps")
session.run("pip", "list")
session.run("pytest", "onnxscript", "--doctest-modules", *session.posargs)
session.run("pytest", "tests", "docs/test", *session.posargs)
@nox.session(tags=["test-torch-nightly"])
def test_torch_nightly(session):
"""Test with PyTorch nightly (preview) build."""
session.install(
*COMMON_TEST_DEPENDENCIES,
ONNX_RUNTIME,
TRANSFORMERS,
)
session.install("-r", "requirements/ci/requirements-onnx-weekly.txt")
session.install("-r", "requirements/ci/requirements-pytorch-nightly.txt")
session.install(".", "--no-deps")
session.run("pip", "list")
session.run("pytest", "onnxscript", "--doctest-modules", *session.posargs)
session.run("pytest", "tests", *session.posargs)
@nox.session(tags=["test-onnx-weekly"])
def test_onnx_weekly(session):
"""Test with ONNX weekly (preview) build."""
session.install(*COMMON_TEST_DEPENDENCIES, ONNX_RUNTIME, PYTORCH, TORCHVISON, TRANSFORMERS)
session.install("-r", "requirements/ci/requirements-onnx-weekly.txt")
session.install(".", "--no-deps")
session.run("pip", "list")
session.run("pytest", "onnxscript", "--doctest-modules", *session.posargs)
session.run("pytest", "tests", *session.posargs)
@nox.session(tags=["test-ort-nightly"])
def test_ort_nightly(session):
"""Test with ONNX Runtime nightly builds."""
session.install(
*COMMON_TEST_DEPENDENCIES,
PYTORCH,
TORCHVISON,
ONNX,
*ONNX_RUNTIME_NIGHTLY_DEPENDENCIES,
)
session.install("-r", "requirements/ci/requirements-ort-nightly.txt")
session.install(".", "--no-deps")
session.run("pip", "list")
session.run("pytest", "onnxscript", "--doctest-modules", *session.posargs)
session.run("pytest", "tests", *session.posargs)
@nox.session(tags=["test-experimental-torchlib-tracing"])
def test_experimental_torchlib_tracing(session):
"""Test TorchLib with the experimental TORCHLIB_EXPERIMENTAL_PREFER_TRACING flag on."""
session.install(
*COMMON_TEST_DEPENDENCIES,
PYTORCH,
TORCHVISON,
ONNX,
*ONNX_RUNTIME_NIGHTLY_DEPENDENCIES,
)
session.install("-r", "requirements/ci/requirements-ort-nightly.txt")
session.install(".", "--no-deps")
session.run("pip", "list")
session.run(
"pytest",
"tests/function_libs/torch_lib/ops_test.py",
*session.posargs,
env={"TORCHLIB_EXPERIMENTAL_PREFER_TRACING": "1"},
)
@nox.session(tags=["test-dort"])
def test_dort(session):
"""Test the conversion of a couple of models from transformers."""
session.install(
*COMMON_TEST_DEPENDENCIES,
)
torch_version, transformers_version = session.posargs
if torch_version == "nightly":
session.install(
"--pre",
"torch",
"torchvision",
"torchaudio",
"--index-url",
"https://download.pytorch.org/whl/nightly/cpu",
)
else:
session.install("torch", "torchvision", "torchaudio")
session.install("torch", "torchvision", "torchaudio")
session.install(f"transformers=={transformers_version}")
session.install("onnxruntime-training==1.17.1")
session.run("pip", "list")
session.run("pytest", "onnxscript")
session.run("pytest", "tests")