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
fix: clarify py_modules usage in 1546 #1597
Conversation
This PR closes: #1546 |
Should the title refer to 1546 and not 1549? What is the learnings from here? Which patterns can be imported and which can't? |
in test docstring |
Latency summaryCurrent PR yields:
Breakdown
Backed by latency-tracking. Further commits will update this comment. |
@@ -277,7 +277,12 @@ def _path_import(absolute_path: str) -> Optional[ModuleType]: | |||
spec = importlib.util.spec_from_file_location('jinahub', absolute_path) | |||
module = importlib.util.module_from_spec(spec) | |||
user_module_name = os.path.splitext(os.path.basename(absolute_path))[0] | |||
sys.modules[f'{spec.name}.{user_module_name}'] = module | |||
if user_module_name == '__init__': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this may put some problems in many hub executors right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, irrelevant, magic is in spec.loader.exec_module(module)
Codecov Report
@@ Coverage Diff @@
## master #1597 +/- ##
==========================================
+ Coverage 83.86% 84.84% +0.97%
==========================================
Files 128 128
Lines 6664 6725 +61
==========================================
+ Hits 5589 5706 +117
+ Misses 1075 1019 -56
Continue to review full report at Codecov.
|
https://github.com/jina-ai/jina-hub/blob/master/README.md#use-py_modules-to-import-multiple-files