Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
174 lines (162 loc) · 5.86 KB
/
Copy pathpyproject.toml
File metadata and controls
174 lines (162 loc) · 5.86 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
[build-system]
requires = ["setuptools>=83.0.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "drowse.ai"
dynamic = ["version"]
description = "Activation steering and trait monitoring for HuggingFace transformers"
readme = "README.md"
license = "AGPL-3.0-or-later"
authors = [{name = "Drowse Contributors"}]
requires-python = ">=3.11"
keywords = [
"activation-steering",
"representation-engineering",
"interpretability",
"mechanistic-interpretability",
"transformers",
"huggingface",
"llm",
"openai-api",
"ollama",
"sae",
"probing",
]
classifiers = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Environment :: Console",
"Environment :: GPU :: NVIDIA CUDA",
"Environment :: Web Environment",
"Framework :: FastAPI",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
dependencies = [
"torch>=2.13.0",
# >=5.22: Cache.crop takes a (negative) count of tokens to remove; the
# prefix cache relies on that contract.
"transformers>=5.22",
# >=1.26: HfApi.resolve_revision, which pins model reads and J-lens
# bindings to an immutable commit (transformers >=5.18 no longer sets
# config._commit_hash; 5.10 itself only requires huggingface-hub>=1.5).
"huggingface-hub>=1.26",
"accelerate>=0.27",
"safetensors>=0.7.0",
"pyyaml>=6.0",
"fastapi>=0.110",
"uvicorn[standard]>=0.44.0",
]
[project.urls]
Homepage = "https://drowse.ai"
Repository = "https://github.com/stdlogits/drowse"
Issues = "https://github.com/stdlogits/drowse/issues"
Releases = "https://github.com/stdlogits/drowse/releases"
[project.optional-dependencies]
flash = ["flash-attn>=2.5"]
cuda = ["bitsandbytes>=0.43", "kernels>=0.12"]
dev = ["build>=1.2", "pytest>=8.0", "pytest-cov>=5.0", "pytest-xdist>=3.6", "httpx>=0.27", "ruff>=0.6.9", "pyright>=1.1.400"]
# SAELens sources (``sae fetch``); nltk is pinned past its CVE'd releases.
sae = ["sae-lens>=6.0,<7.0", "nltk>=3.10.3"]
hf = ["datasets>=2.0"]
gguf = ["gguf>=0.10"]
research = [
"datasets>=2.0",
"matplotlib>=3.8",
"numpy>=1.26",
"pandas>=3.0.2",
"pillow>=10",
"scikit-learn>=1.4",
"scipy>=1.11",
]
notebook = ["plotly>=5.0", "pandas>=3.0.2", "kaleido>=0.2"]
[project.scripts]
drowse = "drowse.cli.main:main"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = ["--strict-markers"]
xfail_strict = true
markers = [
"gpu: requires a CUDA or MPS backend (deselect with `-m \"not gpu\"`)",
"perf: wall-clock throughput test; skipped under xdist, run with `pytest -m perf -p no:xdist`",
]
filterwarnings = [
# Python 3.14 flags SWIG-generated builtin types in transitive C deps
# (scipy/PIL). Not drowse code and nothing we can fix upstream.
"ignore:builtin type Swig(Py(Packed|Object)|varlink) has no __module__ attribute:DeprecationWarning",
]
[tool.ruff]
line-length = 120
target-version = "py311"
[tool.ruff.lint]
select = ["E", "F", "W", "T20"]
ignore = ["E501", "E741", "E402", "E731"]
[tool.ruff.lint.per-file-ignores]
# CLI runners and the cli/output.py presentation layer are the
# canonical print-to-stdout sites; T20 (flake8-print) is meant to
# catch debug-print leakage in the engine, IO, and server.
"drowse/cli/*" = ["T20"]
# Maintenance/benchmark scripts are stand-alone and intentionally
# print to stdout for diagnostic output and progress reporting.
"scripts/*" = ["T20"]
# Examples are runnable demos that print results.
"examples/*" = ["T20"]
# Pyright — whole-project type checking. Historically scoped to the
# public-API surface because the engine/CLI/server layers lean on
# torch/transformers/fastapi internals whose stubs are uneven;
# the maintained library, tests, examples, and utility scripts are now fully
# annotated, so the rules below hold across those surfaces.
#
# ``standard`` mode (rather than ``strict``) is deliberate: ``strict``
# turns on ``reportUnknown*`` and those fire constantly on legitimate
# ``Tensor.norm()`` / ``Tensor.item()`` calls because torch's type stubs
# are partial. We escalate the rules that actually catch bugs (missing
# parameter types, missing type arguments, attribute access, argument /
# call / return / assignment issues) to error; the irreducible torch
# stub-gap noise (private re-exports) stays at warning.
[tool.pyright]
include = [
"drowse",
"tests",
"scripts",
"examples",
]
exclude = ["**/__pycache__", "**/node_modules"]
pythonVersion = "3.11"
typeCheckingMode = "standard"
reportMissingTypeStubs = false
reportMissingImports = "warning"
reportMissingParameterType = "error"
reportMissingTypeArgument = "error"
reportAttributeAccessIssue = "error"
reportArgumentType = "error"
reportCallIssue = "error"
reportReturnType = "error"
reportAssignmentType = "error"
reportUnnecessaryIsInstance = "warning"
# torch re-exports `dtype`, `device`, `float32`, `dot` etc. through
# its public namespace, but its stubs don't list them in __all__.
# Newer pyright treats that as a private-import error; downgrade to
# warning so legitimate public API references don't break CI.
reportPrivateImportUsage = "warning"
[tool.setuptools.dynamic]
# Single literal lives in drowse/__init__.py; setuptools reads it via AST
# parsing without executing the module (so the eager torch re-export at
# drowse/__init__.py doesn't fire at build time). The CI ``build`` job
# in .github/workflows/ci.yml is the validation gate.
version = {attr = "drowse.__version__"}
[tool.setuptools.packages.find]
include = ["drowse*"]
[tool.setuptools.package-data]
drowse = [
"data/**/*.json",
"py.typed",
"web/dist/*",
"web/dist/**/*",
]