From bed621688541d678ed67ab31a3258c725465d005 Mon Sep 17 00:00:00 2001 From: JohnWL <34081873+John-WL@users.noreply.github.com> Date: Sun, 5 Nov 2023 07:58:14 -0500 Subject: [PATCH 1/3] allow to install manager on install page --- install_comfyui_manager.py | 20 ++++++++++++++++++++ lib_comfyui/webui/tab.py | 16 ++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 install_comfyui_manager.py diff --git a/install_comfyui_manager.py b/install_comfyui_manager.py new file mode 100644 index 0000000..bc1f89b --- /dev/null +++ b/install_comfyui_manager.py @@ -0,0 +1,20 @@ +import os +import sys + + +default_install_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ComfyUI', 'custom_nodes', 'ComfyUI-Manager') + + +def main(install_location): + import git + git_repo_url = 'https://github.com/ltdrdata/ComfyUI-Manager.git' + os.mkdir(install_location) + git.Repo.clone_from(git_repo_url, install_location) + + +if __name__ == '__main__': + install_location = default_install_location + if len(sys.argv) > 1: + inistall_location = sys.argv[1] + + main(install_location) diff --git a/lib_comfyui/webui/tab.py b/lib_comfyui/webui/tab.py index 7e7d9ac..3908af0 100644 --- a/lib_comfyui/webui/tab.py +++ b/lib_comfyui/webui/tab.py @@ -3,6 +3,7 @@ import textwrap import gradio as gr import install_comfyui +import install_comfyui_manager from lib_comfyui import external_code, ipc from lib_comfyui.webui import settings, gradio_utils from lib_comfyui.default_workflow_types import sandbox_tab_workflow_type @@ -24,6 +25,9 @@ def create_tab(): gr.Markdown(comfyui_install_instructions_markdown) with gr.Column(): + with gr.Row(): + install_manager = gr.Checkbox(label='Install with ComfyUI-Manager', value=True) + with gr.Row(): install_path = gr.Textbox(placeholder=f'Leave empty to install at {install_comfyui.default_install_location}', label='Installation path') @@ -33,7 +37,7 @@ def create_tab(): with gr.Row(): installed_feedback = gr.Markdown() - install_button.click(automatic_install_comfyui, inputs=[install_path], outputs=[installed_feedback], show_progress=True) + install_button.click(automatic_install_comfyui, inputs=[install_manager, install_path], outputs=[installed_feedback], show_progress=True) gradio_utils.ExtensionDynamicProperty( key='workflow_type_ids', @@ -44,7 +48,7 @@ def create_tab(): @ipc.restrict_to_process('webui') -def automatic_install_comfyui(install_location): +def automatic_install_comfyui(should_install_manager, install_location): from modules import shared install_location = install_location.strip() if not install_location: @@ -58,6 +62,10 @@ def automatic_install_comfyui(install_location): install_comfyui.main(install_location) shared.opts.comfyui_install_location = install_location + if should_install_manager: + manager_install_location = os.path.join(install_location, 'custom_nodes', 'ComfyUI-Manager') + install_comfyui_manager.main(manager_install_location) + return gr.Markdown.update('Installed! Now please reload the UI.') @@ -68,10 +76,10 @@ def can_install_at(path): comfyui_install_instructions_markdown = ''' ## ComfyUI extension -It looks like your ComfyUI installation isn't set up yet! +It looks like your ComfyUI installation isn't set up yet. If you already have ComfyUI installed on your computer, go to `Settings > ComfyUI`, and set the proper install location. -Alternatively, if you don't have ComfyUI installed, you can install it with this button: +Alternatively, if you don't have ComfyUI installed, you can install it here: ''' From 59b42ade4d7a9b61f55c753595e237b2f47b5c9a Mon Sep 17 00:00:00 2001 From: JohnWL <34081873+John-WL@users.noreply.github.com> Date: Sun, 5 Nov 2023 08:53:04 -0500 Subject: [PATCH 2/3] put install script in install_comfyui --- install_comfyui.py | 17 ++++++++++++++++- install_comfyui_manager.py | 20 -------------------- lib_comfyui/webui/tab.py | 7 +------ 3 files changed, 17 insertions(+), 27 deletions(-) delete mode 100644 install_comfyui_manager.py diff --git a/install_comfyui.py b/install_comfyui.py index b943042..5a4802d 100644 --- a/install_comfyui.py +++ b/install_comfyui.py @@ -5,12 +5,27 @@ default_install_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ComfyUI') -def main(install_location): +def main(install_location, should_install_manager=False): import git git_repo_url = 'https://github.com/comfyanonymous/ComfyUI.git' os.mkdir(install_location) git.Repo.clone_from(git_repo_url, install_location) + if should_install_manager: + manager_location = manager_location_from_comfyui_location(install_location) + install_manager(manager_location) + + +def install_manager(manager_location): + import git + git_repo_url = 'https://github.com/ltdrdata/ComfyUI-Manager.git' + os.mkdir(manager_location) + git.Repo.clone_from(git_repo_url, manager_location) + + +def manager_location_from_comfyui_location(comfyui_location): + return os.path.join(comfyui_location, 'custom_nodes', 'ComfyUI-Manager') + def update(install_location): print("[sd-webui-comfyui]", f"Updating comfyui at {install_location}...") diff --git a/install_comfyui_manager.py b/install_comfyui_manager.py deleted file mode 100644 index bc1f89b..0000000 --- a/install_comfyui_manager.py +++ /dev/null @@ -1,20 +0,0 @@ -import os -import sys - - -default_install_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ComfyUI', 'custom_nodes', 'ComfyUI-Manager') - - -def main(install_location): - import git - git_repo_url = 'https://github.com/ltdrdata/ComfyUI-Manager.git' - os.mkdir(install_location) - git.Repo.clone_from(git_repo_url, install_location) - - -if __name__ == '__main__': - install_location = default_install_location - if len(sys.argv) > 1: - inistall_location = sys.argv[1] - - main(install_location) diff --git a/lib_comfyui/webui/tab.py b/lib_comfyui/webui/tab.py index 3908af0..345b623 100644 --- a/lib_comfyui/webui/tab.py +++ b/lib_comfyui/webui/tab.py @@ -3,7 +3,6 @@ import textwrap import gradio as gr import install_comfyui -import install_comfyui_manager from lib_comfyui import external_code, ipc from lib_comfyui.webui import settings, gradio_utils from lib_comfyui.default_workflow_types import sandbox_tab_workflow_type @@ -59,13 +58,9 @@ def automatic_install_comfyui(should_install_manager, install_location): print(message, file=sys.stderr) return gr.Markdown.update(message) - install_comfyui.main(install_location) + install_comfyui.main(install_location, should_install_manager) shared.opts.comfyui_install_location = install_location - if should_install_manager: - manager_install_location = os.path.join(install_location, 'custom_nodes', 'ComfyUI-Manager') - install_comfyui_manager.main(manager_install_location) - return gr.Markdown.update('Installed! Now please reload the UI.') From 7980125cb3f9a44d73e5a7066bf29d195106cf5a Mon Sep 17 00:00:00 2001 From: JohnWL <34081873+John-WL@users.noreply.github.com> Date: Sun, 5 Nov 2023 09:02:16 -0500 Subject: [PATCH 3/3] refact --- install_comfyui.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/install_comfyui.py b/install_comfyui.py index 5a4802d..47671c4 100644 --- a/install_comfyui.py +++ b/install_comfyui.py @@ -6,27 +6,25 @@ def main(install_location, should_install_manager=False): - import git - git_repo_url = 'https://github.com/comfyanonymous/ComfyUI.git' - os.mkdir(install_location) - git.Repo.clone_from(git_repo_url, install_location) + repo_url = 'https://github.com/comfyanonymous/ComfyUI.git' + install_repo(repo_url, install_location) if should_install_manager: + manager_repo_url = 'https://github.com/ltdrdata/ComfyUI-Manager.git' manager_location = manager_location_from_comfyui_location(install_location) - install_manager(manager_location) - - -def install_manager(manager_location): - import git - git_repo_url = 'https://github.com/ltdrdata/ComfyUI-Manager.git' - os.mkdir(manager_location) - git.Repo.clone_from(git_repo_url, manager_location) + install_repo(manager_repo_url, manager_location) def manager_location_from_comfyui_location(comfyui_location): return os.path.join(comfyui_location, 'custom_nodes', 'ComfyUI-Manager') +def install_repo(git_repo_url, install_location): + import git + os.mkdir(install_location) + git.Repo.clone_from(git_repo_url, install_location) + + def update(install_location): print("[sd-webui-comfyui]", f"Updating comfyui at {install_location}...") if not install_location.is_dir() or not any(install_location.iterdir()):