Add optional extras to slim the core dependency set#112
Open
levon003 wants to merge 6 commits into
Open
Conversation
litellm is a convenience for routing completions to non-OpenAI providers, but most users don't need it. Move it out of the core dependencies into a `litellm` optional extra so the base install is lighter. - pyproject.toml: declare [project.optional-dependencies] litellm; keep it in the dev group so `uv sync` and the test suite still cover litellm_completion. - completion_functions.py: import litellm lazily inside litellm_completion with a friendly install hint, since the module is imported eagerly by core code. - validate.yaml: `uv sync --all-extras` so CI tests all extras. - docs: document `pip install 'python-flexeval[litellm]'`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Trim the core dependency set so a base install is lighter: - langgraph checkpoint loading is now an opt-in `langgraph` extra. The runtime only needs JsonPlusSerializer (from langgraph-checkpoint); the DB is read with stdlib sqlite3. The import in load_langgraph_sqlite is now lazy with a friendly install hint. Everything else referencing "langgraph" in src/ is peewee field names / enum values, not package imports. - Drop `langchain` entirely: nothing in the repo imports it. - Move test-only deps to the dev group: langchain-openai, langgraph, langgraph-checkpoint-sqlite (test fixtures / unit tests), and sympy (integration test fixtures only). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
matplotlib is only used by the optional visualize_graph helper, so declare it as a `viz` extra (pip install 'python-flexeval[viz]') rather than a core dep. The defensive import now points users at the extra. Also tidy the helper while here: accept an optional `ax`, return (fig, ax) so it composes into a caller's figure, and extract the node-label construction into _graph_node_label. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Minor bump for the optional-extras change: litellm, langgraph checkpoint loading, and visualize_graph (matplotlib) now require their respective extras. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Trims FlexEval's core dependency set so a plain
pip install python-flexevalis substantially leaner. Three optional, user-facing features now live behind extras, and several dependencies that were only needed for tests/dev have moved to thedevgroup (or been dropped).Partially addresses #87.
Optional extras
litellmlitellmlitellm_completion— routing completions to many non-OpenAI providerslanggraphlanggraph-checkpointlanggraph_sqlitedata source (loading langgraph checkpoint DBs)vizmatplotlibvisualize_graphhelper (metric dependency-graph plots)Install with e.g.
pip install 'python-flexeval[litellm]'(or combine:[litellm,langgraph,viz]).Dependency moves
langchain— nothing in the repo imports it.devgroup (test/fixture-only):langchain-openai,langgraph,langgraph-checkpoint-sqlite(unit tests + fixtures), andsympy(integration-test fixtures only).dev(or pulled in transitively) so a plainuv syncstill gives contributors the full feature set and CI can exercise everything.How it works
litellm→ insidelitellm_completion(completion_functions.py). It was previously a top-level import in a module imported eagerly by core code, so without this the base install would break for everyone.langgraph-checkpoint(JsonPlusSerializer) → insideload_langgraph_sqlite(data_loader.py). Everything else referencing "langgraph" insrc/is peewee field names / enum values, not package imports — so this single wrapped import is sufficient.matplotlib→ insidevisualize_graph(helpers.py), already defensive; error message now points at thevizextra.visualize_graphtidied while in there: accepts an optionalax, returns(fig, ax)so it composes into a caller's figure, and the inline node-label construction moved into_graph_node_label.validate.yamlnow runsuv sync --all-extrasso every extra is tested (and stays future-proof as more deps become optional).getting_started.rstdocuments each extra's install command.Verification
uv run python -m unittest discover -s tests.unit→ 67 pass (6 pre-existing expected failures); ruff clean. Green in CI viauv sync --all-extras.flexevalimports fine, and the relevant function raises a clearImportErrorwith the correctpip install 'python-flexeval[...]'hint.visualize_graphsmoke-tested: returns(fig, ax), honors a passed-inax, and still writesoutput_path.litellm/langgraph/vizare opt-in extras and thatlangchain/langgraph/langgraph-checkpoint-sqlite/sympyare no longer coreRequires-Dist.Upgrade note
These are user-visible install changes: anyone currently relying on
litellm, langgraph checkpoint loading, orvisualize_graphfrom a plainpip install python-flexevalwill need to add the relevant extra after this ships. Worth a line in the release notes for the next version bump.🤖 Generated with Claude Code