Skip to content

Add __all__ exports to metrics modules - #108

Merged
Khanz9664 merged 3 commits into
Khanz9664:mainfrom
JavadTe:add-metrics-all-exports
May 24, 2026
Merged

Khanz9664 merged 3 commits into
Khanz9664:mainfrom
JavadTe:add-metrics-all-exports

Conversation

@JavadTe

@JavadTe JavadTe commented May 24, 2026 •

Copy link
Copy Markdown
Contributor

Pull Request Template

Summary

This pull request adds explicit __all__ definitions to the metrics modules listed in issue #34.

Related Issue

Closes #34

Type of Change

Please check the type of change:

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 📝 Documentation update (changes to docs or examples)
  • 🧹 Maintenance (refactoring, code cleanup, dependencies)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected)

Changes Made

  • Added __all__ to trustlens/metrics/calibration.py.
  • Added __all__ to trustlens/metrics/failure.py.
  • Added __all__ to trustlens/metrics/bias.py.
  • Added __all__ to trustlens/metrics/representation.py.
  • Added tests to confirm the public metric exports.

Testing

  • Ran py -m pytest tests/test_metrics_all_exports.py
    • Result: 4 passed
  • Ran py -m pytest --ignore=tests/backends/test_xgboost_logic.py
    • Result: 256 passed, 1 skipped

Pre-submit Checklist

Before submitting, please ensure you have:

  • Run pre-commit run --all-files and all hooks passed.
  • Verified that all tests pass (make test).
  • Updated the CHANGELOG.md if applicable.
  • Verified that documentation has been updated for new features.

Notes for Reviewers

I followed the issue guidance by including only public user-facing metric functions and excluding private helpers such as _violation_level, _center_kernel, and _hsic.

Summary by CodeRabbit

  • Tests

    • Added test suite to validate public API exports for metrics submodules (calibration, failure, bias, representation)
  • Chores

    • Explicitly defined public API exports for calibration metrics (brier_score, expected_calibration_error, reliability_curve)
    • Explicitly defined public API exports for failure metrics (misclassification_summary, confidence_gap)
    • Explicitly defined public API exports for bias metrics (class_imbalance_report, subgroup_performance, equalized_odds)
    • Explicitly defined public API exports for representation metrics (embedding_separability, centered_kernel_alignment)

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@JavadTe, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 46 minutes and 4 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c1716b3-a852-4b2e-b252-6721476c7f14

📥 Commits

Reviewing files that changed from the base of the PR and between f72ad34 and b0ebdca.

📒 Files selected for processing (4)
  • tests/test_metrics_all_exports.py
  • trustlens/metrics/bias.py
  • trustlens/metrics/failure.py
  • trustlens/metrics/representation.py
📝 Walkthrough

Walkthrough

This PR adds explicit __all__ lists to four metrics submodules and introduces a test suite to validate the public API declarations. Each module now declares which metric functions are intended for public use, improving API clarity and preventing accidental exposure of internal helpers.

Changes

Metrics Module API Definitions

Layer / File(s) Summary
Add __all__ declarations to metrics modules
trustlens/metrics/calibration.py, trustlens/metrics/failure.py, trustlens/metrics/bias.py, trustlens/metrics/representation.py
Calibration exports brier_score, expected_calibration_error, reliability_curve. Failure exports misclassification_summary, confidence_gap. Bias exports class_imbalance_report, subgroup_performance, equalized_odds. Representation exports embedding_separability, centered_kernel_alignment.
Test validation of __all__ exports
tests/test_metrics_all_exports.py
Four test functions verify that each metrics submodule's __all__ set matches expected public metric names for calibration, failure, bias, and representation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Four modules now declare what's true,
Their public APIs shining through,
No hidden helpers lurking near,
Each metric function crystal clear!
Tests ensure the lists align—
Clarity in code, a design so fine! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding all exports to metrics modules, which matches the changeset.
Linked Issues check ✅ Passed The PR successfully fulfills issue #34 by adding all definitions to all four specified modules (calibration, failure, bias, representation) with only public user-facing functions, plus adding comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are within scope: all definitions added to four metrics modules and tests created to validate exports, all directly addressing issue #34 requirements.
Description check ✅ Passed The pull request description comprehensively follows the template with all major sections completed, including clear summary, linked issue, type of change, detailed changes made, testing results, and notes for reviewers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@llamapreview llamapreview 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.

AI Code Review by LlamaPReview

🎯 TL;DR & Recommendation

Recommendation: Approve with suggestions

This PR adds explicit __all__ exports to four metrics modules and a corresponding test file. The only concern is a linting CI failure that should be resolved before merging.

🌟 Strengths

  • Solid test coverage verifying public API exports.

💡 Suggestions (P2)

  • trustlens/metrics/calibration.py: The linting CI check failed; run the linter locally with pre-commit run --all-files and resolve reported violations to keep CI green.

💡 Have feedback? We'd love to hear it in our GitHub Discussions.
✨ This review was generated by LlamaPReview Advanced, which is free for all open-source projects. Learn more.

Comment thread trustlens/metrics/calibration.py

@Khanz9664 Khanz9664 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@JavadTe Thanks for picking this up — I reviewed the implementation and this looks great overall.

You kept the PR nicely scoped to the issue, added explicit __all__ definitions across the requested metrics modules, and followed the guidance around excluding private/internal helpers from the public API surface. I also appreciate you adding tests/test_metrics_all_exports.py to verify the exports — that wasn’t strictly required, but it’s a really nice addition for preventing regressions in the future.

I also checked that the PR stays focused on the requested modules (calibration.py, failure.py, bias.py, and representation.py) without unrelated cleanup/refactors, which I appreciate.

Since all checks are green and the implementation aligns with the issue scope, this looks good to me. Nice work on this one.

Thanks again for the contribution!

@Khanz9664
Khanz9664 merged commit 983bff8 into Khanz9664:main May 24, 2026
11 checks passed
@JavadTe
JavadTe deleted the add-metrics-all-exports branch May 24, 2026 21:21
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.

Add __all__ to remaining modules

2 participants