Skip to content

Add optional extras to slim the core dependency set#112

Open
levon003 wants to merge 6 commits into
mainfrom
chore/litellm-optional-extra
Open

Add optional extras to slim the core dependency set#112
levon003 wants to merge 6 commits into
mainfrom
chore/litellm-optional-extra

Conversation

@levon003
Copy link
Copy Markdown
Member

@levon003 levon003 commented Jun 5, 2026

What

Trims FlexEval's core dependency set so a plain pip install python-flexeval is substantially leaner. Three optional, user-facing features now live behind extras, and several dependencies that were only needed for tests/dev have moved to the dev group (or been dropped).

Partially addresses #87.

Optional extras

Extra Package Enables
litellm litellm litellm_completion — routing completions to many non-OpenAI providers
langgraph langgraph-checkpoint the langgraph_sqlite data source (loading langgraph checkpoint DBs)
viz matplotlib the visualize_graph helper (metric dependency-graph plots)

Install with e.g. pip install 'python-flexeval[litellm]' (or combine: [litellm,langgraph,viz]).

Dependency moves

  • Dropped entirely: langchain — nothing in the repo imports it.
  • Moved to the dev group (test/fixture-only): langchain-openai, langgraph, langgraph-checkpoint-sqlite (unit tests + fixtures), and sympy (integration-test fixtures only).
  • Each extra's package is also kept in dev (or pulled in transitively) so a plain uv sync still gives contributors the full feature set and CI can exercise everything.

How it works

  • Lazy imports. Each optional dependency is imported inside the function that needs it, with a friendly error pointing at the right extra:
    • litellm → inside litellm_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) → inside load_langgraph_sqlite (data_loader.py). Everything else referencing "langgraph" in src/ is peewee field names / enum values, not package imports — so this single wrapped import is sufficient.
    • matplotlib → inside visualize_graph (helpers.py), already defensive; error message now points at the viz extra.
  • visualize_graph tidied while in there: accepts an optional ax, returns (fig, ax) so it composes into a caller's figure, and the inline node-label construction moved into _graph_node_label.
  • CI: validate.yaml now runs uv sync --all-extras so every extra is tested (and stays future-proof as more deps become optional).
  • Docs: getting_started.rst documents 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 via uv sync --all-extras.
  • Simulated each dependency being absent: flexeval imports fine, and the relevant function raises a clear ImportError with the correct pip install 'python-flexeval[...]' hint.
  • visualize_graph smoke-tested: returns (fig, ax), honors a passed-in ax, and still writes output_path.
  • Built-wheel metadata confirms litellm / langgraph / viz are opt-in extras and that langchain / langgraph / langgraph-checkpoint-sqlite / sympy are no longer core Requires-Dist.

Upgrade note

These are user-visible install changes: anyone currently relying on litellm, langgraph checkpoint loading, or visualize_graph from a plain pip install python-flexeval will 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

levon003 and others added 3 commits June 4, 2026 17:33
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>
@levon003 levon003 changed the title Make litellm an optional extra Slim the core dependency set with optional extras Jun 5, 2026
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>
@levon003 levon003 changed the title Slim the core dependency set with optional extras Add optional extras to slim the core dependency set Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant