-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
v0.0.3
Return correct Type and Repr after first use
#21
Conversation
π Hello @glenn-jocher, thank you for submitting a
This is an automated response to help streamline the review process. An Ultralytics engineer will review your submission and provide additional feedback soon. For additional guidance, please refer to our Contributing Guide. Let us know if you have any questions or need assistance. Thank you for contributing to Ultralytics! ππ |
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Test script import time
from autoimport import lazy
with lazy():
t0 = time.perf_counter()
import torch # Import is deferred until first use
print(f"\nInitial import time: {time.perf_counter() - t0:.3f}s") # Example output: 0.000s
print(f"Initial type: {type(torch)}")
print(f"Initial print: {str(torch)}")
t1 = time.perf_counter()
torch.cuda.is_available() # Package is actually loaded here
print(f"\nFirst use time: {time.perf_counter() - t1:.3f}s") # Example output: 0.462s
print(f"First use type: {type(torch)}")
print(f"First use print: {str(torch)}") Currently returns this, module type is incorrect which may impact code bases that check using i.e.
|
Ok I think this is working now. After latest commit:
|
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
v0.0.3
Return correct Type and Repr after first use
π PR Merged! Huge thanks, @glenn-jocher, for this fantastic update to As Leonardo da Vinci once said, "Details make perfection, and perfection is not a detail." Your contributions embody this truthβthank you for your dedication. Here's to making tools smarter and the developer's journey smoother! π |
π οΈ PR Summary
Made with β€οΈ by Ultralytics Actions
π Summary
Update to the
autoimport
package improvingLazyLoader
functionality, with test enhancements and version bump. ππ Key Changes
LazyLoader
to copy critical module attributes (__file__
,__path__
, etc.) for better compatibility.LazyLoader.__repr__()
for improved clarity when modules aren't loaded.LazyLoader
correctly integrates with standard imports.pytest
(recommended) andunittest
testing options.0.0.2
to0.0.3
.π― Purpose & Impact
LazyLoader
works seamlessly with external tools and libraries that rely on module attributes.LazyLoader
instances simplify debugging.This update enhances reliability and usability for developers leveraging the
autoimport
package. π