Fix module loading path collision#558
Conversation
|
Welcome @avinxshKD! It looks like this is your first PR to kubeedge/ianvs 🎉 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: avinxshKD The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request updates the load_module function in core/common/utils.py to dynamically load Python modules from file paths using unique module IDs generated via MD5 hashing. The review feedback highlights two important issues: first, importlib.util must be explicitly imported to prevent a runtime AttributeError; second, the code should verify that the module spec is not None before passing it to module_from_spec to avoid a potential ValueError.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
2c3d74f to
eea8617
Compare
Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
eea8617 to
b99161f
Compare
|
@MooreZheng @hsj576 kept this intentionally small since the bug is isolated to |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fixes
load_module()so two Python files with the same basename do not collide insys.modules.Ianvs examples often use common names like
basemodel.py,accuracy.py, andmap.py. The old loader imported by basename after adding the directory tosys.path, so a later file could reuse an earlier module with the same name.This keeps the existing loader behavior for callers, but loads file paths under a unique internal module name.
Which issue(s) this PR fixes:
Fixes #557