-
Notifications
You must be signed in to change notification settings - Fork 101
/
pyproject.toml
296 lines (251 loc) · 8.66 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
[tool.poetry]
name = "ibm-generative-ai"
authors = [
"Tomas Dvorak <[email protected]>",
"Radek Jezek <[email protected]>",
"David Kristek <[email protected]>",
]
maintainers = [
"Tomas Dvorak <[email protected]>",
"Radek Jezek <[email protected]>",
]
description = "IBM Generative AI is a Python library built on IBM's large language model REST interface."
readme = "README.md"
version = "0.0.0"
packages = [{include = "genai", from="src"}]
[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
build-backend = "poetry_dynamic_versioning.backend"
[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "semver"
strict = true
metadata = false
[tool.poetry-dynamic-versioning.substitution]
folders = [
{ path = "src" }
]
[tool.poetry.dependencies]
python = "^3.9"
pydantic = "^2.0.0"
httpx = "^0.27.0"
aiolimiter = "^1.1.0"
httpx-sse = "^0.4.0"
langchain-core = { version = "^0.1.0", optional = true }
pyyaml = { version = "^6.0.0", optional = true }
transformers = { version = "^4.33.3", optional = true, extras=["agents"] }
llama-index-core = { version = "^0.10.0", optional = true }
uvicorn = { version = "^0.22.0", optional = true }
fastapi = { version = "^0.100.0", optional = true }
deprecated = "^1.2.14"
lm-eval = { version = "^0.4.2", optional = true }
tqdm = { version = "^4.66.1", optional = true }
[tool.black] # left for IDE compatibility (pycharm)
line-length = 120
[tool.ruff]
line-length = 120
extend-exclude = ['src/genai/_version.py']
target-version = "py39"
[tool.ruff.lint]
select = [ # See docs for available rules: https://docs.astral.sh/ruff/rules
"B", # bugbear (assignment to os.environ, assert False, ...)
"C", # mccabe (too complex structures, ...)
"E", # error (line too long, syntax error, ...)
"F", # pyflakes (unused imports, variables, ...)
"I", # isort
"W", # pycodestyle (indentation, whitespace, ...)
"T20", # flake8-print (print found, pprint found, ...)
]
[tool.ruff.lint.mccabe]
max-complexity = 18
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403", "F405"] # Ignore import violations in all `__init__.py` files.
"examples/**/*.py" = ["T201", "T203", "B904"] # Examples can include print and pprint, ignore exception propagation
"src/genai/schema/_api.py" = ["E501"] # Generated can include long lines
"tests/unit/docs_examples_generator/assets/**/*.py" = ["T201"] # Allow prints
[tool.ruff.lint.isort]
known-first-party = ["genai"]
[tool.poetry.group.dev.dependencies]
python-dotenv = "^1.0.1"
datasets = "^2.18.0"
pytest = "^8.1.1"
pytest-dotenv = "^0.5.2"
pre-commit = "^3.6.2"
pytest-cov = "^4.1.0"
sphinx = "^7.2.6"
furo = "^2024.1.29"
pytest-asyncio = "^0.21.1"
pytest-mock = "^3.14.0"
datamodel-code-generator = { version="^0.25.2", extras=["http"] }
vcrpy = "^6.0.1"
pytest-recording = "^0.13.1"
pytest-subtests = "^0.11.0"
autodoc_pydantic = "^2.1.0"
ruff = "^0.3.3"
poethepoet = "^0.24.4"
pandas = "^2.2.1"
pyyaml = "^6.0.1"
tqdm = "^4.66.2"
sphinx-toolbox = "3.5.0"
git-changelog = "2.4.0"
gitchangelog = "3.0.4"
pystache = "0.6.5"
tabulate = "0.9.0"
m2r = "^0.3.1"
sphinx-multiversion = {path = "external/sphinx_multiversion"}
sphinx-copybutton = "^0.5.2"
sphinx-notfound-page = "^1.0.0"
langchain = "^0.1.4"
sqlalchemy = "^2.0.28"
pytest-httpx = "^0.30.0"
[tool.poetry.extras]
langchain = ["langchain-core", "pyyaml"]
huggingface = ["datasets", "transformers"]
llama-index = ["llama-index-core"]
lm-eval = ["lm-eval", "tqdm"]
localserver = ["uvicorn", "fastapi"]
[tool.pytest.ini_options]
addopts = "--cov --cov-report term-missing --cov-fail-under 80 -v"
testpaths = ["tests"]
markers = [
"unit",
"integration",
"e2e",
"extension"
]
env_files = [
".test.env"
]
pythonpath = ["src", "scripts"]
[tool.coverage.run]
source = ["src"]
[tool.setuptools_scm]
write_to = "src/genai/_version.py"
local_scheme = "no-local-version"
[tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/src,$MYPY_CONFIG_FILE_DIR/scripts,$MYPY_CONFIG_FILE_DIR/tests"
exclude = "^build/$"
check_untyped_defs = true
plugins = ["pydantic.mypy"]
[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
[tool.poe.tasks.install]
help = "Install dependencies for the SDK core and it's extensions"
cmd = "poetry install --all-extras --without dev"
[tool.poe.tasks.lm_eval]
help = "Run lm_eval with support for genai models"
cmd = "python -m genai.extensions.lm_eval"
[tool.poe.tasks.install-dev]
help = "Install dependencies and related tooling for development"
sequence = [{ cmd = "poetry install --all-extras" }, { cmd = "pre-commit install" }]
deps = ["install"]
[tool.poe.tasks.clean]
help = "Remove all artifacts and builds"
sequence = [
{ script = "shutil:rmtree('build/', ignore_errors=1)"},
{ script = "shutil:rmtree('dist/', ignore_errors=1)"},
{ ref = "docs --type=clear" }
]
[tool.poe.tasks.format]
help = "Run all formating tools"
sequence = [
{ "cmd" = "ruff format"}, # format code
{ "cmd" = "ruff check --select I --fix" } # sort imports
]
[tool.poe.tasks.lint]
help = "Check for errors and fix them using ruff (includes isort)"
cmd = "ruff check --fix"
[tool.poe.tasks.schema]
help = "Generate Pydantic models and endpoints information from OpenAPI"
env = { "PYTHONPATH" = "scripts" }
sequence = [{ cmd = "python scripts/types_generator/main.py" }, { ref = "format", "cwd" = "src/genai/schema"}]
[tool.poe.tasks._git]
control.expr = "type"
args = ["type"]
[[tool.poe.tasks._git.switch]]
case = "latest_tag"
help = "Finds the latest released version (by GIT tag lookup)"
shell = "git tag --sort version:refname | grep -E '[0-9]' | tail -1"
[[tool.poe.tasks._git.switch]]
case = "current_branch"
help = "Gets the current branch name"
shell = "git rev-parse --abbrev-ref HEAD"
[tool.poe.tasks.docs]
help = "Documentation related commands"
control.expr = "type"
args = ["type"]
uses = { LATEST_VERSION = "_git --type latest_tag", CURRENT_BRANCH="_git --type current_branch" }
[[tool.poe.tasks.docs.switch]]
case = "help"
help = "Show help"
cmd = "make"
[[tool.poe.tasks.docs.switch]]
case = "build"
help = "Update sources for the documentation and build static HTML"
sequence = [
{ shell = '[ -z "$(git status -uno --porcelain)" ] || { echo "Your index contains uncommitted changes! Commit them and try again." && exit 1; }' },
"docs --type=clear",
{ cmd = "make docs", cwd = "documentation" },
{ cmd = 'python scripts/docs_root_redirect.py --prefix="${DOCS_URL_PREFIX}" --version="${LATEST_VERSION}" --output="./documentation/build"', env = { "PYTHONPATH" = "scripts" } },
]
[[tool.poe.tasks.docs.switch]]
case = "open"
help = "Open HTML Documentation"
cwd = "documentation"
cmd = "open build/${CURRENT_BRANCH}/index.html"
uses = { CURRENT_BRANCH="_git --type current_branch" }
[[tool.poe.tasks.docs.switch]]
case = "clear"
help = "Remove build"
cwd = "documentation"
sequence = [{ "script" = "shutil:rmtree('build/', ignore_errors=1)" }, { "script" = "shutil:rmtree('source/rst_source', ignore_errors=1)" }]
[tool.poe.tasks.changelog]
help = "Changelog related commands"
control.expr = "type"
args = [
{ name = "type" },
{ name = "version", positional = true },
]
[[tool.poe.tasks.changelog.switch]]
case = "update"
help = "Update unreleased changelog section"
env = { "PYTHONPATH" = "scripts" }
cmd = "python scripts/docs_changelog_generator/generate_changelog.py --debug"
[[tool.poe.tasks.changelog.switch]]
case = "release"
help = "Sets version to the latest entry in the CHANGELOG"
env = { "PYTHONPATH" = "scripts" }
cmd = "python scripts/docs_changelog_generator/release_changelog.py $version"
[tool.poe.tasks.test]
args = ["type"]
control.expr = "type"
[[tool.poe.tasks.test.switch]]
case = "unit"
help = "Run Unit Tests"
cmd = "pytest -m 'unit'"
[[tool.poe.tasks.test.switch]]
case = "integration"
help = "Run Integration Tests"
cmd = "pytest -m 'integration' tests/integration"
[[tool.poe.tasks.test.switch]]
case = "extension"
help = "Run Extension Tests"
cmd = "pytest -m 'integration'"
[[tool.poe.tasks.test.switch]]
case = "e2e"
help = "Run E2E Tests"
cmd = "pytest -m 'e2e'"
[[tool.poe.tasks.test.switch]]
case = "rewrite_casettes"
help = "Rewrite casettes for failed tests (usually due to API endpoint version update)"
cmd = "scripts/rewrite_casettes.sh"
[[tool.poe.tasks.test.switch]]
case = "check_markers"
help = "Check if all tests have proper markers (unit, integration or e2e)"
cmd = "scripts/check_markers.sh"
[[tool.poe.tasks.test.switch]]
help = "Run All Tests"
cmd = "pytest"