{{ message }}
Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
436 lines (395 loc) · 12.7 KB
/
Copy pathpyproject.toml
File metadata and controls
436 lines (395 loc) · 12.7 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
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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "samo-dl"
version = "0.1.0"
description = "SAMO Deep Learning - AI-powered voice-first journaling companion"
authors = [
{name = "SAMO DL Team", email = "dev@samo.ai"}
]
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"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",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
# API Framework (base install should be light)
"fastapi>=0.100.0",
"uvicorn[standard]>=0.23.0",
"python-multipart>=0.0.6",
"pydantic>=2.11.7,<3.0.0",
"PyJWT>=2.8.0,<3.0.0",
# Database & Storage
"sqlalchemy>=2.0.0",
"psycopg2-binary>=2.9.0",
"pgvector>=0.2.0",
"redis>=4.6.0",
# Utilities
"python-dotenv>=1.1.1,<2.0.0",
"pyyaml>=6.0",
"requests==2.32.4",
"certifi>=2025.7.14,<2026.0.0",
"click>=8.1.0",
"rich>=13.0.0",
"loguru>=0.7.0",
]
[project.optional-dependencies]
# Test Dependencies
test = [
"pytest>=8.4.1,<9.0.0",
"pytest-cov>=6.2.1,<7.0.0",
"pytest-xdist>=3.3.0",
"pytest-mock>=3.11.0",
"pytest-asyncio>=0.21.0",
"pytest-timeout>=2.1.0",
"pytest-benchmark>=4.0.0",
"httpx>=0.24.0", # For FastAPI testing
"coverage[toml]>=7.2.0",
"factory-boy>=3.3.0", # For test data generation
]
# Development Dependencies
dev = [
"ruff>=0.0.280",
"black>=23.7.0",
"mypy>=1.5.0",
"bandit[toml]>=1.7.5",
# safety removed - kept optional in CI to avoid resolver backtracking
"pre-commit>=3.3.0",
"jupyterlab>=4.0.0",
"ipykernel>=6.25.0",
]
# Production Dependencies
prod = [
"gunicorn>=21.2.0",
"prometheus-client==0.20.0",
"sentry-sdk[fastapi]>=1.29.0",
]
# Heavy ML/NLP stack (install when needed)
ml = [
# Core ML/AI Dependencies
"torch>=2.0.0,<3.0.0",
"transformers>=4.55.0,<5.0.0",
"datasets>=2.14.0,<5.0.0",
"accelerate>=0.20.0,<1.0.0",
"onnx>=1.14.0,<2.0.0",
"onnxruntime>=1.22.1,<2.0.0",
"sentencepiece>=0.1.99,<1.0.0",
"tokenizers>=0.21.4,<1.0.0",
# Deep Learning Frameworks
"scikit-learn>=1.3.0,<2.0.0",
"pandas>=2.0.0,<3.0.0",
"numpy>=1.24.0,<3.0.0",
"scipy>=1.11.0,<2.0.0",
# Text Processing
"nltk>=3.8,<4.0.0",
"spacy>=3.6.0,<4.0.0",
"gensim>=4.3.0,<5.0.0",
"textblob>=0.17.0,<1.0.0",
]
# Audio Processing (separate due to system dependencies)
audio = [
"librosa>=0.10.0,<1.0.0",
"soundfile>=0.12.0,<1.0.0",
"pydub>=0.25.1,<1.0.0",
"openai-whisper>=20231117",
"jiwer>=3.0.0,<4.0.0",
# pyaudio requires system libraries - install separately if needed
# "pyaudio>=0.2.11; platform_system != 'Darwin' or platform_machine != 'arm64'",
]
# GPU-optimized ML dependencies (CUDA support)
ml-gpu = [
# GPU-enabled PyTorch (CUDA 12.1 compatible)
"torch>=2.0.0,<3.0.0; sys_platform == 'linux'",
"torchvision>=0.15.0,<1.0.0; sys_platform == 'linux'",
"torchaudio>=2.0.0,<3.0.0; sys_platform == 'linux'",
# Include base ML dependencies
"transformers>=4.55.0,<5.0.0",
"datasets>=2.14.0,<5.0.0",
"accelerate>=0.20.0,<1.0.0",
"onnxruntime-gpu>=1.22.1,<2.0.0; sys_platform == 'linux'",
"onnx>=1.14.0,<2.0.0",
"sentencepiece>=0.1.99,<1.0.0",
"tokenizers>=0.21.4,<1.0.0",
# Data processing
"scikit-learn>=1.3.0,<2.0.0",
"pandas>=2.0.0,<3.0.0",
"numpy>=1.24.0,<3.0.0",
"scipy>=1.11.0,<2.0.0",
]
# Note: Install multiple extras directly using: pip install .[test,dev,prod,ml]
# For GPU support: pip install .[ml-gpu] (Linux only)
# For audio: pip install .[audio]
# Removed 'all' extra to avoid self-referential dependency issues
[project.urls]
"Homepage" = "https://github.com/samo-ai/samo-dl"
"Bug Reports" = "https://github.com/samo-ai/samo-dl/issues"
"Source" = "https://github.com/samo-ai/samo-dl"
[project.scripts]
samo-train = "src.training.cli:main"
samo-api = "src.unified_ai_api:main"
# ============================================================================
# TOOL CONFIGURATIONS
# ============================================================================
[tool.setuptools]
package-dir = {"" = "src"}
[tool.setuptools.packages.find]
where = ["src"]
# Ruff Configuration (Linting & Formatting)
[tool.ruff]
target-version = "py38"
line-length = 100
indent-width = 4
# Include/exclude patterns
include = ["*.py", "*.pyi"]
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"data/cache",
"models/*/cache",
"test_checkpoints",
]
[tool.ruff.lint]
# Enable rule categories
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # Pyflakes
"I", # isort
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"UP", # pyupgrade
"SIM", # flake8-simplify
"TCH", # flake8-type-checking
"PTH", # flake8-use-pathlib
"ERA", # eradicate
"PD", # pandas-vet
"PL", # pylint
"NPY", # NumPy-specific rules
"RUF", # Ruff-specific rules
"S", # flake8-bandit (security)
"G", # flake8-logging-format
"T20", # flake8-print
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"D", # pydocstyle
"DTZ", # flake8-datetimez
]
# Disable specific rules that conflict or are too strict
ignore = [
"E501", # Line too long (handled by formatter)
"D203", # One blank line before class (conflicts with D211)
"D213", # Multi-line summary second line (conflicts with D212)
"S101", # Use of assert (common in tests)
"G004", # Logging f-string (acceptable for performance)
"S607", # Starting process with partial path (acceptable for development)
"S603", # Subprocess call (acceptable for development scripts)
"PLR2004", # Magic numbers (too strict for ML constants)
"PLR0913", # Too many arguments (acceptable for ML functions)
"PLR0915", # Too many statements (acceptable for complex functions)
"PD901", # Generic DataFrame names (acceptable for data processing)
"PLC0415", # Import at top-level (acceptable for conditional imports)
"PTH123", # Pathlib usage (acceptable for file operations)
"PTH120", # Pathlib usage (acceptable for file operations)
"PTH108", # Pathlib usage (acceptable for file operations)
"SIM115", # Context manager (acceptable for simple file operations)
"B008", # Function call in defaults (acceptable for FastAPI)
"ARG001", # Unused arguments (acceptable for FastAPI handlers)
"ARG002", # Unused method arguments (acceptable for overrides)
"RUF012", # Mutable class attributes (acceptable for ML models)
"PLE1205", # Logging format (acceptable for development)
"ERA001", # Commented code (acceptable for development)
"W293", # Blank line whitespace (acceptable)
"SIM102", # Nested if statements (acceptable for complex logic)
"B904", # Exception chaining (acceptable for development)
"I001", # Import sorting (acceptable)
"UP035", # Import from collections.abc (acceptable)
"PLW0603", # Global statement (acceptable for model caching)
"UP006", # Use X instead of Y for type annotation (avoid churn in py38 target)
]
# Per-file ignores
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"S101", # Allow assert in tests
"ANN", # Don't require type annotations in tests
"D", # Don't require docstrings in tests
]
"scripts/**" = [
"T20", # Allow print statements in scripts
"ANN", # Don't require type annotations in scripts
"D", # Don't require docstrings in scripts
]
"src/data/sample_data.py" = [
"S311", # Allow random for sample data generation
]
"src/**" = [
"D100", # Missing docstring in public module (too strict for ML modules)
"D102", # Missing docstring in public method (too strict for ML methods)
"D103", # Missing docstring in public function (too strict for ML functions)
"D104", # Missing docstring in public package (too strict for ML packages)
"D105", # Missing docstring in magic method (too strict for ML classes)
"D106", # Missing docstring in public nested class (too strict for ML classes)
"D107", # Missing docstring in __init__ (too strict for ML constructors)
"ANN201", # Missing return type annotations (too strict for ML functions)
"ANN001", # Missing type annotations (too strict for ML arguments)
"ANN003", # Missing type annotations (too strict for ML kwargs)
"ANN202", # Missing return type annotations (too strict for ML private functions)
"ANN204", # Missing return type annotations (too strict for ML special methods)
]
[tool.ruff.lint.pydocstyle]
convention = "google" # Use Google docstring style
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
# MyPy Configuration (Type Checking)
[tool.mypy]
python_version = "3.9"
warn_return_any = false # Too strict for ML code
warn_unused_configs = true
disallow_untyped_defs = false
disallow_incomplete_defs = false
check_untyped_defs = false
disallow_untyped_decorators = false # Too strict for FastAPI
no_implicit_optional = false # Too strict for Python 3.9
warn_redundant_casts = false # Too strict for ML code
warn_unused_ignores = false # Too strict for development
warn_no_return = false # Too strict for ML code
warn_unreachable = false # Too strict for ML code
strict_equality = false # Too strict for ML code
# Ignore missing imports for third-party packages
[[tool.mypy.overrides]]
module = [
"transformers.*",
"datasets.*",
"torch.*",
"numpy.*",
"pandas.*",
"sklearn.*",
"librosa.*",
"soundfile.*",
"whisper.*",
"gensim.*",
"nltk.*",
"spacy.*",
"textblob.*",
]
ignore_missing_imports = true
# Pytest Configuration
[tool.pytest.ini_options]
minversion = "7.0"
addopts = [
"-ra",
"-q",
"--strict-markers",
"--strict-config",
"--cov=src",
"--cov-report=term-missing",
"--cov-report=html",
"--cov-report=xml",
"--cov-fail-under=50", # Raised threshold to 50%
"--tb=short",
]
testpaths = ["tests"]
python_files = ["test_*.py", "*_test.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]
# Test markers
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"gpu: marks tests that require GPU",
"integration: marks integration tests",
"e2e: marks end-to-end tests",
"model: marks tests that load ML models",
"network: marks tests that require network access",
"asyncio: marks tests that use asyncio",
]
# Filter warnings
filterwarnings = [
"error",
"ignore::UserWarning",
"ignore::DeprecationWarning",
"ignore::PendingDeprecationWarning",
"ignore::FutureWarning",
]
# Coverage Configuration
[tool.coverage.run]
source = ["src"]
branch = true
omit = [
"*/tests/*",
"*/test_*",
"*/__pycache__/*",
"*/site-packages/*",
"setup.py",
]
[tool.coverage.report]
precision = 2
show_missing = true
skip_covered = false
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
[tool.coverage.xml]
output = "coverage.xml"
[tool.coverage.html]
directory = "htmlcov"
# Bandit Configuration (Security)
[tool.bandit]
exclude_dirs = ["tests", "test_*", "*_test.py"]
skips = [
"B101", # assert_used - acceptable in tests
"B311", # random - acceptable for sample data generation
"B404", # subprocess import - acceptable for development
"B603", # subprocess_without_shell_equals_true - acceptable for trusted input
"B607", # start_process_with_partial_path - acceptable in controlled environments
"B614", # pytorch_load_save - acceptable for ML model persistence
]
# Safety Configuration (Dependency Vulnerability Scanning)
[tool.safety]
# Ignore specific vulnerabilities if needed
# ignore = ["12345"]
# Black Configuration (Code Formatting) - Fallback if Ruff format not used
[tool.black]
target-version = ['py38']
line-length = 100
skip-string-normalization = false
skip-magic-trailing-comma = false
You can’t perform that action at this time.
