fix: use _load_module_temp for bootstrap modules to avoid sys.modules conflicts
bootstrap_comfyui_runtime() now uses _load_module_temp() with temporary module names (_bootstrap_options, _bootstrap_cli_args, _bootstrap_cuda_malloc) instead of real module names. This prevents cached stale modules from sys.modules conflicting with ComfyUI's internal import chain (e.g. nodes.py -> comfy.sd -> comfy.model_management -> comfy.cli_args). Fixes the text-to-image runtime e2e failure: ImportError: cannot import name 'args' from 'comfy.cli_args'
This commit is contained in:
@@ -146,10 +146,12 @@ class UpscaleModelLoaderExportTest(unittest.TestCase):
|
||||
|
||||
self.assertIn("def bootstrap_comfyui_runtime()", generated)
|
||||
self.assertIn("def cleanup_comfyui_runtime(", generated)
|
||||
# Hardened imports use _load_module(), not bare 'import comfy.options'
|
||||
self.assertIn('"comfy.options"', generated)
|
||||
# Hardened imports use _load_module_temp() with temporary names,
|
||||
# not bare 'import comfy.options' — avoids sys.modules pollution
|
||||
self.assertIn("_load_module_temp", generated)
|
||||
self.assertIn("options.py", generated)
|
||||
self.assertIn("enable_args_parsing()", generated)
|
||||
self.assertIn('"cuda_malloc"', generated)
|
||||
self.assertIn("cuda_malloc.py", generated)
|
||||
self.assertNotIn("\nbootstrap_comfyui_runtime()\n", generated)
|
||||
self.assertIn(
|
||||
"def main(unload_models: bool | None = None):\n"
|
||||
|
||||
Reference in New Issue
Block a user