-
Notifications
You must be signed in to change notification settings - Fork 357
Expand file tree
/
Copy pathpyproject.toml
More file actions
343 lines (310 loc) · 12.4 KB
/
Copy pathpyproject.toml
File metadata and controls
343 lines (310 loc) · 12.4 KB
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
[build-system]
requires = [
"setuptools>=21",
"setuptools-scm"
]
build-backend = "setuptools.build_meta"
[project]
name="lightly"
# 3.8 is the lowest version we support and test, and the lowest interpreter uv can
# provision, so 3.6/3.7 can no longer be installed or tested here.
requires-python = ">=3.8"
authors = [
{name = "Lightly Team", email = "team@lightly.ai"},
]
license = {file = "LICENSE.txt"}
description="A deep learning package for self-supervised learning"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
]
dependencies = [
"hydra-core>=1.0.0",
"numpy>=1.18.1",
"tqdm>=4.44",
"torch",
"torchvision",
"pytorch_lightning>=1.0.4",
]
dynamic = ["version", "readme"]
[project.optional-dependencies]
all = [
"lightly[matplotlib,minimal,timm,video]"
]
# Deprecated. The version floors this extra used to carry are test-only and now live
# in the `minimal` dependency group, which is not distributed with the package. Kept
# as an empty extra so `lightly[minimal]` and `lightly[all]` keep resolving.
minimal = []
timm = ["timm>=0.9.9"]
video = ["av>=8.0.3"]
matplotlib = ["matplotlib>=3"]
# Dependency groups are development-only and are never distributed with the package.
# Anything users are meant to install goes into [project.optional-dependencies] instead.
[dependency-groups]
# Tooling to develop, test, lint and type-check the package. Installed by default,
# see tool.uv.default-groups below.
#
# Every entry needs a lower bound, even though this group is development-only and its
# versions are otherwise pinned by uv.lock. `uv sync --resolution=lowest-direct`, which
# the minimal test setup uses, resolves the whole lockfile and therefore applies to this
# group as well: an unbounded `pandas` resolves to pandas 0.1 (2009), which does not
# build. The bounds are the versions uv.lock already selects for Python 3.8, the lowest
# version we test against (except mypy, floored lower at 1.4.1 since type-check runs only
# on 3.12), so the dev tooling stays usable there. Bumping them is only necessary when a
# tool no longer works at its floor.
dev = [
"pytest>=8.3.5",
"pytest-forked>=1.6.0",
"pytest-xdist>=3.6.1",
"pytest-mock>=3.14.1",
"responses>=0.25.7",
# Also a lower bound for the `matplotlib` extra when both are installed, so the
# minimal test setup exercises this version rather than the extra's `matplotlib>=3`.
"matplotlib>=3.7.5",
"pre-commit>=3.5.0",
"opencv-python>=4.11.0.86",
"scikit-learn>=1.3.2",
"pandas>=2.0.3",
"toml>=0.10.2",
"torchmetrics>=1.5.2",
# Ruff should match the version defined in .pre-commit-config.yaml.
"ruff==0.12.7",
"mypy>=1.4.1",
"types-python-dateutil>=2.9.0.20241206",
"types-toml>=0.10.8.20240310",
"types-requests>=2.32.0.20241016",
"types-PyYAML>=6.0.12.20241230",
"nbformat>=5.10.4",
"jupytext>=1.17.1",
]
# Sphinx and its extensions, only needed to build the documentation in docs/.
# Lower bounds are required for the same reason as in the `dev` group above.
docs = [
"sphinx>=5.3.0",
# Pinned: 0.16 is both the highest version the docs build with and the version the
# lockfile selects, so the lower bound has nowhere else to go.
"docutils==0.16",
"sphinx-copybutton>=0.5.2",
"sphinx-design>=0.5.0",
"sphinx-gallery>=0.19.0",
"sphinx-tabs>=3.4.7",
"sphinx-reredirects>=0.1.4",
"sphinx_rtd_theme>=2.0.0",
]
# Tooling to build and publish the package to PyPI.
# Lower bounds are required for the same reason as in the `dev` group above.
dist = [
"build>=1.2.2.post1",
"twine>=6.1.0",
"wheel>=0.45.1",
]
# Lowest dependency versions we test against, used together with
# `uv sync --resolution=lowest-direct`. Older versions might work depending on the
# functionality used. This used to be the `minimal` extra.
minimal = [
"torch>=1.10.0",
"torchvision>=0.11.0",
"pytorch_lightning>=1.6",
# Without this floor, lowest-direct resolves numpy to ~1.20.1 (torchmetrics 1.5.2 in the
# dev group requires numpy>1.20.0) while taking the newest Pillow, whose PIL/_typing.py
# imports numpy.typing.NDArray (added in 1.21.0). Floor numpy to 1.21 so the two agree.
"numpy>=1.21.0",
]
[tool.uv]
# Only `dev` is installed automatically; docs/dist/minimal are opt-in via --group.
default-groups = ["dev"]
# setuptools is pulled into the Python 3.8 minimal test setup transitively (nothing
# depends on it directly), and `--resolution=lowest-direct` leaves transitive versions
# at their newest. It is held in a narrow window:
# - Cap <59.6: torch 1.10's tensorboard import reads distutils.version.LooseVersion.
# setuptools 59.6.0 changed its bundled-distutils hook so that access raises
# "module 'distutils' has no attribute 'version'"; 59.5.0 is the last release where it
# works. Without the cap the resolution takes the newest setuptools and torch 1.10 breaks.
# - Floor >=56: 56.0.0 is the first release whose pkg_resources import hook (VendorImporter)
# implements find_spec. pytest's `--import-mode=importlib` calls find_spec on every
# sys.meta_path finder, so an older setuptools would break collection with
# "'VendorImporter' object has no attribute 'find_spec'". The cap already lands on a
# find_spec-capable version (59.5.0); the floor guards against a future direct dependency
# re-pinning setuptools low, the way the removed openapi extra once did.
# A constraint, not a dependency, so it only bounds setuptools where it is already pulled
# in. The Python marker keeps the newer targets, which build against Python 3.12 and need
# a modern setuptools, unaffected.
constraint-dependencies = ["setuptools>=56,<59.6; python_full_version < '3.9'"]
# av 8.0.3, which `--resolution=lowest-direct` selects for the minimal test setup, is
# sdist-only and ships no pyproject.toml, so uv runs its setup.py under the default
# legacy setuptools backend just to read the package metadata. Line 6 of that setup.py
# imports `distutils.msvccompiler` unconditionally, and setuptools removed that module
# from its bundled distutils in 74.0.0. Since setuptools 60, `import distutils` resolves
# to that bundled copy even on Python 3.8, where the stdlib still provides the module.
#
# This has to be a *build* constraint: `constraint-dependencies` above only applies to
# the project's own resolution, not to the isolated PEP 517 build environments. The
# Python marker keeps the newer targets, which build against Python 3.12, unaffected.
build-constraint-dependencies = ["setuptools<74; python_full_version < '3.9'"]
[project.urls]
"Homepage" = "https://www.lightly.ai"
"Web-App" = "https://app.lightly.ai"
"Documentation" = "https://docs.lightly.ai"
"Github" = "https://github.com/lightly-ai/lightly"
"Discord" = "https://discord.gg/xvNJW94"
[project.scripts]
lightly-crop = "lightly.cli.crop_cli:entry"
lightly-embed = "lightly.cli.embed_cli:entry"
lightly-magic = "lightly.cli.lightly_cli:entry"
lightly-ssl-train = "lightly.cli.train_cli:entry"
lightly-version = "lightly.cli.version_cli:entry"
[tool.setuptools.packages.find]
include = ["lightly*"]
[tool.setuptools.dynamic]
readme = {file = ["README.md"], content-type = "text/markdown"}
version = {attr = "lightly.__version__"}
[tool.setuptools.package-data]
lightly = ["lightly/cli/config/*.yaml"]
[tool.ruff]
line-length = 88
target-version = "py38"
extend-exclude = ["lightly/openapi_generated"]
[tool.ruff.lint]
select = ["I", "D202", "D209", "D212", "D214", "D410", "D411", "D412"]
ignore = ["E501"]
[tool.ruff.lint.isort]
known-first-party = ["lightly"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.per-file-ignores]
# Deprecated paths (mirrors pyproject.toml's mypy excludes for deprecated code).
"lightly/models/simclr.py" = ["D"]
"lightly/models/moco.py" = ["D"]
"lightly/models/barlowtwins.py" = ["D"]
"lightly/models/nnclr.py" = ["D"]
"lightly/models/simsiam.py" = ["D"]
"lightly/models/byol.py" = ["D"]
"tests/models/test_ModelsSimSiam.py" = ["D"]
"tests/models/test_ModelsSimCLR.py" = ["D"]
"tests/models/test_ModelsNNCLR.py" = ["D"]
"tests/models/test_ModelsMoCo.py" = ["D"]
"tests/models/test_ModelsBYOL.py" = ["D"]
[tool.ruff.format]
docstring-code-format = true
[tool.mypy]
ignore_missing_imports = true
warn_unused_configs = true
strict_equality = true
# Disallow dynamic typing
disallow_any_decorated = true
# TODO(Philipp, 09/23): Remove me!
# disallow_any_explicit = True
disallow_any_generics = true
disallow_subclassing_any = true
# Disallow untyped definitions
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
# None and optional handling
no_implicit_optional = true
strict_optional = true
# Configuring warnings
warn_unused_ignores = false # Different ignores are required for different Python versions
warn_no_return = true
warn_return_any = true
warn_redundant_casts = true
warn_unreachable = true
# Print format
show_error_codes = true
show_error_context = true
# Excludes
# TODO(Philipp, 09/23): Remove these one by one (start with 300 files).
exclude = '''(?x)(
lightly/cli/version_cli.py |
lightly/cli/crop_cli.py |
lightly/cli/embed_cli.py |
lightly/cli/lightly_cli.py |
lightly/cli/config/get_config.py |
lightly/cli/train_cli.py |
lightly/cli/_cli_simclr.py |
lightly/cli/_helpers.py |
lightly/data/dataset.py |
lightly/data/collate.py |
lightly/data/_image_loaders.py |
lightly/data/_video.py |
lightly/core.py |
lightly/utils/cropping/crop_image_by_bounding_boxes.py |
lightly/utils/cropping/read_yolo_label_file.py |
lightly/utils/debug.py |
lightly/utils/benchmarking/benchmark_module.py |
lightly/utils/benchmarking/knn_classifier.py |
lightly/models/modules/masked_autoencoder.py |
lightly/models/modules/ijepa.py |
lightly/models/utils.py |
tests/cli/test_cli_version.py |
tests/cli/test_cli_magic.py |
tests/cli/test_cli_crop.py |
tests/cli/test_cli_train.py |
tests/cli/test_cli_get_lighty_config.py |
tests/cli/test_cli_embed.py |
tests/core/test_Core.py |
tests/data/test_multi_view_collate.py |
tests/data/test_data_collate.py |
tests/data/test_LightlySubset.py |
tests/data/test_LightlyDataset.py |
tests/embedding/test_callbacks.py |
tests/embedding/test_embedding.py |
tests/utils/test_debug.py |
tests/utils/benchmarking/test_benchmark_module.py |
tests/utils/benchmarking/test_topk.py |
tests/utils/benchmarking/test_knn_classifier.py |
tests/utils/benchmarking/test_knn.py |
tests/utils/benchmarking/test_linear_classifier.py |
tests/utils/benchmarking/test_metric_callback.py |
tests/utils/test_dist.py |
tests/conftest.py |
# Let's not type deprecated models:
lightly/models/simclr.py |
lightly/models/moco.py |
lightly/models/barlowtwins.py |
lightly/models/nnclr.py |
lightly/models/simsiam.py |
lightly/models/byol.py |
# Let's not type deprecated models tests:
tests/models/test_ModelsSimSiam.py |
tests/models/test_ModelsSimCLR.py |
tests/models/test_ModelsNNCLR.py |
tests/models/test_ModelsMoCo.py |
tests/models/test_ModelsBYOL.py )'''
# Ignore imports from untyped modules.
[[tool.mypy.overrides]]
module = [
"lightly.cli.*",
"lightly.data.*",
"lightly.models.*",
"lightly.utils.benchmarking.*",
]
follow_imports = "skip"
[tool.pytest.ini_options]
# importlib mode is required for the spawn-based DDP test pool (#1982): spawn
# workers re-import the test module, which deadlocks under the default prepend
# import mode. It is a no-op for the rest of the suite.
addopts = "--import-mode=importlib"
[tool.jupytext]
notebook_metadata_filter="-all"
cell_metadata_filter="-all"
[tool.codespell]
skip = "*.ipynb"
ignore-words-list = "nce,inpt,nd,wirth"