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

ultralytics 8.1.2 scope HUB-SDK imports #7596

Merged
merged 10 commits into from Jan 15, 2024
Merged

ultralytics 8.1.2 scope HUB-SDK imports #7596

merged 10 commits into from Jan 15, 2024

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jan 15, 2024

Scopes HUB-SDK imports to allow for Conda publishing.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Updated dependencies and internal references related to Ultralytics HUB.

πŸ“Š Key Changes

  • Removed hub-sdk from main dependencies, now listed as an optional "extra".
  • Changed version from 8.1.1 to 8.1.2.
  • Modified import statements to use updated references to HUB_API_ROOT and HUB_WEB_ROOT.
  • Added a requirements check for hub-sdk before using HUBClient to ensure the required package is installed.
  • Created environment variables for HUB_API_ROOT and HUB_WEB_ROOT to make the API endpoints easily configurable.
  • Streamlined method for checking if a model identifier corresponds to a valid HUB model.
  • Removed redundant comments and spaces for clarity and style.

🎯 Purpose & Impact

  • πŸ› οΈ Cleaner Dependency Management: By moving hub-sdk to optional dependencies, users who do not need HUB functionality won't have to install it, reducing unnecessary overhead.
  • πŸ”„ Better Version Tracking: Incrementing version numbers aids users and developers in tracking changes and updates.
  • πŸ”— Flexible API Configuration: With environment variables controlling API endpoints, the system becomes more flexible for deployment in various environments, possibly facilitating testing or enterprise integration.
  • πŸ“¦ Module Import Integrity: Ensuring the requirement of hub-sdk before using HUBClient prevents runtime errors due to missing dependencies.
  • βš™οΈ Smarter Model Identification: Streamlining the model checking logic could result in more efficient operations when interacting with the Ultralytics HUB.
  • ✨ Improved Code Readability: Cleanup in code comments and structure enhances readability, making maintenance and further development more straightforward.

πŸ“ Note: Non-expert users might not directly interact with these changes, but they contribute to a more stable and versatile software ecosystem.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher
Copy link
Member Author

glenn-jocher commented Jan 15, 2024

@kalenmike @hassaanfarooq01 I'm scoping HUB-SDK imports here to resolve the Conda build issues. I noticed most of the usage is importing HUB_WEB_ROOT and HUB_API_ROOT:

Screenshot 2024-01-15 at 17 25 57

Could we define these locally identically to allow for local imports instead of importing them from hub_sdk?

https://github.com/ultralytics/hub-sdk/blob/33129b9287685ae2b31d2d7d1d8933b74b61427f/hub_sdk/config.py#L3-L4

HUB_API_ROOT = os.environ.get("ULTRALYTICS_HUB_API", "https://api.ultralytics.com")
HUB_WEB_ROOT = os.environ.get("ULTRALYTICS_HUB_WEB", "https://hub.ultralytics.com")

This would make this part simpler, otherwise I don't see a solution to running this check on model load:

def is_hub_model(model):
"""Check if the provided model is a HUB model."""
return any(
(
model.startswith(f"{HUB_WEB_ROOT}/models/"), # i.e. https://hub.ultralytics.com/models/MODEL_ID
[len(x) for x in model.split("_")] == [42, 20], # APIKEY_MODELID
len(model) == 20 and not Path(model).exists() and all(x not in model for x in "./\\"),
)
) # MODELID

Copy link

codecov bot commented Jan 15, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (b128254) 76.10% compared to head (c2cc4f2) 76.08%.

Files Patch % Lines
ultralytics/hub/__init__.py 50.00% 2 Missing ⚠️
ultralytics/hub/session.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7596      +/-   ##
==========================================
- Coverage   76.10%   76.08%   -0.02%     
==========================================
  Files         117      117              
  Lines       14332    14336       +4     
==========================================
+ Hits        10907    10908       +1     
- Misses       3425     3428       +3     
Flag Coverage Ξ”
Benchmarks 35.73% <53.33%> (-0.01%) ⬇️
GPU 39.76% <73.33%> (+0.17%) ⬆️
Tests 71.18% <73.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

@UltralyticsAssistant UltralyticsAssistant added the HUB Ultralytics HUB issues label Jan 15, 2024
@glenn-jocher glenn-jocher changed the title Scope HUB-SDK imports ultralytics 8.1.2 scope HUB-SDK imports Jan 15, 2024
@glenn-jocher glenn-jocher merged commit 5f5f5d0 into main Jan 15, 2024
10 checks passed
@glenn-jocher glenn-jocher deleted the scope_hub_sdk branch January 15, 2024 22:48
scosijnilvo pushed a commit to scosijnilvo/yolov8 that referenced this pull request Jan 19, 2024
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
hmurari pushed a commit to hmurari/ultralytics that referenced this pull request Apr 17, 2024
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HUB Ultralytics HUB issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants