Skip to content

Fix external plugin module name collisions - #9953

Merged
tastelikefeet merged 1 commit into
modelscope:mainfrom
primorLee:codex/fix-external-plugin-name-collision
Aug 24, 2026
Merged

Fix external plugin module name collisions#9953
tastelikefeet merged 1 commit into
modelscope:mainfrom
primorLee:codex/fix-external-plugin-name-collision

Conversation

@primorLee

Copy link
Copy Markdown
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

External plugins are currently imported by their filename stem. When two configured plugins have the same filename in different directories, Python reuses the first entry from sys.modules, so the second plugin is never executed.

Load external plugins under a stable module key derived from their absolute path. This keeps same-path imports cached while isolating same-name files from different directories, and removes a partially initialized module if execution fails.

The regression test creates two plugin.py files in separate directories and verifies that both modules execute with their own values.

Experiment results

  • python -m unittest tests.utils.test_file_utils.TestFileUtils.test_import_external_files_with_same_name (passed)
  • python -m unittest tests.utils.test_file_utils (2 tests passed)
  • pre-commit run --files swift/utils/utils.py tests/utils/test_file_utils.py (passed)
  • git diff --check (passed)

@tastelikefeet
tastelikefeet merged commit a835d57 into modelscope:main Aug 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants