Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope gitpyhon import in check_git_info() #10221

Merged
merged 3 commits into from
Nov 19, 2022
Merged

Scope gitpyhon import in check_git_info() #10221

merged 3 commits into from
Nov 19, 2022

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Nov 19, 2022

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Refactor of git information retrieval in Ultralytics' codebase.

πŸ“Š Key Changes

  • GIT global variable in utils/general.py is replaced with a function call to check_git_info(), which dynamically checks git information.
  • GIT references within train.py, classify/train.py, and segment/train.py are updated to use GIT_INFO obtained from the new check_git_info() function call.
  • The import statement of the git library is now included within the new check_git_info() function.
  • Import statements for shutil and git modules are cleaned up from where they are no longer needed.
  • The check_git_info() function includes a requirement check for the gitpython package before importing the git library.

🎯 Purpose & Impact

  • Increased Maintainability: Wrapping the git information retrieval in a function reduces code duplication and centralizes the update process for git-related code.
  • Better Error Handling: By checking for the gitpython requirement within the function, the code reduces potential import errors that could occur when the required package is missing.
  • Enhanced Code Clarity: Removing global variables and unused imports declutters the codebase and makes the flow of data more comprehendible.

Overall, users can expect a more robust handling of git-related features with reduced chances of encountering import-related errors. Developers will benefit from a cleaner codebase that is easier to maintain and extend in the future. πŸ› οΈπŸ“ˆ

@glenn-jocher glenn-jocher self-assigned this Nov 19, 2022
@glenn-jocher glenn-jocher merged commit 40bb803 into master Nov 19, 2022
@glenn-jocher glenn-jocher deleted the scope_git_info branch November 19, 2022 13:22
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.

None yet

1 participant