Skip to content

Fix module loading path collision#558

Open
avinxshKD wants to merge 1 commit into
kubeedge:mainfrom
avinxshKD:fix/load-module-path-collision
Open

Fix module loading path collision#558
avinxshKD wants to merge 1 commit into
kubeedge:mainfrom
avinxshKD:fix/load-module-path-collision

Conversation

@avinxshKD

Copy link
Copy Markdown

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 in sys.modules.

Ianvs examples often use common names like basemodel.py, accuracy.py, and map.py. The old loader imported by basename after adding the directory to sys.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

@kubeedge-bot kubeedge-bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 18, 2026
@kubeedge-bot kubeedge-bot requested review from Poorunga and hsj576 June 18, 2026 11:08
@kubeedge-bot

Copy link
Copy Markdown
Collaborator

Welcome @avinxshKD! It looks like this is your first PR to kubeedge/ianvs 🎉

@kubeedge-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: avinxshKD
To complete the pull request process, please assign jaypume after the PR has been reviewed.
You can assign the PR to them by writing /assign @jaypume in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 18, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread core/common/utils.py Outdated
Comment thread core/common/utils.py Outdated
@avinxshKD avinxshKD force-pushed the fix/load-module-path-collision branch 2 times, most recently from 2c3d74f to eea8617 Compare June 18, 2026 11:13
Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
@avinxshKD avinxshKD force-pushed the fix/load-module-path-collision branch from eea8617 to b99161f Compare June 18, 2026 11:15
@avinxshKD

Copy link
Copy Markdown
Author

@MooreZheng @hsj576 kept this intentionally small since the bug is isolated to load_module().
Pls take a look, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core: load_module can reuse the wrong file when module names collide

2 participants