From 954de12d0813549754f601ece210b1f305bb9e7a Mon Sep 17 00:00:00 2001 From: bennykok Date: Fri, 26 Jan 2024 20:16:10 +0800 Subject: [PATCH] feat(builder): add ipadapter support - exposing pip install --- builder/modal-builder/src/main.py | 9 ++++++++- builder/modal-builder/src/template/app.py | 2 ++ builder/modal-builder/src/template/config.py | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/builder/modal-builder/src/main.py b/builder/modal-builder/src/main.py index 2776836..f486b56 100644 --- a/builder/modal-builder/src/main.py +++ b/builder/modal-builder/src/main.py @@ -142,6 +142,7 @@ def read_root(): class GitCustomNodes(BaseModel): hash: str disabled: bool + pip: Optional[List[str]] = None class FileCustomNodes(BaseModel): filename: str @@ -377,13 +378,19 @@ async def build_logic(item: Item): cp_process = await asyncio.subprocess.create_subprocess_exec("cp", "-r", "/app/src/template", folder_path) await cp_process.wait() + pip_modules = set() + for git_custom_node in item.snapshot.git_custom_nodes.values(): + if git_custom_node.pip: + pip_modules.update(git_custom_node.pip) + # Write the config file config = { "name": item.name, "deploy_test": os.environ.get("DEPLOY_TEST_FLAG", "False"), "gpu": item.gpu, "public_model_volume": "model-store", - "private_model_volume": item.model_volume_name + "private_model_volume": item.model_volume_name, + "pip": list(pip_modules) } with open(f"{folder_path}/config.py", "w") as f: f.write("config = " + json.dumps(config)) diff --git a/builder/modal-builder/src/template/app.py b/builder/modal-builder/src/template/app.py index 91d5601..64111d5 100644 --- a/builder/modal-builder/src/template/app.py +++ b/builder/modal-builder/src/template/app.py @@ -65,6 +65,8 @@ if not deploy_test: .run_commands("chmod +x /start.sh") # Restore the custom nodes first + .pip_install(config["pip"]) + .copy_local_file(f"{current_directory}/data/restore_snapshot.py", "/") .copy_local_file(f"{current_directory}/data/snapshot.json", "/comfyui/custom_nodes/ComfyUI-Manager/startup-scripts/restore-snapshot.json") .run_commands("python restore_snapshot.py") diff --git a/builder/modal-builder/src/template/config.py b/builder/modal-builder/src/template/config.py index 492426c..2ecf253 100644 --- a/builder/modal-builder/src/template/config.py +++ b/builder/modal-builder/src/template/config.py @@ -3,5 +3,6 @@ config = { "deploy_test": "True", "gpu": "T4", "public_model_volume": "model-store", - "private_model_volume": "private-model-store" + "private_model_volume": "private-model-store", + "pip": [] }