Skip to content

Unpack star imports#98

Merged
glenn-jocher merged 7 commits into
mainfrom
star-imports
Sep 3, 2025
Merged

Unpack star imports#98
glenn-jocher merged 7 commits into
mainfrom
star-imports

Conversation

@glenn-jocher
Copy link
Copy Markdown
Member

@glenn-jocher glenn-jocher commented Sep 3, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Small but solid cleanup and polish release for thop 2.0.17: fixes a duplicate test, clarifies exports, replaces wildcard imports with explicit ones, and tidies fx profiling imports and docs. 🚀

📊 Key Changes

  • Version bump: 2.0.162.0.17.
  • Tests: renamed duplicated test_matmul_case2 to test_matmul_case3 to avoid collisions.
  • Public API clarified:
    • Added __all__ = ["profile", "profile_origin", "clever_format", "default_dtype"] in thop/__init__.py.
    • Kept default_dtype = torch.float64 as the module default.
  • Import hygiene and readability:
    • Replaced wildcard imports with explicit imports in profile.py and vision/basic_hooks.py.
    • Centralized and deduplicated imports in fx_profile.py (e.g., symbolic_trace, ShapeProp, calculate_conv, prRed, prYellow).
  • Minor documentation improvements:
    • Added concise docstrings for example classes in fx_profile.py.

🎯 Purpose & Impact

  • More stable and maintainable codebase:
    • Explicit imports reduce namespace pollution, prevent accidental overrides, and improve static analysis (linting/type-checking). 🧹
  • Clearer public surface:
    • __all__ ensures from thop import * exposes only intended functions, reducing surprises for users. 📦
  • Better test reliability:
    • Fixes a duplicate test method name that could mask failures. ✅
  • No behavior changes expected for normal users:
    • Core APIs (profile, profile_origin, clever_format) remain the same; performance unaffected. ⚙️

For more details, see the Ultralytics thop repository.

@UltralyticsAssistant UltralyticsAssistant added the enhancement New feature or request label Sep 3, 2025
@UltralyticsAssistant
Copy link
Copy Markdown
Member

👋 Hello @glenn-jocher, thank you for submitting an ultralytics/thop 🚀 PR! This is an automated response to help streamline the review process. An Ultralytics engineer will also review and assist you here shortly. Please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions. For this PR, please explicitly note the import-path changes as a potential breaking change and reference any impacted usages.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/thop main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues. Given the import refactors, ensure tests cover direct imports from thop.profile and thop.utils.
  • Update Documentation: Update the relevant documentation for any new or modified features. Since top-level re-exports were removed, please ensure docs or examples reflect the new explicit import paths.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing. Consider adding a simple test to validate the updated import paths and prevent regressions.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don’t hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀✨

@glenn-jocher glenn-jocher merged commit 0d37c69 into main Sep 3, 2025
5 checks passed
@glenn-jocher glenn-jocher deleted the star-imports branch September 3, 2025 14:04
@UltralyticsAssistant
Copy link
Copy Markdown
Member

🎉 Merged and marvelous — thank you, @glenn-jocher!

“Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away.” — Antoine de Saint-Exupéry. Your polish in thop 2.0.17 embodies this: clearer exports, cleaner imports, a fixed duplicate test, and tighter docs — all without changing user-facing behavior.

Highlights:

  • Clarified public API with __all__
  • Import hygiene across key modules
  • Reliable tests and concise docstrings
  • Version bump to 2.0.17

This is the kind of craftsmanship that keeps the ecosystem robust and a joy to use. 🙌

See the merged work here: PR #98 on ultralytics/thop

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants