Skip to content

feat: make datasets and litellm optional dependencies#1972

Closed
astefanutti wants to merge 6 commits into
harbor-framework:mainfrom
astefanutti:feat/optional-heavy-deps
Closed

feat: make datasets and litellm optional dependencies#1972
astefanutti wants to merge 6 commits into
harbor-framework:mainfrom
astefanutti:feat/optional-heavy-deps

Conversation

@astefanutti

@astefanutti astefanutti commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • datasets + pyarrow/pandas/numpy (180MB), and litellm (55MB) from core dependencies to optional extras
  • Add three new extras: harbor[claude-sdk], harbor[datasets], harbor[litellm]
  • Convert unguarded top-level imports to lazy function-level imports with actionable error messages
  • Base install drops from 544MB to 39MB (93% reduction), including the work done in Remove dead Claude Agent SDK usage #2023.

Test plan

  • All 3430 unit tests pass
  • Ruff lint/format clean, ty type checker shows no new diagnostics
  • harbor --help and harbor run --help work in a slim venv without optional deps
  • Dev workflow unchanged (dev group and all meta-extra include all three)
  • End-to-end eval run with harbor run -t hello-world/hello-world

Closes #1971


Open in Devin Review

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

@astefanutti is attempting to deploy a commit to the Harbor Framework Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Enjoy a better diff viewing experience by clicking one of these URLs:

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@astefanutti astefanutti force-pushed the feat/optional-heavy-deps branch from 66f5470 to e8ce15b Compare June 18, 2026 15:06
@Kurry

Kurry commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This is an interesting insight. They really don't like big changes though.

@astefanutti astefanutti force-pushed the feat/optional-heavy-deps branch from e8ce15b to cd3e76e Compare June 23, 2026 10:31

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment on lines +48 to +55
def _build_provider_model_names():
try:
import litellm
except ImportError:
raise ImportError(
"litellm is required for model provider detection. "
"Install it with: pip install 'harbor[litellm]'"
) from None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Agents like openhands, mini_swe_agent, swe_agent now require harbor[litellm] at runtime

Files like src/harbor/agents/installed/mini_swe_agent.py:13, openhands.py:11, and swe_agent.py:13 have top-level from harbor.agents.utils import get_api_key_var_names_from_model_name. Importing this function is safe (no litellm import triggered at import time after this PR), but calling it will raise ImportError if litellm is not installed. Before this PR, litellm was always available. This is a behavioral change for users who install harbor without [litellm] — these agents will fail at runtime with an ImportError when trying to resolve API keys. The error message from _build_provider_model_names() at src/harbor/agents/utils.py:52-54 is clear about how to fix it, so this is acceptable but worth noting in release documentation.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@astefanutti astefanutti changed the title feat: make claude-agent-sdk, datasets, and litellm optional dependencies feat: make datasets and litellm optional dependencies Jun 23, 2026
@astefanutti

Copy link
Copy Markdown
Contributor Author

@alexgshaw I've rebased on top of #2023 which happens to make this PR much simpler as you hinted during the community call, thanks!

@alexgshaw

Copy link
Copy Markdown
Collaborator

Huh, is the datasets dependency even being used anywhere? I don't see any changed references in your PR.

@astefanutti

Copy link
Copy Markdown
Contributor Author

Yes that PR just moves the dependency from core to optional in pyproject.toml.

The datasets imports were already guarded with try/except and function-level imports like in traces_utils.py and sweeps.py, so no code changes were actually needed.

datasets is only used for HuggingFace Hub export, not the eval loop.

Move three heavy dependencies from core to optional extras, reducing
base install from 544MB to 39MB (93% reduction):

- claude-agent-sdk (219MB) → harbor[claude-sdk]
- datasets + pyarrow + pandas + numpy (180MB) → harbor[datasets]
- litellm (55MB) → harbor[litellm]

All three are peripheral to the core eval loop (trial runner,
orchestrators, verifier). Imports are converted to function-level
lazy loading with clear error messages pointing users to the right
extra when a feature requires an optional dependency.

The dev dependency group and `all` meta-extra include all three,
so development workflows are unchanged.
The model_info registration in __init__ was unguarded — would crash
if litellm isn't installed and model_info kwarg is passed.
…r in annotator

- Add try/except around get_llm_provider import with user-friendly error
- Move import check before @Retry decorator so ImportError fails immediately
  instead of retrying 3 times with exponential backoff
@astefanutti astefanutti force-pushed the feat/optional-heavy-deps branch from 3efb6b0 to 71e8936 Compare June 29, 2026 07:31
@github-actions github-actions Bot removed the area:cli label Jun 29, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

The datasets library is an optional extra, but several code paths in
traces_utils.py and sweeps.py imported it bare, surfacing a raw
ModuleNotFoundError (or a generic RuntimeError) instead of the
install-hint pattern used everywhere else in this PR.

Add a `_require_datasets()` helper in traces_utils.py and route the
runtime import sites through it; wrap the sweeps.py export import with
the same try/except. Missing datasets now raises a clear ImportError
pointing to `pip install 'harbor[datasets]'`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@astefanutti

Copy link
Copy Markdown
Contributor Author

I've actually added some import guards for datasets as per Devin's review feedback.

@alexgshaw I think it's ready for another review when you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: make claude-agent-sdk, datasets, and litellm optional dependencies

3 participants