Skip to content

chore(deps): drop hf-classifier extra#2137

Merged
Pouyanpi merged 1 commit into
developfrom
pouyanpi/drop-hf-classifier-deps
Jul 3, 2026
Merged

chore(deps): drop hf-classifier extra#2137
Pouyanpi merged 1 commit into
developfrom
pouyanpi/drop-hf-classifier-deps

Conversation

@Pouyanpi

@Pouyanpi Pouyanpi commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Description

Drop the hf-classifier packaging extra. transformers and torch are heavy
dependencies that we do not want to declare as an installable extra; this
removes the hf-classifier extra and those two packages from the aggregate
all extra.

Coupled with docs PR #1969 (hf_classifier rail docs): its Setup section
currently shows pip install nemoguardrails[hf-classifier], which becomes
invalid once this lands. Whichever PR merges last must reconcile so the docs
show only pip install transformers torch.

AI Assistance

  • No AI tools were used.
  • AI tools were used; a human reviewed and can explain every change (tool: Claude Code).

Checklist

  • I've read the CONTRIBUTING guidelines.
  • This PR links to a triaged issue assigned to me.
  • My PR title follows the project commit convention.
  • I've updated the documentation if applicable. (Docs handled in docs: draft documentation for the hf_classifier rail #1969; see coupling note above.)
  • I've added tests if applicable. (No behavior change; existing test_hf_classifier.py still passes.)
  • I've noted any verification beyond CI and any checks I couldn't run.
  • I did not update generated changelog files manually.
  • I addressed all CodeRabbit, Greptile, and other review comments, or replied with why no change is needed.
  • @mentions of the person or team responsible for reviewing proposed changes.

Summary by CodeRabbit

  • Bug Fixes
    • Clarified the setup error message for the local HF classifier so it now points directly to the required packages to install.
    • Removed the HF classifier package from the bundled optional dependency set, simplifying installation options.

Remove the hf-classifier packaging extra (transformers, torch) and drop
those packages from the aggregate all extra. transformers/torch are heavy
dependencies we do not want to declare as an installable extra.

The hf_classifier rail is unchanged: its local backend already imports
transformers lazily, so users install the packages directly
(pip install transformers torch), matching the jailbreak-detection rail.
The ImportError hint in backends.py is updated to point at the direct
install instead of the removed extra. Regenerate uv.lock accordingly.
@Pouyanpi Pouyanpi self-assigned this Jul 3, 2026
@github-actions github-actions Bot added size: XS status: needs triage New issues that have not yet been reviewed or categorized. labels Jul 3, 2026
@Pouyanpi Pouyanpi added status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile). and removed status: needs triage New issues that have not yet been reviewed or categorized. labels Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 714696f9-b43b-40b5-8b13-6de15ad62f83

📥 Commits

Reviewing files that changed from the base of the PR and between 2e36a78 and 40e7589.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • nemoguardrails/library/hf_classifier/backends.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • pyproject.toml

📝 Walkthrough

Walkthrough

Removed the hf-classifier optional dependency extra and its transformers/torch entries from the all extra in pyproject.toml. Updated the ImportError message in backends.py to instruct installing transformers and torch directly instead of via the removed extra.

Changes

hf-classifier dependency removal

Layer / File(s) Summary
Dependency extra and error message update
pyproject.toml, nemoguardrails/library/hf_classifier/backends.py
Removed the hf-classifier extra and its transformers/torch entries from the all extra, and updated the ImportError message to suggest pip install transformers torch.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: removing the hf-classifier extra.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Test Results For Major Changes ✅ Passed PR description includes testing info (“existing test_hf_classifier.py still passes”), and the code change is a small packaging/message edit.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pouyanpi/drop-hf-classifier-deps

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Pouyanpi Pouyanpi merged commit 716ac48 into develop Jul 3, 2026
16 checks passed
@Pouyanpi Pouyanpi deleted the pouyanpi/drop-hf-classifier-deps branch July 3, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XS status: triaged Triaged by a maintainer; eligible for automated review (CodeRabbit/Greptile).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant