-
Notifications
You must be signed in to change notification settings - Fork 444
/
pyproject.toml
393 lines (341 loc) · 11.5 KB
/
pyproject.toml
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# SETUP CONFIGURATION. #
[build-system]
requires = [
"setuptools>=61",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "otx"
dynamic = ["version"]
description = "OpenVINO™ Training Extensions: Train, Evaluate, Optimize, Deploy Computer Vision Models via OpenVINO™"
readme = "README.md"
requires-python = ">=3.10"
license = {file = "LICENSE"}
authors = [
{ name = "OpenVINO™ Training Extensions Contributors" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Cython",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"datumaro==1.10.0rc0",
"omegaconf==2.3.0",
"rich==13.9.4",
"jsonargparse==4.30.0",
"psutil==6.1.0", # Mem cache needs system checks
"ftfy==6.3.1",
"regex==2024.11.6",
"importlib_resources==6.4.5",
"docstring_parser==0.16", # CLI help-formatter
"rich_argparse==1.6.0", # CLI help-formatter
"einops==0.8.0",
"decord==0.6.0",
"typeguard>=4.3,<4.5",
"numba==0.60.0",
# TODO(ashwinvaidya17): https://github.com/openvinotoolkit/anomalib/issues/2126
"setuptools<70",
]
[project.optional-dependencies]
dev = [
"tox==4.23.2",
"pre-commit==4.0.1",
"pylint",
"pytest",
"coverage",
"pytest-timeout",
"pytest-mock",
"pytest-csv",
"pytest-cov",
"onnxruntime==1.20.1",
]
docs = [
"furo",
"myst-parser",
"sphinx==7.2.6",
"pydata-sphinx-theme==0.12.0",
"sphinx-tabs",
"sphinx-panels",
"sphinx-design",
"sphinx-copybutton==0.5.2",
"sphinx-autoapi",
"sphinxemoji",
"nbsphinx",
"myst-parser>=2.0.0",
"linkify-it-py",
]
base = [
"torch==2.5.1",
"lightning==2.4.0",
"pytorchcv==0.0.67",
"timm==1.0.3",
"openvino==2024.5",
"openvino-dev==2024.5",
"openvino-model-api==0.2.5",
"onnx==1.17.0",
"onnxconverter-common==1.14.0",
"nncf==2.14.0",
"anomalib[core]==1.1.0",
]
transformers = [
"transformers==4.47.0",
"diffusers==0.31.0",
"torchmetrics[image]>=0.7.0"
]
mmlab = [
"mmdet==3.2.0",
"mmpretrain==1.1.1",
"mmsegmentation==1.2.1",
"mmaction2==1.2.0",
"mmdeploy==1.3.*",
# Without the pip cache, oss2 will sometimes install to a lower version. This is related to the installation of the mmlab library.
# This causes an error when training the mm model, so fix the version first.
"oss2==2.19.1",
]
ci_tox = [
"tox==4.23.2",
]
ci_publish = [
"build==1.2.2.post1",
]
ci_benchmark = [
"pandas<2.3", # To avoid conflict with nncf==2.9.0
"matplotlib==3.9.3",
"nbconvert==7.16.4",
"ipython==8.30.0",
"ipykernel==6.29.5",
"openpyxl==3.1.5",
"mlflow==2.18.0",
"py-cpuinfo==9.0.0",
]
[project.scripts]
otx = "otx.cli:main"
[project.urls]
Documentation = "https://openvinotoolkit.github.io/training_extensions/"
Repository = "https://github.com/openvinotoolkit/training_extensions/"
[tool.setuptools.dynamic]
version = {attr = "otx.__version__"}
[tool.setuptools]
include-package-data = true
[tool.setuptools.packages.find]
where = ["src"]
include = ["otx*"]
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# COVERAGE CONFIGURATION. #
[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if TYPE_CHECKING:",
]
[tool.coverage.run]
source = [
"src/otx/",
]
omit = [
"**/__init__.py",
"src/otx/recipes/*",
"src/otx/tools/*",
"**/mmconfigs/*",
"**/mmdeploy/*",
"**/exportable_code/*",
# Ignore mm related code for now
"src/otx/core/data/transform_libs/mmaction.py",
"src/otx/core/data/transform_libs/mmcv.py",
"src/otx/core/data/transform_libs/mmdet.py",
"src/otx/core/data/transform_libs/mmpretrain.py",
"src/otx/core/data/transform_libs/mmseg.py",
"src/otx/core/exporter/mmdeploy.py",
"src/otx/core/model/utils/*",
# Ignore some generated files by opencv-python
"config.py",
"config-3.py",
]
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# MYPY CONFIGURATION. #
[tool.mypy]
python_version = "3.10"
ignore_missing_imports = true
show_error_codes = true
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# RUFF CONFIGURATION #
[tool.ruff]
# Enable rules
select = [
"F", # Pyflakes (`F`)
# Enable all `pydocstyle` rules, limiting to those that adhere to the
# Google convention via `convention = "google"`, below.
"D", # pydocstyle (`D`)
"E", # pycodestyle error (`E`)
"W", # pycodestyle warning (`W`)
"I", # isort (`I`)
"PL", # pylint (`PL`)
"C90", # mccabe (`C90`)
"N", # pep8-naming (`N`)
"UP", # pyupgrade (`UP`)
"YTT", # flake8-2020 (`YTT`)
"ANN", # flake8-annotations (`ANN`)
"S", # flake8-bandit (`S`)
# "BLE", # flake8-blind-except (`BLE`) -> Need to discuss new exception structure
"B", # flake8-bugbear (`B`)
"A", # flake8-builtins (`A`)
"COM", # flake8-commas (`COM`)
# "CPY", # flake8-copyright (`CPY`) -> Rules included in the preview version of RUFF. It may be added in the future, but for now, disable it.
"C4", # flake8-comprehensions (`C4`)
"DTZ", # flake8-datatimez (`DTZ`)
"T10", # flake8-debugger (`T10`)
"EM", # flake8-errmsg (`EM`)
"FA", # flake8-future-annotations (`FA`)
"ISC", # flake8-implicit-str-concat (`ISC`)
"ICN", # flake8-import-conventions (`ICN`)
"PIE", # flake8-pie (`PIE`)
"PT", # flake8-pytest-style (`PT`)
"RSE", # flake8-raise (`RSE`)
"RET", # flake8-return (`RET`)
"SLF", # flake8-self (`SLF`)
"SIM", # flake8-simplify (`SIM`)
"TID", # flake8-tidy-imports (`TID`)
"TCH", # flake8-type-checking (`TCH`)
"INT", # flake8-gettext (`INT`)
"ARG", # flake8-unsused-arguments (`ARG`)
"PTH", # flake8-use-pathlib (`PTH`)
"TD", # flake8-todos (`TD`)
"FIX", # flake8-fixme (`FIX`)
# "LOG", # flake8-logging (`LOG`) -> Rules included in the preview version of RUFF. It may be added in the future, but for now, disable it.
"ERA", # eradicate (`ERA`)
"PD", # pandas-vet (`PD`)
"PGH", # pygrep-hooks (`PGH`)
"TRY", # tryceratos (`TRY`)
"FLY", # flynt (`FLY`)
"NPY", # NumPy-specific rules (`NPY`)
"PERF", # Perflint (`PERF`)
# "FURB", # refurb (`FURB`) -> Rules included in the preview version of RUFF. It may be added in the future, but for now, disable it.
"RUF", # Ruff-specific rules (`RUF`)
]
ignore = [
# pydocstyle
# On top of the Google convention, disable `D417`, which requires
# documentation for every function parameter.
"D417", # Missing argument descriptions in the docstring
"D107", # Missing docstring in `__init__`
"D105", # Missing docstring in magic method
# flake8-annotations
"ANN101", # Missing-type-self
"ANN002", # Missing type annotation for *args
"ANN003", # Missing type annotation for **kwargs
"ANN102", # Missing type annotation for `cls` in classmethod
"ANN204", # Missing return type annotation for special method `__init__`
"ARG002", # Unused method argument -> some function cannot use argument
# flake8-type-checking
"TCH001", # typing-only-first-party-import, Sometimes this causes an incorrect error.
# flake8-fixme
"FIX002", # line-contains-todo
"E731", # Do not assign a `lambda` expression, use a `def`
"TD003", # Missing issue link on the line following this TODO
# TODO (someone): Update legacy np.random.{method_name} call with np.random.Generator
# Legacy (MT19964) and new (PCG64) random generators use different pseudo-random number generators.
# (https://numpy.org/doc/stable/reference/random/legacy.html#legacy)
# For now, remaining legacy random methods is required until numpy version is explicitly updated in OTX.
"NPY002", # Replace legacy np.random.{method_name} call with np.random.Generator
]
# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
# fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
# unfixable = [
# "F401", # disable autofix for unused imports
# ]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"tests/assets",
"src/otx/algo/**/mmdeploy/",
# it will be cleaned up later
"for_developers/helpers.py",
# Ruff complains it but don't know how to fix since it literally showed no useful logs.
# https://github.com/openvinotoolkit/training_extensions/actions/runs/7176557723/job/19541622452?pr=2718#step:5:170
"tests/regression/*.py",
# Mostly borrowed from jsonargparse codebase
"src/otx/core/utils/jsonargparse.py"
]
# Same as Black.
line-length = 120
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# minimum target version
target-version = "py38"
# Enumerate all fixed violations.
show-fixes = true
[tool.ruff.lint.flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
extend-immutable-calls = [
# Label info objects
"otx.core.types.label.LabelInfo",
"otx.core.types.label.HLabelInfo",
"otx.core.types.label.SegLabelInfo",
"otx.core.types.label.NullLabelInfo",
"otx.core.types.label.AnomalyLabelInfo",
# Config objects
"otx.core.config.data.TileConfig",
]
[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 20
[tool.ruff.pylint]
allow-magic-value-types = ["str", "bytes", "int", "float"]
max-args = 20
max-branches = 50
max-statements = 150
max-returns = 10
[tool.ruff.per-file-ignores]
# Declare an additional exclude rule for test code
"tests/**/*.py" = [
"S101", # pytest-style allows `assert` statements in tests.
"SLF001", # We sometimes need to inspect private functions for testing.
"TCH003", # It doesn't seem necessary to use TYPE_CHECKING in tests.
"PT004", # fixture ignore type returning.
"E501", # Test skips lines that are too long.
"ANN001", # Skip annotation type hint in test codes
"ANN201", # Skip return type hint in test codes
"D", # Test skips missing docstring argument with magic (fixture) methods.
"ARG001", # Some arguments are passed for executing fixture
]
"src/otx/**/*.py" = [
"ERA001",
]
# See https://github.com/openvinotoolkit/training_extensions/actions/runs/7109500350/job/19354528819?pr=2700
"src/otx/core/config/**/*.py" = [
"UP007"
]
[tool.ruff.pydocstyle]
convention = "google"
[tool.pytest.ini_options]
markers = [
"gpu", # mark tests which require NVIDIA GPU
"cpu",
"xpu", # mark tests which require Intel dGPU
]
python_files = "tests/**/*.py"