added support for --no-deps option to node install and reinstall

This commit is contained in:
telamonian 2024-07-19 10:17:39 -04:00
parent b3be556837
commit af331778c8
3 changed files with 43 additions and 20 deletions

4
.gitignore vendored
View File

@ -1,6 +1,8 @@
__pycache__/
.idea/
.vscode/
.history/
*.code-workspace
.tmp
.cache
config.ini
@ -12,4 +14,4 @@ matrix_auth
channels.list
comfyworkflows_sharekey
github-stats-cache.json
pip_overrides.json
pip_overrides.json

View File

@ -80,6 +80,7 @@ read_downgrade_blacklist() # This is a preparation step for manager_core
class Ctx:
def __init__(self):
self.channel = 'default'
self.no_deps = False
self.mode = 'cache'
def set_channel_mode(self, channel, mode):
@ -100,6 +101,9 @@ class Ctx:
asyncio.run(unified_manager.reload(cache_mode=self.mode == 'cache'))
asyncio.run(unified_manager.load_nightly(self.channel, self.mode))
def set_no_deps(self, no_deps):
self.no_deps = no_deps
channel_ctx = Ctx()
@ -107,7 +111,7 @@ channel_ctx = Ctx()
def install_node(node_spec_str, is_all=False, cnt_msg=''):
if core.is_valid_url(node_spec_str):
# install via urls
res = asyncio.run(core.gitclone_install(node_spec_str))
res = asyncio.run(core.gitclone_install(node_spec_str, no_deps=channel_ctx.no_deps))
if not res.result:
print(res.msg)
print(f"[bold red]ERROR: An error occurred while installing '{node_spec_str}'.[/bold red]")
@ -125,7 +129,7 @@ def install_node(node_spec_str, is_all=False, cnt_msg=''):
if not is_specified:
version_spec = None
res = asyncio.run(unified_manager.install_by_id(node_name, version_spec, channel_ctx.channel, channel_ctx.mode, instant_execution=True))
res = asyncio.run(unified_manager.install_by_id(node_name, version_spec, channel_ctx.channel, channel_ctx.mode, instant_execution=True, no_deps=channel_ctx.no_deps))
if res.action == 'skip':
print(f"{cnt_msg} [ SKIP ] {node_name:50} => Already installed")
@ -171,7 +175,7 @@ def fix_node(node_spec_str, is_all=False, cnt_msg=''):
node_name, version_spec, _ = node_spec
print(f"{cnt_msg} [ FIXING ]: {node_name:50}[{version_spec}]")
res = unified_manager.unified_fix(node_name, version_spec)
res = unified_manager.unified_fix(node_name, version_spec, no_deps=channel_ctx.no_deps)
if not res.result:
print(f"ERROR: f{res.msg}")
@ -211,7 +215,7 @@ def update_node(node_spec_str, is_all=False, cnt_msg=''):
node_name, version_spec, _ = node_spec
res = unified_manager.unified_update(node_name, version_spec, return_postinstall=True)
res = unified_manager.unified_update(node_name, version_spec, no_deps=channel_ctx.no_deps, return_postinstall=True)
if not res.result:
print(f"ERROR: An error occurred while updating '{node_name}'.")
@ -549,9 +553,17 @@ def install(
mode: str = typer.Option(
None,
help="[remote|local|cache]"
)
),
no_deps: Annotated[
Optional[bool],
typer.Option(
show_default=False,
help="Use new fast dependency installer",
),
] = False,
):
channel_ctx.set_channel_mode(channel, mode)
channel_ctx.set_no_deps(no_deps)
for_each_nodes(nodes, act=install_node)
@ -571,8 +583,16 @@ def reinstall(
None,
help="[remote|local|cache]"
),
no_deps: Annotated[
Optional[bool],
typer.Option(
show_default=False,
help="Use new fast dependency installer",
),
] = False,
):
channel_ctx.set_channel_mode(channel, mode)
channel_ctx.set_no_deps(no_deps)
for_each_nodes(nodes, act=reinstall_node)

View File

