[PR #340] [MERGED] Add sibling-import fallback for Forge Neo / namespace-package edge cases #307

Closed
opened 2026-10-30 21:22:12 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/pull/340
Author: @RedNodeAI
Created: 5/17/2026
Status: ✅ Merged
Merged: 5/17/2026
Merged by: @DominikDoom

Base: main ← Head: main


📝 Commits (3)

  • dcad9fc Add sibling-import fallback for Forge Neo
  • e49631f Add sibling-import fallback for Forge Neo
  • 20472d5 Add sibling-import fallback for Forge Neo

📊 Changes

3 files changed (+24 additions, -7 deletions)

View changed files

📝 scripts/model_keyword_support.py (+6 -2)
📝 scripts/tag_autocomplete_helper.py (+11 -4)
📝 scripts/tag_frequency_db.py (+7 -1)

📄 Description

Problem

On some Forge Neo and Forge Classic installs, the extension silently fails to load with:

*** Error loading script: model_keyword_support.py
ModuleNotFoundError: No module named 'scripts.shared_paths'
*** Error loading script: tag_autocomplete_helper.py
ModuleNotFoundError: No module named 'scripts.model_keyword_support'
*** Error loading script: tag_frequency_db.py
ModuleNotFoundError: No module named 'scripts.shared_paths'

Result: the extension's on_ui_settings callback never registers, so no tac_* keys reach the JS opts object, so JSON.parse(opts["tac_keymap"]) throws on undefined, and the tag popup never wires up. From the user's point of view: "the extension does nothing."

Cause

Python's namespace-package resolution for scripts doesn't always pick up the extension's scripts/ folder when the webui has its own scripts/ folder — the webui's folder is found first, doesn't contain shared_paths, and ModuleNotFoundError is raised instead of also checking the extension's folder.

Fix

Mirrors the existing fallback pattern already used in tag_autocomplete_helper.py for tag_frequency_db: try the package-style import first, and if it fails, add the script's own directory to sys.path and re-import bare. No behavior change on webuis where the package import works.

Applied to:

  • scripts/model_keyword_support.py
  • scripts/tag_frequency_db.py
  • scripts/tag_autocomplete_helper.py

Tested on Forge Neo and Forge Classic.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/pull/340 **Author:** [@RedNodeAI](https://github.com/RedNodeAI) **Created:** 5/17/2026 **Status:** ✅ Merged **Merged:** 5/17/2026 **Merged by:** [@DominikDoom](https://github.com/DominikDoom) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (3) - [`dcad9fc`](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/commit/dcad9fc187671c77d23fb14196c523eb25e6a11d) Add sibling-import fallback for Forge Neo - [`e49631f`](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/commit/e49631fa31c195ba1cb7119aecee7c3383eb7dbc) Add sibling-import fallback for Forge Neo - [`20472d5`](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/commit/20472d565b50f2d2b8b629463e28fa6715dacd09) Add sibling-import fallback for Forge Neo ### 📊 Changes **3 files changed** (+24 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `scripts/model_keyword_support.py` (+6 -2) 📝 `scripts/tag_autocomplete_helper.py` (+11 -4) 📝 `scripts/tag_frequency_db.py` (+7 -1) </details> ### 📄 Description ## Problem On some Forge Neo and Forge Classic installs, the extension silently fails to load with: *** Error loading script: model_keyword_support.py ModuleNotFoundError: No module named 'scripts.shared_paths' *** Error loading script: tag_autocomplete_helper.py ModuleNotFoundError: No module named 'scripts.model_keyword_support' *** Error loading script: tag_frequency_db.py ModuleNotFoundError: No module named 'scripts.shared_paths' Result: the extension's `on_ui_settings` callback never registers, so no `tac_*` keys reach the JS `opts` object, so `JSON.parse(opts["tac_keymap"])` throws on `undefined`, and the tag popup never wires up. From the user's point of view: "the extension does nothing." ## Cause Python's namespace-package resolution for `scripts` doesn't always pick up the extension's `scripts/` folder when the webui has its own `scripts/` folder — the webui's folder is found first, doesn't contain `shared_paths`, and `ModuleNotFoundError` is raised instead of also checking the extension's folder. ## Fix Mirrors the existing fallback pattern already used in `tag_autocomplete_helper.py` for `tag_frequency_db`: try the package-style import first, and if it fails, add the script's own directory to `sys.path` and re-import bare. No behavior change on webuis where the package import works. Applied to: - `scripts/model_keyword_support.py` - `scripts/tag_frequency_db.py` - `scripts/tag_autocomplete_helper.py` Tested on Forge Neo and Forge Classic. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-30 21:22:12 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#307
No description provided.