Compare commits

...
Author SHA1 Message Date
Dr.Lt.Data 77a8fc0cdc An install by a git URL clones a repository that the registry lists
`cm-cli install <url>` and Install via Git URL asked the registry for the
latest version of the nodepack and unpacked its archive when the URL was of
a repository that the registry lists, since #1813 (3.32). The URL with
`@<commit>` was cloned.

- `gitclone_install` asks for the nightly of such a nodepack, which is a
  clone of its repository. A version of the registry that is enabled is
  disabled for the clone, as for any nightly install
- `_install_git` enables that version again when the clone fails. It
  disabled the version before the clone and left the nodepack with no
  enabled version, also for `<id>@nightly` and for a switch to nightly in
  Custom Nodes Manager
- `gitclone_install` passes `instant_execution` and `no_deps` on, which were
  dropped for such a repository, and the URL, which `install_by_id` now
  takes as `reinstall_by_id` does. The clone is of the URL that was given,
  also when the channel has another repository under the name of the nodepack
- `_get_git_install_url` takes the repository of a nightly from the registry
  when the channel does not list the nodepack. Without it that install fails
  with `Node '<id>@nightly' not found`, which #1813 avoided by asking for no
  version (#1812)
- `cm-cli reinstall` of a nightly clone that only the registry lists clones
  it again. The test that pinned `not found` for it now expects the clone
- Add tests: the URL of a repository that only the registry lists is cloned
  from a repository of the test with the flags of the caller, also over a
  version that is enabled or disabled, and the enabled version is enabled
  again when the clone fails
- Add a CHANGELOG entry
2026-12-05 21:11:48 +09:00
4 changed files with 135 additions and 23 deletions
+29
View File
@@ -2,6 +2,35 @@
## Unreleased
### An install by a git URL clones the repository, also one that the registry lists
`cm-cli install <url>` and **Install via Git URL** did not clone a repository
that the registry lists: they asked the registry for the latest version of
that nodepack and unpacked its archive, and said `[INSTALLED] <url>` as for a
clone. The folder had no `.git`, and what the repository got after that
version was not in it. The same URL with `@<commit>` was cloned.
The URL without a commit is now cloned as well, as the nightly of the
nodepack, and the clone is of the URL that was given. A registry version of
the nodepack that is enabled is disabled for that clone. A nightly of the
nodepack that is already installed is kept as it is, and nothing is cloned. A
URL with `@<commit>` is cloned as before. The install also takes `--no-deps`
for such a repository now.
A nightly install over an enabled version disabled that version first, and
left the nodepack with no enabled version when the repository could not be
cloned. The version is now enabled again in that case. A clone that arrives
and whose install script then fails stays in place with the version disabled,
as before. This is also so for `cm-cli install <id>@nightly` and for a switch
to `nightly` in **Custom Nodes Manager**.
A nightly install of a nodepack that the registry lists and the channel does
not failed with `Node '<id>@nightly' not found` (#1812). That is why the
install by a URL was moved to the registry version in 3.32. The repository of
such a nodepack is now taken from the registry: `cm-cli install <id>@nightly`
installs it, and `cm-cli reinstall` of its nightly clone clones it again,
where it said `not found` and left the clone.
### A folder can be a channel of a private network
With `network_mode = private`, a line of `channels.list` can name a folder,
+14 -7
View File
@@ -1532,7 +1532,7 @@ class UnifiedManager:
else:
return self.cnr_switch_version(node_id, instant_execution=instant_execution, no_deps=no_deps, return_postinstall=return_postinstall).with_ver('cnr')
async def install_by_id(self, node_id: str, version_spec=None, channel=None, mode=None, instant_execution=False, no_deps=False, return_postinstall=False):
async def install_by_id(self, node_id: str, version_spec=None, channel=None, mode=None, instant_execution=False, no_deps=False, return_postinstall=False, repo_url=None):
"""
priority if version_spec == None
1. CNR latest
@@ -1544,7 +1544,6 @@ class UnifiedManager:
if 'comfyui-manager' in node_id.lower():
return ManagedResult('skip').fail(f"ignored: installing '{node_id}'")
repo_url = None
if version_spec is None:
if node_id in self.cnr_map:
self.forget_gone_disabled_versions_if_one_is_left(node_id)
@@ -1556,7 +1555,7 @@ class UnifiedManager:
else:
version_spec = self.resolve_unspecified_version(node_id)
if version_spec in ('unknown', 'nightly'):
if repo_url is None and version_spec in ('unknown', 'nightly'):
try:
repo_url = await self._get_git_install_url(node_id, version_spec, channel, mode)
except InvalidChannel as exc:
@@ -1611,9 +1610,13 @@ class UnifiedManager:
async def _get_git_install_url(self, node_id, version_spec, channel, mode):
custom_nodes = await self.get_custom_nodes(channel, mode)
node = custom_nodes.get(node_id)
if node is None:
raise LookupError(f"Node '{node_id}@{version_spec}' not found in [{channel}, {mode}]")
return node['files'][0] if version_spec == 'unknown' else node['repository']
if node is not None:
return node['files'][0] if version_spec == 'unknown' else node['repository']
if version_spec == 'nightly':
cnr = self.cnr_map.get(node_id)
if cnr is not None and cnr.get('repository'):
return cnr['repository']
raise LookupError(f"Node '{node_id}@{version_spec}' not found in [{channel}, {mode}]")
def _git_install_path(self, node_id):
return os.path.abspath(os.path.join(get_default_custom_nodes_path(), node_id))
@@ -1621,9 +1624,11 @@ class UnifiedManager:
def _install_git(self, node_id, version_spec, repo_url, instant_execution=False, no_deps=False, return_postinstall=False):
to_path = self._git_install_path(node_id)
replaced_version = None
if version_spec == 'nightly':
# disable cnr nodes
if self.is_enabled(node_id, 'cnr'):
replaced_version = self.get_cnr_active_version(node_id)
res = self.disable_for_replacement(node_id, to_path)
if not res.result:
return res
@@ -1636,6 +1641,8 @@ class UnifiedManager:
cnr_utils.generate_cnr_id(to_path, node_id)
self.active_nodes[node_id] = 'nightly', to_path
else:
if replaced_version is not None and not os.path.lexists(to_path):
self.unified_enable(node_id, replaced_version)
return res
return res.with_target(version_spec)
@@ -2503,7 +2510,7 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
cnr = unified_manager.get_cnr_by_repo(url)
if cnr:
cnr_id = cnr['id']
return await unified_manager.install_by_id(cnr_id, version_spec=None, channel='default', mode='cache')
return await unified_manager.install_by_id(cnr_id, version_spec='nightly', channel='default', mode='cache', instant_execution=instant_execution, no_deps=no_deps, repo_url=url)
else:
new_url, commit_id = extract_url_and_commit_id(url)
if commit_id != "":
+85
View File
@@ -0,0 +1,85 @@
import pytest
from test_install_flags_config import _run_child
SCRIPT = '''
import asyncio, pathlib, subprocess
import cnr_utils
def git(path, *args):
return subprocess.run(['git', '-c', 'user.name=test', '-c', 'user.email=test@example.invalid', *args],
cwd=path, check=True, capture_output=True, text=True).stdout.strip()
origin = pathlib.Path(tmp) / 'grp' / 'zz-pack'
origin.mkdir(parents=True)
git(origin, 'init', '-q')
for version in (1, 2):
(origin / '__init__.py').write_text('VERSION = %d' % version)
git(origin, 'add', '.')
git(origin, 'commit', '-q', '-m', 'version %d' % version)
tip = git(origin, 'rev-parse', 'HEAD')
other = pathlib.Path(tmp) / 'other' / 'zz-pack'
other.mkdir(parents=True)
git(other, 'init', '-q')
(other / '__init__.py').write_text('ANOTHER = 1')
git(other, 'add', '.')
git(other, 'commit', '-q', '-m', 'another repository of the same name')
os.environ.update(GIT_CONFIG_COUNT='2', GIT_CONFIG_KEY_0='url.%s/%s/.insteadOf' % (tmp, 'grp' if CLONE_WORKS else 'gone'), GIT_CONFIG_VALUE_0='https://git.example.invalid/grp/',
GIT_CONFIG_KEY_1='url.%s/other/.insteadOf' % tmp, GIT_CONFIG_VALUE_1='https://git.example.invalid/other/')
nodes = pathlib.Path(tmp) / 'custom_nodes'
nodes.mkdir()
sys.modules['folder_paths'].get_folder_paths = lambda name: [str(nodes)]
manager_core.get_default_custom_nodes_path = lambda: str(nodes)
manager_core.get_config = lambda: {'network_mode': 'public', 'channel_url': manager_core.DEFAULT_CHANNEL, 'http_channel_enabled': False}
flags = []
manager_core.unified_manager.execute_install_script = lambda url, path, **given: flags.append(given) or True
async def registry(*args, **kwargs):
return [{'id': 'zz-pack', 'repository': 'https://git.example.invalid/grp/zz-pack', 'latest_version': {'version': '1.0.0'}}]
async def channel(mode, filename, channel_url=None):
return {'custom_nodes': LISTED_BY_THE_CHANNEL}
asked = []
cnr_utils.get_cnr_data = registry
cnr_utils.install_node = lambda node_id, version=None: asked.append([node_id, version])
manager_core.get_data_by_mode = channel
installed = FOLDER_OF_A_VERSION
if installed:
(nodes / installed).mkdir(parents=True)
(nodes / installed / 'pyproject.toml').write_text('[project]\\nname = "zz-pack"\\nversion = "1.0.0"\\n')
(nodes / installed / '.tracking').write_text('pyproject.toml')
result = asyncio.run(manager_core.gitclone_install('https://git.example.invalid/grp/zz-pack', instant_execution=True, no_deps=True))
left = {str(path.relative_to(nodes)): 'the tip' if git(path, 'rev-parse', 'HEAD') == tip else 'a clone' for path in nodes.rglob('*') if (path / '.git').is_dir()}
left.update({str(path.relative_to(nodes)): 'version 1.0.0' for path in nodes.rglob('*') if (path / '.tracking').is_file()})
print(json.dumps({'installed': result.result, 'left': left, 'asked the registry for': asked, 'flags of the clone': flags}))
'''
ANOTHER_OF_THE_SAME_NAME = [{'id': 'zz-pack', 'title': 'zz-pack', 'author': 'other', 'install_type': 'git-clone', 'description': '',
'reference': 'https://git.example.invalid/other/zz-pack', 'files': ['https://git.example.invalid/other/zz-pack']}]
def install_by_url(folder_of_a_version=None, clone_works=True, channel=()):
return _run_child(SCRIPT.replace('FOLDER_OF_A_VERSION', repr(folder_of_a_version)).replace('CLONE_WORKS', repr(clone_works)).replace('LISTED_BY_THE_CHANNEL', repr(list(channel))))
CLONED = {'installed': True, 'asked the registry for': [], 'flags of the clone': [{'instant_execution': True, 'no_deps': True}]}
def test_url_of_a_repository_that_the_registry_lists_is_cloned():
assert install_by_url() == {**CLONED, 'left': {'zz-pack': 'the tip'}}
def test_url_is_what_is_cloned_when_the_channel_lists_another_repository_of_that_name():
assert install_by_url(channel=ANOTHER_OF_THE_SAME_NAME) == {**CLONED, 'left': {'zz-pack': 'the tip'}}
@pytest.mark.parametrize('folder', ['zz-pack', '.disabled/zz-pack@1_0_0'], ids=['enabled', 'disabled'])
def test_url_of_a_nodepack_that_is_installed_at_a_version_is_cloned_and_the_version_is_disabled(folder):
assert install_by_url(folder) == {**CLONED, 'left': {'zz-pack': 'the tip', '.disabled/zz-pack@1_0_0': 'version 1.0.0'}}
def test_enabled_version_is_enabled_again_when_the_clone_in_its_place_fails():
assert install_by_url('zz-pack', clone_works=False) == {'installed': False, 'left': {'zz-pack': 'version 1.0.0'}, 'asked the registry for': [], 'flags of the clone': []}
+7 -16
View File
@@ -1422,9 +1422,10 @@ INSTALLED_BEFORE_A_REINSTALL = {
}
def cm_cli_reinstall(installed, spec):
def cm_cli_reinstall(installed, spec, before=''):
data = run(f'''
import io
{before}
{INSTALLED_BEFORE_A_REINSTALL[installed]}
registry_with_every_version()
clone_stand_in()
@@ -1451,23 +1452,13 @@ def test_cm_cli_reinstall_without_a_version_clones_the_nightly_that_is_installed
assert cm_cli_reinstall(installed, spec) == ('[NIGHTLY]', 'the clone')
NODE_LIST_LACKS_IT = "NODE_LIST[:] = [x for x in NODE_LIST if x['reference'] != FOO_URL]"
@pytest.mark.parametrize('installed', ['the_nightly_clone', 'a_disabled_nightly_clone'])
@pytest.mark.parametrize('spec', ['comfyui-foo', 'https://github.com/example/ComfyUI-Foo'], ids=['by-id', 'by-url'])
def test_cm_cli_reinstall_without_a_version_keeps_a_nightly_clone_that_the_node_list_lacks(spec, installed):
data = run(f'''
import io
NODE_LIST[:] = [x for x in NODE_LIST if x['reference'] != FOO_URL]
{INSTALLED_BEFORE_A_REINSTALL[installed]}
registry_with_every_version()
clone_stand_in()
reload()
before = files(nodes)
out = io.StringIO()
cm_cli_reinstall_node(out)({spec!r})
emit({{'out': out.getvalue(), 'same': before == files(nodes)}})
''')
assert "Node 'comfyui-foo@nightly' not found" in data['out']
assert data['same']
def test_cm_cli_reinstall_without_a_version_clones_a_nightly_that_only_the_registry_lists(spec, installed):
assert cm_cli_reinstall(installed, spec, before=NODE_LIST_LACKS_IT) == ('[NIGHTLY]', 'the clone')
def test_cm_cli_reinstall_without_a_version_keeps_a_version_that_the_registry_no_longer_has():