Fix new playbook modules not discovered during hot reload#2042
Fix new playbook modules not discovered during hot reload#2042harinik05 wants to merge 2 commits intorobusta-dev:masterfrom
Conversation
When new .py files are added to a playbook repo and a config reload is triggered, pkgutil.walk_packages() fails to discover them because Python's FileFinder caches directory listings from the initial import. Existing file changes are picked up by importlib.reload(), but new modules remain invisible until the process restarts. Add importlib.invalidate_caches() before the package walk so that newly installed modules are visible to the finder machinery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughA single call to Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
importlib.invalidate_caches()inConfigLoader.__import_playbooks_package()beforepkgutil.walk_packages()so that newly added.pyfiles in playbook repos are discoverable during hot reloadFixes #2041
Problem
When new
.pyfiles are added to a git-based custom playbook repo and a config reload is triggered,pkgutil.walk_packages()does not discover them because Python'sFileFindercaches directory listings from the initial import. Changes to existing files work fine viaimportlib.reload(), but new modules remain invisible until a full pod restart.Fix
A single call to
importlib.invalidate_caches()before the package walk clears the staleFileFinderdirectory cache, allowing newly installed modules to be found.Test plan
.pyaction file to the repo and push