@ -1521,7 +1521,8 @@ def __win_check_git_pull(path):
process.wait()
def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=False):
def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=False, no_deps=False):
# import ipdb; ipdb.set_trace()
install_script_path = os.path.join(repo_path, "install.py")
requirements_path = os.path.join(repo_path, "requirements.txt")
@ -1529,7 +1530,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
install_cmd = ["#LAZY-INSTALL-SCRIPT", sys.executable]
try_install_script(url, repo_path, install_cmd)
else:
if os.path.exists(requirements_path):
if os.path.exists(requirements_path) and not no_deps:
print("Install: pip packages")
with open(requirements_path, "r") as requirements_file:
for line in requirements_file:
@ -1547,7 +1548,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
return True
def git_repo_update_check_with(path, do_fetch=False, do_update=False):
def git_repo_update_check_with(path, do_fetch=False, do_update=False, no_deps=False):
"""
perform update check for git custom node
@ -1570,7 +1571,7 @@ def git_repo_update_check_with(path, do_fetch=False, do_update=False):
if platform.system() == "Windows":
updated, success = __win_check_git_update(path, do_fetch, do_update)
if updated and success:
execute_install_script(None, path, lazy_mode=True)
execute_install_script(None, path, lazy_mode=True, no_deps=no_deps)
return updated, success
else:
# Fetch the latest commits from the remote repository
@ -1618,7 +1619,7 @@ def git_repo_update_check_with(path, do_fetch=False, do_update=False):
new_commit_hash = repo.head.commit.hexsha
if commit_hash != new_commit_hash:
execute_install_script(None, path)
execute_install_script(None, path, no_deps=no_deps)
print(f"\nUpdated: {path}")
return True, True
else:
@ -1683,7 +1684,7 @@ def is_valid_url(url):
return False
async def gitclone_install(url, instant_execution=False, msg_prefix=''):
async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=False):
await unified_manager.reload('cache')
await unified_manager.get_custom_nodes('default', 'cache')
@ -1729,7 +1730,7 @@ async def gitclone_install(url, instant_execution=False, msg_prefix=''):
repo.git.clear_cache()
repo.close()
execute_install_script(url, repo_path, instant_execution=instant_execution)
execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps)
print("Installation was successful.")
return result.with_target(repo_path)
@ -1806,7 +1807,7 @@ async def get_data_by_mode(mode, filename, channel_url=None):
return json_obj
def gitclone_fix(files, instant_execution=False):
def gitclone_fix(files, instant_execution=False, no_deps=False):
print(f"Try fixing: {files}")
for url in files:
if not is_valid_url(url):
@ -1822,7 +1823,7 @@ def gitclone_fix(files, instant_execution=False):
if os.path.exists(repo_path+'.disabled'):
repo_path = repo_path+'.disabled'
if not execute_install_script(url, repo_path, instant_execution=instant_execution):
if not execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps):
return False
except Exception as e:
@ -1950,7 +1951,7 @@ def gitclone_set_active(files, is_disable):
return True
def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefix=""):
def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefix="", no_deps=False):
import os
print(f"{msg_prefix}Update: {files}")
@ -1968,10 +1969,10 @@ def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefi
if not skip_script:
if instant_execution:
if not execute_install_script(url, repo_path, lazy_mode=False, instant_execution=True):
if not execute_install_script(url, repo_path, lazy_mode=False, instant_execution=True, no_deps=no_deps):
return False
else:
if not execute_install_script(url, repo_path, lazy_mode=True):
if not execute_install_script(url, repo_path, lazy_mode=True, no_deps=no_deps):
return False
except Exception as e:
@ -1983,7 +1984,7 @@ def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefi
return True
def update_path(repo_path, instant_execution=False):
def update_path(repo_path, instant_execution=False, no_deps=False):
if not os.path.exists(os.path.join(repo_path, '.git')):
return "fail"
@ -2023,7 +2024,7 @@ def update_path(repo_path, instant_execution=False):
if commit_hash != remote_commit_hash:
git_pull(repo_path)
execute_install_script("ComfyUI", repo_path, instant_execution=instant_execution)
execute_install_script("ComfyUI", repo_path, instant_execution=instant_execution, no_deps=no_deps)
return "updated"
else:
return "skipped"