Commit
·
2dee1ec
1
Parent(s):
e7b1387
- launch.py +1 -3
- modules/launch_util.py +22 -30
launch.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
import sys
|
| 3 |
import platform
|
| 4 |
|
| 5 |
-
from modules.launch_util import
|
| 6 |
run_pip, repo_dir, git_clone, requirements_met, script_path, dir_repos
|
| 7 |
from modules.model_loader import load_file_from_url
|
| 8 |
from modules.path import modelfile_path, lorafile_path
|
|
@@ -21,12 +21,10 @@ def prepare_environment():
|
|
| 21 |
comfy_repo = os.environ.get('COMFY_REPO', "https://github.com/comfyanonymous/ComfyUI")
|
| 22 |
comfy_commit_hash = os.environ.get('COMFY_COMMIT_HASH', "2bc12d3d22efb5c63ae3a7fc342bb2dd16b31735")
|
| 23 |
|
| 24 |
-
commit = commit_hash()
|
| 25 |
tag = fooocus_tag
|
| 26 |
|
| 27 |
print(f"Python {sys.version}")
|
| 28 |
print(f"Version: {tag}")
|
| 29 |
-
print(f"Commit hash: {commit}")
|
| 30 |
|
| 31 |
comfyui_name = 'ComfyUI-from-StabilityAI-Official'
|
| 32 |
git_clone(comfy_repo, repo_dir(comfyui_name), "Inference Engine", comfy_commit_hash)
|
|
|
|
| 2 |
import sys
|
| 3 |
import platform
|
| 4 |
|
| 5 |
+
from modules.launch_util import fooocus_tag, is_installed, run, python, \
|
| 6 |
run_pip, repo_dir, git_clone, requirements_met, script_path, dir_repos
|
| 7 |
from modules.model_loader import load_file_from_url
|
| 8 |
from modules.path import modelfile_path, lorafile_path
|
|
|
|
| 21 |
comfy_repo = os.environ.get('COMFY_REPO', "https://github.com/comfyanonymous/ComfyUI")
|
| 22 |
comfy_commit_hash = os.environ.get('COMFY_COMMIT_HASH', "2bc12d3d22efb5c63ae3a7fc342bb2dd16b31735")
|
| 23 |
|
|
|
|
| 24 |
tag = fooocus_tag
|
| 25 |
|
| 26 |
print(f"Python {sys.version}")
|
| 27 |
print(f"Version: {tag}")
|
|
|
|
| 28 |
|
| 29 |
comfyui_name = 'ComfyUI-from-StabilityAI-Official'
|
| 30 |
git_clone(comfy_repo, repo_dir(comfyui_name), "Inference Engine", comfy_commit_hash)
|
modules/launch_util.py
CHANGED
|
@@ -1,18 +1,18 @@
|
|
| 1 |
import os
|
| 2 |
import importlib
|
| 3 |
import importlib.util
|
|
|
|
| 4 |
import subprocess
|
| 5 |
import sys
|
| 6 |
import re
|
| 7 |
import logging
|
|
|
|
| 8 |
|
| 9 |
-
from functools import lru_cache
|
| 10 |
|
| 11 |
logging.getLogger("torch.distributed.nn").setLevel(logging.ERROR) # sshh...
|
| 12 |
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
|
| 13 |
|
| 14 |
python = sys.executable
|
| 15 |
-
git = os.environ.get('GIT', "git")
|
| 16 |
default_command_live = (os.environ.get('LAUNCH_LIVE_OUTPUT') == "1")
|
| 17 |
index_url = os.environ.get('INDEX_URL', "")
|
| 18 |
|
|
@@ -23,35 +23,27 @@ dir_repos = "repositories"
|
|
| 23 |
fooocus_tag = '1.0.0'
|
| 24 |
|
| 25 |
|
| 26 |
-
|
| 27 |
-
def commit_hash():
|
| 28 |
try:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
f"Couldn't checkout commit {commithash} for {name}", live=True)
|
| 49 |
-
return
|
| 50 |
-
|
| 51 |
-
run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}", live=True)
|
| 52 |
-
|
| 53 |
-
if commithash is not None:
|
| 54 |
-
run(f'"{git}" -C "{dir}" checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
|
| 55 |
|
| 56 |
|
| 57 |
def repo_dir(name):
|
|
|
|
| 1 |
import os
|
| 2 |
import importlib
|
| 3 |
import importlib.util
|
| 4 |
+
import shutil
|
| 5 |
import subprocess
|
| 6 |
import sys
|
| 7 |
import re
|
| 8 |
import logging
|
| 9 |
+
import pygit2
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
logging.getLogger("torch.distributed.nn").setLevel(logging.ERROR) # sshh...
|
| 13 |
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
|
| 14 |
|
| 15 |
python = sys.executable
|
|
|
|
| 16 |
default_command_live = (os.environ.get('LAUNCH_LIVE_OUTPUT') == "1")
|
| 17 |
index_url = os.environ.get('INDEX_URL', "")
|
| 18 |
|
|
|
|
| 23 |
fooocus_tag = '1.0.0'
|
| 24 |
|
| 25 |
|
| 26 |
+
def git_clone(url, dir, name, hash=None):
|
|
|
|
| 27 |
try:
|
| 28 |
+
try:
|
| 29 |
+
repo = pygit2.Repository(dir)
|
| 30 |
+
print(f'{name} exists.')
|
| 31 |
+
except:
|
| 32 |
+
if os.path.exists(dir):
|
| 33 |
+
shutil.rmtree(dir, ignore_errors=True)
|
| 34 |
+
os.makedirs(dir, exist_ok=True)
|
| 35 |
+
repo = pygit2.clone_repository(url, dir)
|
| 36 |
+
print(f'{name} cloned.')
|
| 37 |
+
|
| 38 |
+
remote = repo.remotes['origin']
|
| 39 |
+
remote.fetch()
|
| 40 |
+
|
| 41 |
+
commit = repo.get(hash)
|
| 42 |
+
|
| 43 |
+
repo.checkout_tree(commit, strategy=pygit2.GIT_CHECKOUT_FORCE)
|
| 44 |
+
print(f'{name} checkout finished.')
|
| 45 |
+
except Exception as e:
|
| 46 |
+
print(f'Git clone failed for {name}: {str(e)}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
def repo_dir(name):
|