fix(starlark): reload tronbyte_repository module to pick up code changes

The web service caches imported modules in sys.modules. When deploying
code updates, the old cached version was still being used.

Now uses importlib.reload() when module is already loaded.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Chuck
2026-02-19 09:29:19 -05:00
parent c584f227c1
commit a821060084

View File

@@ -6982,11 +6982,17 @@ def clear_old_errors():
def _get_tronbyte_repository_class():
"""Import TronbyteRepository from plugin-repos directory."""
import importlib.util
import importlib
module_path = PROJECT_ROOT / 'plugin-repos' / 'starlark-apps' / 'tronbyte_repository.py'
if not module_path.exists():
raise ImportError(f"TronbyteRepository module not found at {module_path}")
# If already imported, reload to pick up code changes
if "tronbyte_repository" in sys.modules:
importlib.reload(sys.modules["tronbyte_repository"])
return sys.modules["tronbyte_repository"].TronbyteRepository
spec = importlib.util.spec_from_file_location("tronbyte_repository", module_path)
module = importlib.util.module_from_spec(spec)
sys.modules["tronbyte_repository"] = module