From 39d9fc8c5d9fce66d9ee446d44884a8f1beccca5 Mon Sep 17 00:00:00 2001 From: doctorpangloss <@hiddenswitch.com> Date: Mon, 17 Jun 2024 15:12:17 -0700 Subject: [PATCH] Deprecate main.py --- .ci/update_windows/update.py | 110 ------------------ .ci/update_windows/update_comfyui.bat | 8 -- .../README_VERY_IMPORTANT.txt | 31 ----- .ci/windows_base_files/run_cpu.bat | 2 - .ci/windows_base_files/run_nvidia_gpu.bat | 2 - main.py | 2 + 6 files changed, 2 insertions(+), 153 deletions(-) delete mode 100755 .ci/update_windows/update.py delete mode 100755 .ci/update_windows/update_comfyui.bat delete mode 100755 .ci/windows_base_files/README_VERY_IMPORTANT.txt delete mode 100755 .ci/windows_base_files/run_cpu.bat delete mode 100755 .ci/windows_base_files/run_nvidia_gpu.bat diff --git a/.ci/update_windows/update.py b/.ci/update_windows/update.py deleted file mode 100755 index 127247b2f..000000000 --- a/.ci/update_windows/update.py +++ /dev/null @@ -1,110 +0,0 @@ -import pygit2 -from datetime import datetime -import sys -import os -import shutil -import filecmp - -def pull(repo, remote_name='origin', branch='master'): - for remote in repo.remotes: - if remote.name == remote_name: - remote.fetch() - remote_master_id = repo.lookup_reference('refs/remotes/origin/%s' % (branch)).target - merge_result, _ = repo.merge_analysis(remote_master_id) - # Up to date, do nothing - if merge_result & pygit2.GIT_MERGE_ANALYSIS_UP_TO_DATE: - return - # We can just fastforward - elif merge_result & pygit2.GIT_MERGE_ANALYSIS_FASTFORWARD: - repo.checkout_tree(repo.get(remote_master_id)) - try: - master_ref = repo.lookup_reference('refs/heads/%s' % (branch)) - master_ref.set_target(remote_master_id) - except KeyError: - repo.create_branch(branch, repo.get(remote_master_id)) - repo.head.set_target(remote_master_id) - elif merge_result & pygit2.GIT_MERGE_ANALYSIS_NORMAL: - repo.merge(remote_master_id) - - if repo.index.conflicts is not None: - for conflict in repo.index.conflicts: - print('Conflicts found in:', conflict[0].path) - raise AssertionError('Conflicts, ahhhhh!!') - - user = repo.default_signature - tree = repo.index.write_tree() - commit = repo.create_commit('HEAD', - user, - user, - 'Merge!', - tree, - [repo.head.target, remote_master_id]) - # We need to do this or git CLI will think we are still merging. - repo.state_cleanup() - else: - raise AssertionError('Unknown merge analysis result') - -pygit2.option(pygit2.GIT_OPT_SET_OWNER_VALIDATION, 0) -repo_path = str(sys.argv[1]) -repo = pygit2.Repository(repo_path) -ident = pygit2.Signature('comfyui', 'comfy@ui') -try: - print("stashing current changes") - repo.stash(ident) -except KeyError: - print("nothing to stash") -backup_branch_name = 'backup_branch_{}'.format(datetime.today().strftime('%Y-%m-%d_%H_%M_%S')) -print("creating backup branch: {}".format(backup_branch_name)) -try: - repo.branches.local.create(backup_branch_name, repo.head.peel()) -except: - pass - -print("checking out master branch") -branch = repo.lookup_branch('master') -ref = repo.lookup_reference(branch.name) -repo.checkout(ref) - -print("pulling latest changes") -pull(repo) - -print("Done!") - -self_update = True -if len(sys.argv) > 2: - self_update = '--skip_self_update' not in sys.argv - -update_py_path = os.path.realpath(__file__) -repo_update_py_path = os.path.join(repo_path, ".ci/update_windows/update.py") - -cur_path = os.path.dirname(update_py_path) - - -req_path = os.path.join(cur_path, "current_requirements.txt") -repo_req_path = os.path.join(repo_path, "requirements.txt") - - -def files_equal(file1, file2): - try: - return filecmp.cmp(file1, file2, shallow=False) - except: - return False - -def file_size(f): - try: - return os.path.getsize(f) - except: - return 0 - - -if self_update and not files_equal(update_py_path, repo_update_py_path) and file_size(repo_update_py_path) > 10: - shutil.copy(repo_update_py_path, os.path.join(cur_path, "update_new.py")) - exit() - -if not os.path.exists(req_path) or not files_equal(repo_req_path, req_path): - import subprocess - try: - subprocess.check_call([sys.executable, '-s', '-m', 'pip', 'install', '-r', repo_req_path]) - shutil.copy(repo_req_path, req_path) - except: - pass diff --git a/.ci/update_windows/update_comfyui.bat b/.ci/update_windows/update_comfyui.bat deleted file mode 100755 index bb08c0de0..000000000 --- a/.ci/update_windows/update_comfyui.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -..\python_embeded\python.exe .\update.py ..\ComfyUI\ -if exist update_new.py ( - move /y update_new.py update.py - echo Running updater again since it got updated. - ..\python_embeded\python.exe .\update.py ..\ComfyUI\ --skip_self_update -) -if "%~1"=="" pause diff --git a/.ci/windows_base_files/README_VERY_IMPORTANT.txt b/.ci/windows_base_files/README_VERY_IMPORTANT.txt deleted file mode 100755 index 0216658de..000000000 --- a/.ci/windows_base_files/README_VERY_IMPORTANT.txt +++ /dev/null @@ -1,31 +0,0 @@ -HOW TO RUN: - -if you have a NVIDIA gpu: - -run_nvidia_gpu.bat - - - -To run it in slow CPU mode: - -run_cpu.bat - - - -IF YOU GET A RED ERROR IN THE UI MAKE SURE YOU HAVE A MODEL/CHECKPOINT IN: ComfyUI\models\checkpoints - -You can download the stable diffusion 1.5 one from: https://huggingface.co/runwayml/stable-diffusion-v1-5/blob/main/v1-5-pruned-emaonly.ckpt - - -RECOMMENDED WAY TO UPDATE: -To update the ComfyUI code: update\update_comfyui.bat - - - -To update ComfyUI with the python dependencies, note that you should ONLY run this if you have issues with python dependencies. -update\update_comfyui_and_python_dependencies.bat - - -TO SHARE MODELS BETWEEN COMFYUI AND ANOTHER UI: -In the ComfyUI directory you will find a file: extra_model_paths.yaml.example -Rename this file to: extra_model_paths.yaml and edit it with your favorite text editor. diff --git a/.ci/windows_base_files/run_cpu.bat b/.ci/windows_base_files/run_cpu.bat deleted file mode 100755 index c3ba41721..000000000 --- a/.ci/windows_base_files/run_cpu.bat +++ /dev/null @@ -1,2 +0,0 @@ -.\python_embeded\python.exe -s ComfyUI\main.py --cpu --windows-standalone-build -pause diff --git a/.ci/windows_base_files/run_nvidia_gpu.bat b/.ci/windows_base_files/run_nvidia_gpu.bat deleted file mode 100755 index 274d7c948..000000000 --- a/.ci/windows_base_files/run_nvidia_gpu.bat +++ /dev/null @@ -1,2 +0,0 @@ -.\python_embeded\python.exe -s ComfyUI\main.py --windows-standalone-build -pause diff --git a/main.py b/main.py index 0e3c9e6eb..67a5e8d54 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,8 @@ import asyncio +import warnings from comfy.cmd.main import main if __name__ == "__main__": + warnings.warn("main.py is deprecated. Start comfyui by installing the package through the instructions in the README, not by cloning the repository.", DeprecationWarning) asyncio.run(main())