Skip to content

Commit 833fece

Browse files
authored
refactor: reorganize dependencies following PEP 735 (#588)
* refactor: reorganize dependencies following PEP 735 - Remove unused dependencies (json5, ansicolors) - Move type stubs to typecheck group (types-requests, types-tqdm) - Move server components to optional server group (uvicorn, fastapi) - Move llm-sandbox to optional sandbox group - Move huggingface-hub to hf optional group - Create granite_retriever optional group (elasticsearch, pyarrow, sentence-transformers) - Split dev group into modular groups (lint, test, typecheck, build, release) - Add dev group using PEP 735 include-group syntax - Move langchain-community and ddgs to test group - Add langchain-core to tools group - Update CONTRIBUTING.md installation instructions Closes #583 Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * chore: align import errors with new optional dependencies Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> * feat: add backends dependency group Adds 'backends' extra for installing just backend dependencies (watsonx, hf, vllm, litellm) without additional features. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com> --------- Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
1 parent 8a385d5 commit 833fece

6 files changed

Lines changed: 201 additions & 99 deletions

File tree

AGENTS.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ AGENTS.md — Instructions for AI coding assistants (Claude, Cursor, Copilot, Co
1717
- The virtual environment is `.venv/``uv run` automatically uses it
1818

1919
```bash
20-
pre-commit install # Required: install git hooks
21-
uv sync --all-extras --all-groups # Install all deps (required for tests)
22-
ollama serve # Start Ollama (required for most tests)
23-
uv run pytest # Default: qualitative tests, skip slow tests
24-
uv run pytest -m "not qualitative" # Fast tests only (~2 min)
25-
uv run pytest -m slow # Run only slow tests (>5 min)
26-
uv run pytest --co -q # Run ALL tests including slow (bypass config)
27-
uv run ruff format . # Format code
28-
uv run ruff check . # Lint code
29-
uv run mypy . # Type check
20+
pre-commit install # Required: install git hooks
21+
uv sync --all-extras --all-groups # Install all deps (required for tests)
22+
uv sync --extra backends --all-groups # Install just backend deps (lighter)
23+
ollama serve # Start Ollama (required for most tests)
24+
uv run pytest # Default: qualitative tests, skip slow tests
25+
uv run pytest -m "not qualitative" # Fast tests only (~2 min)
26+
uv run pytest -m slow # Run only slow tests (>5 min)
27+
uv run pytest --co -q # Run ALL tests including slow (bypass config)
28+
uv run ruff format . # Format code
29+
uv run ruff check . # Lint code
30+
uv run mypy . # Type check
3031
```
3132
**Branches**: `feat/topic`, `fix/issue-id`, `docs/topic`
3233

CONTRIBUTING.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,13 @@ to melleaadmin@ibm.com.
5858
source .venv/bin/activate # On Windows: .venv\Scripts\activate
5959
```
6060

61-
3. **Install with all dependencies:**
61+
3. **Install dependencies:**
6262
```bash
63+
# Install all dependencies (recommended for development)
6364
uv sync --all-extras --all-groups
64-
```
65-
66-
Or for minimal development setup:
67-
```bash
68-
uv pip install -e ".[all]" --group dev --group notebook --group docs
65+
66+
# Or install just the backend dependencies
67+
uv sync --extra backends --all-groups
6968
```
7069

7170
4. **Install pre-commit hooks (Required):**

mellea/backends/tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def parameter_remapper(*args, **kwargs):
7676
except ImportError as e:
7777
raise ImportError(
7878
f"It appears you are attempting to utilize a langchain tool '{type(tool)}'. "
79-
"Please install langchain core: uv pip install langchain-core"
79+
"Please install mellea with tools support: pip install 'mellea[tools]'"
8080
) from e
8181

8282
@classmethod
@@ -131,7 +131,7 @@ def tool_call(*args, **kwargs):
131131
except ImportError as e:
132132
raise ImportError(
133133
f"It appears you are attempting to utilize a smolagents tool '{type(tool)}'. "
134-
"Please install mellea with smolagents support: uv pip install 'mellea[smolagents]'"
134+
"Please install mellea with tools support: pip install 'mellea[tools]'"
135135
) from e
136136

137137
@classmethod

mellea/stdlib/tools/interpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def execute(self, code: str, timeout: int) -> ExecutionResult:
203203
stdout=None,
204204
stderr=None,
205205
skipped=True,
206-
skip_message="llm-sandbox not installed. Install with: uv add 'llm-sandbox[docker]'",
206+
skip_message="llm-sandbox not installed. Install with: pip install 'mellea[sandbox]'",
207207
)
208208

209209
try:

pyproject.toml

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,23 @@ dependencies = [
2929
"pydantic",
3030
"openai",
3131
"jinja2",
32-
"json5",
3332
"ollama>=0.5.1",
34-
"ansicolors",
3533
"requests>=2.32.3",
36-
"uvicorn",
37-
"fastapi",
38-
"types-requests",
39-
"types-tqdm",
4034
"typer",
4135
"click<8.2.0", # Newer versions will cause errors with --help in typer CLIs.
4236
"mistletoe>=1.4.0",
43-
"huggingface-hub>=0.33.4",
4437
"pillow", # Needed for Intrinsics (HF and OpenAI Backends).
4538
"math_verify", # Needed for Majority Voting Sampling Strategies.
4639
"rouge_score", # Needed for Majority Voting Sampling Strategies.
47-
"llm-sandbox[docker]>=0.3.23",
4840
]
4941

5042
[project.scripts]
5143
m = "cli.m:cli"
5244

5345
[project.optional-dependencies]
54-
# Use these like:
55-
# uv pip install "mellea[hf]"
56-
# uv pip install -e ".[hf, watsonx]"
57-
# if you want to install all dependencies, use uv sync --all-extras
46+
# Install optional features: pip install "mellea[all]" or uv sync --all-extras
5847

48+
# Backend integrations
5949
hf = [
6050
"accelerate>=1.9.0",
6151
"datasets>=4.0.0",
@@ -64,11 +54,12 @@ hf = [
6454
"transformers>=4.53.2,<5",
6555
"trl==0.19.1",
6656
"xgrammar", # Necessary for granite_common intrinsics.
57+
"huggingface-hub>=0.33.4",
6758
]
6859

6960
vllm = [
7061
"vllm>=0.13.0; sys_platform != 'darwin'",
71-
"numpy<=2.2", # ImportError: Numba needs NumPy 2.2 or less. Got NumPy 2.4.
62+
"numpy<=2.2", # ImportError: Numba needs NumPy 2.2 or less. Got NumPy 2.4.
7263
]
7364

7465
litellm = [
@@ -80,14 +71,10 @@ watsonx = [
8071
"ibm-watsonx-ai>=1.3.31",
8172
]
8273

83-
docling = [
84-
"docling>=2.45.0",
85-
]
86-
74+
# Feature integrations
8775
tools = [
8876
"smolagents>=1.0.0",
89-
"langchain-community>=0.3.0",
90-
"ddgs>=9.0.0", # Required by DuckDuckGoSearchResults in langchain-community
77+
"langchain-core>=1.2.7",
9178
]
9279

9380
telemetry = [
@@ -97,31 +84,79 @@ telemetry = [
9784
"opentelemetry-distro>=0.59b0",
9885
]
9986

100-
all = ["mellea[watsonx,docling,hf,vllm,litellm,tools,telemetry]"]
87+
docling = [
88+
"docling>=2.45.0",
89+
]
90+
91+
granite_retriever = [
92+
"sentence-transformers",
93+
"pyarrow",
94+
"elasticsearch>=8.0.0,<9.0.0",
95+
]
96+
97+
# Infrastructure
98+
server = [
99+
"uvicorn",
100+
"fastapi",
101+
]
102+
103+
sandbox = [
104+
"llm-sandbox[docker]>=0.3.23",
105+
]
106+
107+
backends = ["mellea[watsonx,hf,vllm,litellm]"]
108+
109+
all = ["mellea[backends,docling,tools,telemetry,server,sandbox,granite_retriever]"]
101110

102111
[dependency-groups]
103-
# Use these like:
104-
# pip install -e . --group dev
105-
# pip install mellea --group dev
106-
dev = [
112+
# Development groups: uv sync --all-groups
113+
114+
# Code quality
115+
lint = [
116+
"ruff>=0.11.6",
107117
"isort>=6.0.0",
108118
"pre-commit>=4.2.0",
109119
"pylint>=3.3.4",
110-
"ruff>=0.11.6",
111-
"pdm>=2.24.0",
120+
]
121+
122+
test = [
112123
"pytest",
113124
"pytest-asyncio",
114125
"pytest-cov>=6.0.0",
115126
"pytest-timeout", # For test suite timeout configuration
116127
"psutil", # For test infrastructure: RAM detection in conftest.py
128+
"nbmake>=1.5.5", # Notebook testing
129+
"sentencepiece==0.2.1", # Necessary for test_huggingface_tools test because of Mistral model
130+
"jsonschema",
131+
# Example-only dependencies (run via pytest)
132+
"langchain-community>=0.3.0",
133+
"ddgs>=9.0.0", # Required by DuckDuckGoSearchResults in langchain-community
134+
]
135+
136+
typecheck = [
117137
"mypy>=1.17.0",
138+
"types-requests",
139+
"types-tqdm",
140+
]
141+
142+
build = [
143+
"pdm>=2.24.0",
144+
]
145+
146+
release = [
118147
"python-semantic-release~=7.32",
119-
"nbmake>=1.5.5",
120-
"langchain-core>=1.2.7", # Necessary for mypy and some tool tests
121-
"sentencepiece==0.2.1", # Necessary for test_huggingface_tools test because of Mistral model
122-
"jsonschema",
123148
]
124149

150+
# Convenience: includes all dev dependencies (used by default with uv run)
151+
dev = [
152+
{include-group = "lint"},
153+
{include-group = "test"},
154+
{include-group = "typecheck"},
155+
{include-group = "build"},
156+
{include-group = "release"},
157+
]
158+
159+
# Documentation and notebooks
125160
notebook = [
126161
"ipykernel>=6.29.5",
127162
"ipython>=8.36.0",
@@ -134,13 +169,6 @@ docs = [
134169
"sphinx_mdinclude",
135170
]
136171

137-
# Necessary for granite retriever.
138-
granite_common_retriever = [
139-
"sentence-transformers",
140-
"pyarrow",
141-
"elasticsearch>=8.0.0,<9.0.0"
142-
]
143-
144172
# -----------------------------
145173
# Ruff - Linting and Formatting
146174
# -----------------------------

0 commit comments

Comments
 (0)