Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0187c72807 | ||
|
|
a3c89b1b39 | ||
|
|
c9c5aef804 | ||
|
|
331710cb03 | ||
|
|
c298bb3da5 | ||
|
|
fcb1799d24 | ||
|
|
ab8410cb27 | ||
|
|
983cd37888 | ||
|
|
2db3f4d60c | ||
|
|
5dac360d69 | ||
|
|
6f98354e4b | ||
|
|
ab7ed0f67d | ||
|
|
b3cabc86ee | ||
|
|
69529c6784 | ||
|
|
3902292033 | ||
|
|
c0f58ee0a7 | ||
|
|
81ca9190f9 | ||
|
|
20999f24ad | ||
|
|
768756d284 | ||
|
|
4da6862b9a | ||
|
|
5249cdea87 | ||
|
|
3407fdd404 | ||
|
|
bebdf19035 | ||
|
|
dab74c91c9 | ||
|
|
055b9cd9b6 | ||
|
|
0a04dc7ccf | ||
|
|
813d696e2c | ||
|
|
6798c6d6b2 | ||
|
|
1d360ace35 | ||
|
|
e2ef555237 | ||
|
|
8618b9ccdb | ||
|
|
b078269ccd | ||
|
|
388fb3ea27 | ||
|
|
6fabc5e0a2 | ||
|
|
dc8a83e298 | ||
|
|
a066d786cd | ||
|
|
c68f6820dd | ||
|
|
92369545f9 | ||
|
|
90a05c166c | ||
|
|
a270d3b95c | ||
|
|
5538a03d8b | ||
|
|
89329cc341 | ||
|
|
22d4e24387 | ||
|
|
f910b6e73d | ||
|
|
a17b568b42 | ||
|
|
22965fe92e | ||
|
|
30e027bedd | ||
|
|
2673d47a7e | ||
|
|
499b18b69f | ||
|
|
ea083afca6 | ||
|
|
088c149880 | ||
|
|
f92a308602 | ||
|
|
55e61bea54 | ||
|
|
5e0e3f04ed |
+444
@@ -2,6 +2,450 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
### An aria2 on the same machine can be the downloader
|
||||
|
||||
With aria2 as the downloader, the Manager asks aria2 to save a file into
|
||||
`/models/...` or `/custom_nodes`, which is where the container of
|
||||
`docs/en/use_aria2.md` sees the folders of ComfyUI. An aria2 that runs on the
|
||||
same machine without a container cannot write there, and its downloads failed
|
||||
(#2999). With `COMFYUI_MANAGER_ARIA2_SAME_PATHS=true` the Manager gives aria2
|
||||
each folder as ComfyUI sees it. Without the variable nothing changes.
|
||||
|
||||
### A download through aria2 that fails is reported as failed
|
||||
|
||||
With `COMFYUI_MANAGER_ARIA2_SERVER` set, the Manager did not look at what
|
||||
aria2 did with a download. A model was reported as installed when aria2 had
|
||||
failed the download, or had saved the file in a folder that ComfyUI does not
|
||||
read. A download that aria2 had queued behind others was not waited for: a
|
||||
model was reported as installed before its file was there, and the install of
|
||||
a registry nodepack failed with `Failed to extract archive`. An install now
|
||||
waits for a download that aria2 has queued, and fails with the error of aria2
|
||||
when aria2 fails the download, or when the download is paused or removed in
|
||||
aria2 before it is complete. It also fails when the file is not where
|
||||
ComfyUI reads it, as when aria2 does not see the ComfyUI folder as `/`
|
||||
(`docs/en/use_aria2.md`): the terminal names the folder that aria2 wrote to.
|
||||
When the download of the archive of a registry nodepack fails, the part that
|
||||
was downloaded and the control file of aria2 no longer stay in `custom_nodes`.
|
||||
|
||||
### A nodepack that two node mappings name shows all its nodes, and the list is drawn
|
||||
|
||||
Two node mappings can name one nodepack, one by its id or git URL and one by
|
||||
its `title_aux`. In the Custom Nodes Manager the second mapping replaced the
|
||||
nodes of the first. When another nodepack had a node of the first mapping,
|
||||
the page failed with `TypeError: Cannot read properties of undefined (reading
|
||||
'conflicts')` and drew no list (#2502). A node that both mappings name showed
|
||||
a conflict with no other nodepack, or each other nodepack twice. The Nodes
|
||||
column and the node list of such a nodepack now have the nodes of both
|
||||
mappings, and each conflict names each other nodepack once. A row can
|
||||
therefore list more nodes than before.
|
||||
|
||||
### The Model Manager finds a model in a subfolder of an extra model path
|
||||
|
||||
A model whose folder in the list has a subfolder, such as `checkpoints/SD1.5`,
|
||||
was shown as not installed when its file was in that subfolder of a folder
|
||||
that `extra_model_paths.yaml` adds (#1844). The Model Manager now also asks
|
||||
ComfyUI where the file is. ComfyUI looks in every folder it has for the first
|
||||
part of the path, the extra ones included, so the model is shown as installed.
|
||||
A model that was shown as installed before still is.
|
||||
|
||||
### A conflict in the Custom Nodes Manager counts only enabled nodepacks
|
||||
|
||||
The Nodes column of the Custom Nodes Manager counted a conflict for every
|
||||
node name that another nodepack in the list also has, whether that nodepack
|
||||
is installed or not. An enabled nodepack showed `N conflicts` for nodepacks
|
||||
that are disabled or not installed, which ComfyUI does not load (#3092,
|
||||
#3273). A conflict now counts only another enabled nodepack. An enabled
|
||||
nodepack shows `N conflicts`, and its node list says
|
||||
`Conflict with enabled packs`. A disabled or not installed nodepack shows
|
||||
`N potential conflicts` for the enabled nodepacks it would conflict with, and
|
||||
its node list says `Potential conflict if installed/enabled with`. In the
|
||||
Nodes column `N potential conflicts` takes two lines. Two nodepacks that are
|
||||
both not enabled show nothing for each other.
|
||||
|
||||
### An install without a version enables a disabled registry nodepack, and an enable request fails for one the registry data does not list
|
||||
|
||||
An install without a version did not see a registry nodepack that was
|
||||
disabled: with the nodepack disabled at 1.0.0 and the registry at 2.0.0,
|
||||
`cm-cli install <id>` installed 2.0.0. It now enables 1.0.0, with no download
|
||||
(#3469, #3528). Where the folder of the newest disabled version is gone, it
|
||||
enables the newest version whose folder is there.
|
||||
|
||||
A request to enable a disabled nodepack that the registry data does not list
|
||||
was answered with success, and nothing was enabled. It is now answered with
|
||||
400 and `Specified inactive node not exists: <id>`. The Custom Nodes Manager
|
||||
shows such a nodepack as not installed and has no **Enable** for it, so the
|
||||
page does not send this request.
|
||||
|
||||
### An install from a Git URL installs the dependencies when Windows cannot read `requirements.txt`
|
||||
|
||||
An install of a nodepack from a Git URL (**Install via Git URL**,
|
||||
`cm-cli install <URL>`, `cm-cli install-deps`) read its `requirements.txt` in
|
||||
the encoding of the locale, which on Windows is the ANSI code page. A UTF-8
|
||||
file with a Chinese or Korean comment failed with `UnicodeDecodeError`, and
|
||||
the nodepack was cloned without its dependencies (#3520). When the locale
|
||||
cannot read the file, the install now reads it in the encoding that `chardet`
|
||||
names, if every line is printable ASCII outside its comment. Otherwise, as
|
||||
for a file that is not text or a requirement with a non-ASCII path, it fails
|
||||
with the same error as before. Such a failure no longer installs the lines in
|
||||
front of the byte it fails on.
|
||||
|
||||
### A nodepack that only the registry lists shows Update when the registry has a newer version
|
||||
|
||||
A nodepack that is in the registry and not in the node list never showed
|
||||
**Update** in the Custom Nodes Manager, and the Update filter did not list it,
|
||||
even when the registry had a newer version (#3220, #3261). The row showed
|
||||
**Try update**, which did update it, but nothing said that an update was
|
||||
there. The row of an enabled nodepack of this kind now shows **Update**, and
|
||||
the Update filter lists it. A nodepack installed as nightly gets no **Update**
|
||||
this way, as for a nodepack of the node list. When such a nodepack failed to
|
||||
import and has a newer version, its row shows **Update** in place of
|
||||
`IMPORT FAILED ↗` and **Try fix**, as the row of a nodepack of the node list
|
||||
already did. The Import Failed filter still lists it.
|
||||
|
||||
### The log file has no color codes of the console
|
||||
|
||||
The Manager writes what ComfyUI prints to the console and to the log file,
|
||||
`comfyui.log` in the user directory. The color codes of the console, such as
|
||||
`ESC[32m`, went into the file as well, where an editor or `grep` shows them as
|
||||
text (#3315). They are now left out of the file, and the console keeps its
|
||||
colors. To keep them in the file as before, set
|
||||
`strip_ansi_file_logging = false` in `config.ini`.
|
||||
|
||||
### The Node Usage Analyzer counts the nodes inside subgraphs, and Uninstall Selected uninstalls
|
||||
|
||||
The Node Usage Analyzer counted only the nodes at the top of a workflow, not
|
||||
those inside a subgraph, and left out a workflow that had a `null` node. A
|
||||
nodepack that was used only there showed 0 workflows and was offered for
|
||||
uninstall. The nodes of every subgraph are now counted, and a workflow with
|
||||
a malformed node is counted without that node (#3285). A node whose `cnr_id`
|
||||
is not text stopped the whole count with
|
||||
`TypeError: cnrId.toLowerCase is not a function`. Such a `cnr_id` is now left
|
||||
out.
|
||||
|
||||
**Uninstall Selected** uninstalled nothing. The page said to restart ComfyUI,
|
||||
and the uninstalls ran at the next Update All, where a nodepack that only the
|
||||
registry lists failed with `An error occurred while uninstalling 'None'.` The
|
||||
uninstalls now run at once. When the queue cannot be started, the page says
|
||||
`Couldn't start the uninstall queue (HTTP <status>). Nothing was
|
||||
uninstalled.`, and the uninstalls still run at the next Update All, as
|
||||
before.
|
||||
|
||||
### The PyTorch restore after a nodepack installs the builds that were installed before
|
||||
|
||||
When a nodepack changed torch or torchvision and the torch from before had
|
||||
no local label, Manager installed the newest releases, and through uv
|
||||
nothing. For a torch with a label it installed the versions of a table that
|
||||
ends at 2.7.0, or the newest nightly build. A nodepack that removed torch,
|
||||
or removed torchvision and left torch as it was, ended the restore with
|
||||
`Failed to restore PyTorch`.
|
||||
|
||||
Now Manager installs each of torch, torchvision and torchaudio that is not
|
||||
the build it was before as that build, such as `torch===2.14.0+cu130` from
|
||||
`https://download.pytorch.org/whl/cu130`. A torchvision or torchaudio whose
|
||||
build cannot be had is replaced by one that fits that torch. A package that
|
||||
this torch requires is installed again with it when another package wrote
|
||||
over one of its files, as a torch of another CUDA version does with the
|
||||
CUDA libraries. A last command resolves torch with torchvision and
|
||||
torchaudio: what fits that torch stays, what does not is replaced, and a
|
||||
dependency that the nodepack removed comes back.
|
||||
|
||||
Then Manager checks in a separate process that torch, torchvision and
|
||||
torchaudio work. For a torch that does not, the packages it requires that
|
||||
lack a file are installed again. A torchvision or torchaudio that does not
|
||||
is installed again from torch's index. What still does not work is named in
|
||||
an ERROR line. When the torch from before cannot be had, Manager restores
|
||||
by its version table as before; the table now goes up to 2.15.0. With uv,
|
||||
the command that installs torch, or a changed torchvision or torchaudio, at
|
||||
its build is sent only in a form that a dry run resolved, and once more
|
||||
when it fails while it installs. For safety the restore does not start when
|
||||
the disk has less free space than it can take: twice the size of what it
|
||||
installs again with pip, one and a half times with uv. pip runs without its
|
||||
cache during the restore, so that it holds each wheel once.
|
||||
|
||||
### cm-cli reinstall keeps the version that is installed
|
||||
|
||||
`cm-cli reinstall <nodepack>` without a version removed the nodepack and
|
||||
installed the latest version of the registry, whatever was installed: 1.0.1
|
||||
became 1.0.2, and a nightly clone became a registry version. It now installs
|
||||
the version that is installed, enabled or disabled, and a nightly clone is
|
||||
cloned again. A registry nodepack named by its URL is reinstalled as one named
|
||||
by its id, also with `@<version>` or `@nightly`; the version that a URL named
|
||||
was dropped before, and the latest one installed. A nodepack that is not
|
||||
installed gets the latest version, and `<nodepack>@latest` or
|
||||
`<nodepack>@<version>` installs what it names, as before. When the registry no
|
||||
longer has the version that is installed, the reinstall fails with `not
|
||||
available node: <nodepack>@<version>` and the nodepack stays as it is;
|
||||
`<nodepack>@latest` installs the latest one. A nightly clone of a nodepack that
|
||||
the node list of the channel lacks is not cloned again: the reinstall says
|
||||
`Node '<nodepack>@nightly' not found` and leaves the clone as it is.
|
||||
|
||||
### cm-cli prints a value in square brackets, and a line for each nodepack it counts
|
||||
|
||||
cm-cli printed every line through rich, which reads a lowercase word in square
|
||||
brackets as markup and drops it, and typer shows a help text the same way.
|
||||
`cm-cli fix` named no version for a git nodepack (`[unknown]`, `[nightly]`),
|
||||
and an install of an id that no list has ended with `not found in` and nothing
|
||||
after it. The name of a nodepack, a reason, a title or an author of the node
|
||||
list, a changelog line, a path or the name of a snapshot lost a part in square
|
||||
brackets that starts with a lowercase letter, and a path lost a backslash
|
||||
before a bracket. cm-cli now writes every line as it is, as the Manager writes
|
||||
its own, a coloured line in its colour. A line longer than the console is wide
|
||||
is no longer broken in two, which was at 80 columns where no terminal is
|
||||
attached, as in a script, and a code such as `:bug:` in a value is no longer
|
||||
turned into an emoji. `--help` showed no text for `--mode` and for the argument
|
||||
of `show`, `simple-show`, `update`, `enable`, `disable`, `fix` and
|
||||
`cli-only-mode`. These texts are now written without their brackets, as
|
||||
`remote|local|cache`, and read the same with and without rich. `cm-cli
|
||||
simple-show` refused a word that is no list with the tags of a colour around
|
||||
the line: `[bold red]Invalid command: ...[/bold red]`. The reason of a failed
|
||||
`cm-cli fix` had an `f` before it. `cm-cli disable all` printed no line for the
|
||||
Manager and `cm-cli fix all` none for a disabled nodepack, so each skipped a
|
||||
number; both print a line now, as `update all` does. `cm-cli
|
||||
restore-dependencies` counted `__pycache__` as a nodepack. `cm-cli install`
|
||||
printed a line of its own before each nodepack: `install_node exit on
|
||||
fail:False...`.
|
||||
|
||||
### A git nodepack that a snapshot lists as disabled is restored as disabled
|
||||
|
||||
A snapshot lists each git nodepack with whether it was disabled when the
|
||||
snapshot was saved, and a restore did not read that, with `cm-cli
|
||||
restore-snapshot` and from the Snapshot Manager alike. A nodepack saved as
|
||||
disabled was enabled when it was disabled, left enabled when it was enabled,
|
||||
and cloned when it was not installed. It is now left disabled, disabled, and
|
||||
not cloned. A nodepack saved at a version of the registry keeps its git clone
|
||||
disabled: that clone is restored when the version could not be, as before,
|
||||
where the node list of the machine that restores knows the URL of the clone.
|
||||
Where a URL has an enabled and a disabled clone installed, a snapshot lists it
|
||||
as enabled, with the commit of the enabled clone; it listed the clone it read
|
||||
last.
|
||||
|
||||
### A disable or an enable does not move a nodepack into a folder that exists
|
||||
|
||||
Disabling a nodepack moves its folder into `custom_nodes/.disabled`, and
|
||||
enabling moves it back. Where the folder it moves to was already there, as with
|
||||
an enabled nodepack and a disabled copy of it, the nodepack was moved inside
|
||||
that folder (`.disabled/<name>/<name>`) and reported as disabled. `cm-cli
|
||||
disable`, the Disable button, a restore that disables a nodepack, and an enable
|
||||
or an install that first disables the enabled version all did so. The disable or
|
||||
enable now fails with `Destination already exists: <folder>` and the nodepack
|
||||
stays in its folder. An enable or an install that first disables the enabled
|
||||
version now looks at its own folder before it does so, and stops when that
|
||||
version cannot be disabled, so one that is refused changes nothing. The Disable
|
||||
and Enable buttons reported success for a disable or an enable that the Manager
|
||||
refused; they now report the failure, and the terminal says why. The Custom
|
||||
Nodes Manager shows the reason of a refused enable as well. `cm-cli install`
|
||||
printed its `ENABLED` line for an enable that failed; it now prints the error.
|
||||
An install that first enables a disabled version stops when that enable fails;
|
||||
it went on to switch the version of whatever was in the folder.
|
||||
|
||||
### Both URLs of the default channel are the default channel
|
||||
|
||||
The default channel is served at
|
||||
`https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main` and at
|
||||
`https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main`, and
|
||||
Manager took only the first as the default channel. Manager 4 writes the
|
||||
second into the same `config.ini` and `channels.list`. With the second as
|
||||
`channel_url` of `config.ini`, or as the `default` line of `channels.list`,
|
||||
the start stopped with `An invalid channel was used`, the list of the Custom
|
||||
Nodes Manager failed to load, and the channel menu showed no channel. Both
|
||||
URLs now mean the default channel: the lists are read from one set of cache
|
||||
files, the registry nodepacks are listed, and `default` is selected.
|
||||
`config.ini` and `channels.list` are left as they are.
|
||||
|
||||
### Every place reads a line of requirements.txt the same way
|
||||
|
||||
Each place that installs the `requirements.txt` of a nodepack line by line
|
||||
read a line its own way. A URL was cut at its `#`, so
|
||||
`git+https://host/repo#subdirectory=sub` installed the root of the
|
||||
repository, which pip and uv refuse as no Python project. A requirement
|
||||
followed by `--index-url URL` went to the installer as one argument, which it
|
||||
refuses, in an install from the registry, an update and a fix of a nodepack,
|
||||
and in `cm-cli install`, `fix` and `restore-dependencies`. An entry of
|
||||
`pip_overrides.json` did not apply to a line with a comment there either, nor
|
||||
in a reserved install that runs at the next start. Now a comment starts at a
|
||||
`#` at the start of the line or after whitespace, as pip reads it, and a
|
||||
requirement followed by `--index-url URL` is installed from that index in
|
||||
every place. A requirement followed by another option, such as
|
||||
`flash-attn --no-build-isolation`, still goes to the installer as one
|
||||
argument and fails as before.
|
||||
|
||||
### An option in requirements.txt applies to its own row only
|
||||
|
||||
A row of the `requirements.txt` of a nodepack that has only an option, such as
|
||||
`--extra-index-url URL`, `--trusted-host host` or `-r other.txt`, went to pip
|
||||
or uv as one argument, which both refuse. In an install from the registry, an
|
||||
update and a fix of a nodepack, and in `cm-cli install`, `fix` and
|
||||
`restore-dependencies`, that failure stopped every row after it: none of them
|
||||
was installed, and the nodepack was reported as failed. The Manager installs
|
||||
requirements one row at a time, and an option applies to the row it is
|
||||
written on only. A row with only an option has nothing to install: it is now
|
||||
left out with the line `skip '<row>': the Manager installs requirements one
|
||||
row at a time and does not apply this row`, and the rows after it are
|
||||
installed. `-r` and `-c` install nothing. A row `-e path` or
|
||||
`--editable path` is an editable requirement and goes to the installer as
|
||||
`-e` and its target, which pip and uv install as editable; before, uv
|
||||
installed `-e path` and pip refused it. With a git URL, pip installs `-e` as
|
||||
it is written. uv installs an editable from a local folder only, so with uv
|
||||
a row `-e git+URL`, with or without index options after it, is installed
|
||||
without `-e`, and a line says so; before, uv refused the row.
|
||||
`--extra-index-url URL` after a requirement now goes to the installer with
|
||||
that requirement, as `--index-url URL` does.
|
||||
|
||||
### A row that names a path is installed for each nodepack
|
||||
|
||||
In one session the Manager installs a row of `requirements.txt` once: a row
|
||||
that an earlier nodepack has installed is not installed again. A row that
|
||||
names a path, such as `-e .`, `-e ./local` or
|
||||
`./wheels/demo-1.0-py3-none-any.whl`, counted as the same row in every
|
||||
nodepack, although the installer reads the path from the folder of each
|
||||
nodepack. In an install, an update and a fix, the second nodepack with such a
|
||||
row was reported as done without its row being installed. Such a row is now
|
||||
installed for each nodepack: a row counts as one when an argument of it,
|
||||
without extras and marker, exists as a path seen from that folder. Any other
|
||||
row is installed once in a session, as before.
|
||||
|
||||
### cm-cli show snapshot prints the snapshot
|
||||
|
||||
`cm-cli show snapshot` and `cm-cli simple-show snapshot` printed only a
|
||||
`RuntimeWarning` that a coroutine was never awaited, and ended with exit code
|
||||
0. They now print the snapshot of the current state: as JSON with `show`, and
|
||||
with `simple-show` a line with the commit hash of ComfyUI and of each git
|
||||
nodepack. The hashes, the URLs and the JSON are written as they are, so a hash
|
||||
that starts with a letter is no longer left out and a long line is not broken.
|
||||
|
||||
### cm-cli enable all enables the disabled nodepacks
|
||||
|
||||
`cm-cli enable all` enabled nothing and said `Already enabled` for every
|
||||
nodepack, the disabled ones too. `all` names each nodepack with its version,
|
||||
and a nodepack named with a version counted as enabled and as disabled at
|
||||
once. `enable`, `disable`, `update` and `fix` now look at the state of the
|
||||
version that is named, also in `<id>@<version>` on the command line. `enable
|
||||
all` enables the disabled nodepacks, `disable all` says `Already disabled` for
|
||||
a disabled registry nodepack instead of `Not installed`, and `fix all` leaves
|
||||
the disabled nodepacks out instead of printing an error for each.
|
||||
`<id>@latest` names no installed version, so with it these four commands act
|
||||
on the installed nodepack, as with the id alone. A disabled version with a
|
||||
pre-release part, such as `1.0.0-rc1`, is enabled as well: it was named
|
||||
`1.0.0rc1`, which no installed version is called, so `cm-cli enable` did not
|
||||
find it. The Custom Nodes Manager shows the version of a disabled nodepack
|
||||
under that name too. For a registry nodepack that is not installed, `update`
|
||||
and `fix` say `Not installed` and `enable` and `disable` say `Not found`,
|
||||
instead of `Disabled` and `Already disabled`.
|
||||
|
||||
### cm-cli show installed lists a git nodepack that the lists do not know
|
||||
|
||||
`cm-cli show installed`, `show enabled` and `show disabled`, and the same lists
|
||||
of `simple-show`, left out a git nodepack that neither the node list of the
|
||||
channel nor the registry knows, enabled or disabled. The documentation says
|
||||
that `installed` shows all nodes that have been installed. They now list such
|
||||
a nodepack with its id and `author: N/A`, as cm-cli did before it supported
|
||||
the registry.
|
||||
|
||||
### cm-cli deps-in-workflow tells whether a registry nodepack is installed
|
||||
|
||||
`cm-cli deps-in-workflow` wrote `"state": "not-installed"` for a nodepack
|
||||
installed from the registry, enabled or disabled, and for a git nodepack
|
||||
disabled into `custom_nodes/.disabled`. It looked for a folder named after
|
||||
the repository, but a registry install has a folder named by its id, and a
|
||||
disable moves the folder into `.disabled`. The state now comes from the
|
||||
nodepacks the Manager knows to be installed, as in the Custom Nodes Manager.
|
||||
`cm-cli install-deps`, which reads the same state, enables a disabled
|
||||
nodepack as `cm-cli enable` does; a git nodepack in `.disabled` stayed
|
||||
disabled. It no longer runs an `enable.py` of the nodepack, which `cm-cli
|
||||
enable` and the Custom Nodes Manager do not run either.
|
||||
|
||||
### cm-cli restore-snapshot restores an editable install
|
||||
|
||||
`cm-cli restore-snapshot` with `--pip-non-url`, `--pip-non-local-url` or
|
||||
`--pip-local-url` ended with exit code 1 when the snapshot had a package
|
||||
installed in editable mode, as `pip install -e` makes it. `pip freeze` lists
|
||||
it as `-e <path>` after a comment line, and the restore gave both lines to
|
||||
pip as packages of PyPI, which pip refused; every package was then installed
|
||||
again one at a time. An editable install is now restored as editable with
|
||||
the option of where it is: `--pip-local-url` for a path,
|
||||
`--pip-non-local-url` for a repository URL. With uv, a git URL is
|
||||
installed without `-e`, as such a row of `requirements.txt` is, and a line
|
||||
says so. A path that the machine does not have is listed under
|
||||
`Installation failed for pip packages`, as a `file:` URL is. The comment
|
||||
line is skipped.
|
||||
|
||||
### In Workflow of the Model Manager lists only the models of the workflow
|
||||
|
||||
The Filter "In Workflow" of the Model Manager took the name of each model file
|
||||
of the workflow without its extension, and showed every row that had that text
|
||||
anywhere in its name, type, base, description, file name or save path. The
|
||||
default workflow loads `ae.safetensors`, and the filter showed 29 rows, every
|
||||
TAESD model among them, where only FLUX.1 VAE model is that file. It also
|
||||
cleared the marks of a search, and did not list a model whose file has none of
|
||||
eight extensions, such as a `.gguf` file. A row is now listed when a widget of
|
||||
the workflow names its file, also in a subfolder.
|
||||
|
||||
### The Filter of the Model Manager works together with Type and Base
|
||||
|
||||
With a Filter choice other than All, the Model Manager ignored Type and Base.
|
||||
Type TAESD with the Filter at Not Installed showed all 569 models that are not
|
||||
installed, instead of the 8 TAESD models. The list now shows the rows that
|
||||
match the Filter, Type, Base and the search together.
|
||||
|
||||
### Share = None hides the Share button of the top bar
|
||||
|
||||
The Share setting of the Manager menu says it hides the share button of the
|
||||
main menu, but it hid only the Share button of the old menu, which the
|
||||
frontend shows only when "Use new menu" is Disabled. The Share button that
|
||||
Manager puts in the top bar, beside its Manager button, stayed when Share was
|
||||
None, both right after the choice and after a reload. Share = None now hides
|
||||
the Share button in either menu, and another choice shows it again.
|
||||
|
||||
### An install without torchaudio gets the PyTorch restore, and the restore does not add torchaudio
|
||||
|
||||
ComfyUI no longer needs torchaudio (Comfy-Org/ComfyUI#16457). On an install
|
||||
without it, Manager logged `[ComfyUI-Manager] PyTorch is not installed` at
|
||||
every start and after an install, an update or a fix of a nodepack that has
|
||||
requirements, and did not restore PyTorch when a nodepack changed torch or
|
||||
torchvision. That line is no longer logged, and after such a nodepack Manager
|
||||
runs the PyTorch restore that an install with torchaudio gets. The restore
|
||||
installs torchaudio only when the install had it or the nodepack added it. A
|
||||
nodepack that changes only torchaudio no longer starts that restore. The Linux
|
||||
and Windows venv install scripts and the Colab notebook no longer install
|
||||
torchaudio.
|
||||
|
||||
### An installed registry nodepack is listed with the registry's id
|
||||
|
||||
`GET /customnode/installed` gave the id of a nodepack installed from the
|
||||
registry in lowercase, as `comfyui_sigmoidoffsetscheduler`, and a node added
|
||||
to a workflow took that id. The Custom Nodes Manager names the nodepack as
|
||||
the registry writes it, `ComfyUI_SigmoidOffsetScheduler`, and Check Missing
|
||||
and Install Missing Custom Nodes said `Failed to find the following
|
||||
ComfyRegistry list` for the id of such a workflow when the nodepack was not
|
||||
installed, and then listed the same nodepack. The id is now given as the
|
||||
`pyproject.toml` of the nodepack writes it.
|
||||
|
||||
### Check Missing finds the nodepack of a node whose id differs in case
|
||||
|
||||
A workflow saved with an earlier install keeps the lowercased id. When that
|
||||
nodepack was not installed, Check Missing and Install Missing Custom Nodes
|
||||
said `Failed to find the following ComfyRegistry list` for the id, and did
|
||||
not list the nodepack at all when the node map did not know the node. The id
|
||||
of a missing node is now matched without regard to case when the list has no
|
||||
exact match, as Custom Nodes In Workflow already did.
|
||||
|
||||
### The Custom Nodes Manager no longer offers the "Alternatives of A1111" filter
|
||||
|
||||
The Filter of the Custom Nodes Manager no longer offers "Alternatives of
|
||||
A1111", which showed the entries of `alter-list.json` in an extra Alternatives
|
||||
column. The choice and its route `GET /customnode/alternatives` are removed,
|
||||
and Manager no longer fetches `alter-list.json` at start. The file stays in the
|
||||
channels, where older versions of Manager still fetch it.
|
||||
|
||||
### Update All Custom Nodes in the desktop app shows its result
|
||||
|
||||
In the desktop app the Manager menu has Update All Custom Nodes, which does
|
||||
not update ComfyUI. When its updates were done the menu showed nothing. The
|
||||
result had no entry for ComfyUI, and the menu stopped with an error on the
|
||||
missing entry. The box now lists the nodepacks that were updated, with a
|
||||
RESTART button, and those whose update failed. When nothing was updated and
|
||||
nothing failed, it says `You are already up to date.`
|
||||
|
||||
### Check Update no longer stops the server, and shows how far it is
|
||||
|
||||
Check Update in the Custom Nodes Manager fetched every git nodepack inside the
|
||||
|
||||
@@ -8,8 +8,7 @@ import threading
|
||||
from typing import Optional
|
||||
|
||||
import typer
|
||||
from rich import print
|
||||
from rich.markup import escape
|
||||
import rich
|
||||
from typing_extensions import List, Annotated
|
||||
import re
|
||||
import git
|
||||
@@ -30,7 +29,7 @@ if comfy_path is None:
|
||||
import folder_paths
|
||||
comfy_path = os.path.join(os.path.dirname(folder_paths.__file__))
|
||||
except:
|
||||
print("\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
rich.print("\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
|
||||
comfy_path = os.path.abspath(os.path.join(manager_util.comfyui_manager_path, '..', '..'))
|
||||
|
||||
# This should be placed here
|
||||
@@ -42,6 +41,8 @@ import manager_core as core
|
||||
from manager_core import unified_manager
|
||||
import cnr_utils
|
||||
|
||||
print = core.print
|
||||
|
||||
comfyui_manager_path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
cm_global.pip_blacklist = {'torch', 'torchaudio', 'torchsde', 'torchvision'}
|
||||
@@ -68,7 +69,7 @@ def check_comfyui_hash():
|
||||
core.comfy_ui_revision = len(list(repo.iter_commits('HEAD')))
|
||||
core.comfy_ui_commit_datetime = repo.head.commit.committed_datetime
|
||||
except:
|
||||
print('[bold yellow]INFO: Frozen ComfyUI mode.[/bold yellow]')
|
||||
print('INFO: Frozen ComfyUI mode.', style='bold yellow')
|
||||
core.comfy_ui_revision = 0
|
||||
core.comfy_ui_commit_datetime = 0
|
||||
|
||||
@@ -186,14 +187,13 @@ cmd_ctx = Ctx()
|
||||
|
||||
def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
|
||||
exit_on_fail = kwargs.get('exit_on_fail', False)
|
||||
print(f"install_node exit on fail:{exit_on_fail}...")
|
||||
|
||||
|
||||
if core.is_valid_url(node_spec_str):
|
||||
# install via urls
|
||||
res = asyncio.run(core.gitclone_install(node_spec_str, no_deps=cmd_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]")
|
||||
print(f"ERROR: An error occurred while installing '{node_spec_str}'.", style="bold red")
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
else:
|
||||
@@ -214,7 +214,7 @@ def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
|
||||
|
||||
if res.action == 'skip':
|
||||
print(f"{cnt_msg} [ SKIP ] {node_name:50} => Already installed")
|
||||
elif res.action == 'enable':
|
||||
elif res.action == 'enable' and res.result:
|
||||
print(f"{cnt_msg} [ ENABLED ] {node_name:50}")
|
||||
elif res.action == 'install-git' and res.target == 'nightly':
|
||||
print(f"{cnt_msg} [INSTALLED] {node_name:50}[NIGHTLY]")
|
||||
@@ -229,32 +229,40 @@ def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
|
||||
show_versions(node_name)
|
||||
print("")
|
||||
else:
|
||||
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.\n{res.msg}[/bold red]")
|
||||
print(f"ERROR: An error occurred while installing '{node_name}'.\n{res.msg}", style="bold red")
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def reinstall_node(node_spec_str, is_all=False, cnt_msg=''):
|
||||
node_name, version_spec, _ = unified_manager.resolve_node_spec(node_spec_str)
|
||||
node_name, version_spec, is_specified = unified_manager.resolve_node_spec(node_spec_str)
|
||||
repo_url = None
|
||||
if core.is_valid_url(node_name):
|
||||
url = node_name.rstrip('/')
|
||||
cnr = unified_manager.get_cnr_by_repo(url)
|
||||
if cnr:
|
||||
node_name, version_spec, _ = unified_manager.resolve_node_spec(cnr['id'])
|
||||
node_name = cnr['id']
|
||||
if not is_specified:
|
||||
version_spec = unified_manager.resolve_unspecified_version(node_name)
|
||||
else:
|
||||
node_name, version_spec, repo_url = core.unknown_node_id(url), 'unknown', url
|
||||
|
||||
if not is_specified and repo_url is None:
|
||||
for guess_mode in ('active', 'inactive'):
|
||||
installed = unified_manager.resolve_unspecified_version(node_name, guess_mode=guess_mode)
|
||||
if installed not in (None, 'unknown'):
|
||||
version_spec = installed
|
||||
break
|
||||
|
||||
res = asyncio.run(unified_manager.reinstall_by_id(node_name, version_spec, cmd_ctx.channel, cmd_ctx.mode, instant_execution=True,
|
||||
no_deps=cmd_ctx.no_deps, repo_url=repo_url))
|
||||
if res.action == 'skip':
|
||||
print(f"{cnt_msg} [ SKIP ] {node_name:50} => Already installed")
|
||||
return
|
||||
if not res.result:
|
||||
print(f"[bold red]ERROR: An error occurred while reinstalling '{node_name}'.\n{escape(res.msg)}[/bold red]")
|
||||
print(f"ERROR: An error occurred while reinstalling '{node_name}'.\n{res.msg}", style="bold red")
|
||||
return
|
||||
|
||||
# in capitals, as install_node prints a git install: rich reads a lowercase [nightly] as markup
|
||||
target = res.target.upper() if res.target in ('nightly', 'unknown') else res.target
|
||||
print(f"{cnt_msg} [REINSTALLED] {node_name:50}[{target}]")
|
||||
|
||||
@@ -263,11 +271,10 @@ def fix_node(node_spec_str, is_all=False, cnt_msg='', fixed=None):
|
||||
node_spec = unified_manager.resolve_node_spec(node_spec_str, guess_mode='active')
|
||||
|
||||
if node_spec is None:
|
||||
if not is_all:
|
||||
if unified_manager.resolve_node_spec(node_spec_str, guess_mode='inactive') is not None:
|
||||
print(f"{cnt_msg} [ SKIPPED ]: {node_spec_str:50} => Disabled")
|
||||
else:
|
||||
print(f"{cnt_msg} [ SKIPPED ]: {node_spec_str:50} => Not installed")
|
||||
if unified_manager.resolve_node_spec(node_spec_str, guess_mode='inactive') is not None:
|
||||
print(f"{cnt_msg} [ SKIPPED ]: {node_spec_str:50} => Disabled")
|
||||
else:
|
||||
print(f"{cnt_msg} [ SKIPPED ]: {node_spec_str:50} => Not installed")
|
||||
|
||||
return
|
||||
|
||||
@@ -277,7 +284,7 @@ def fix_node(node_spec_str, is_all=False, cnt_msg='', fixed=None):
|
||||
res = unified_manager.unified_fix(node_name, version_spec, no_deps=cmd_ctx.no_deps, fixed=fixed)
|
||||
|
||||
if not res.result:
|
||||
print(f"[bold red]ERROR: f{res.msg}[/bold red]")
|
||||
print(f"ERROR: {res.msg}", style="bold red")
|
||||
|
||||
|
||||
def uninstall_node(node_spec_str: str, is_all: bool = False, cnt_msg: str = ''):
|
||||
@@ -409,6 +416,7 @@ def enable_node(node_spec_str, is_all=False, cnt_msg=''):
|
||||
|
||||
def disable_node(node_spec_str: str, is_all=False, cnt_msg=''):
|
||||
if 'comfyui-manager' in node_spec_str.lower():
|
||||
print(f"{cnt_msg} [ SKIP ] {node_spec_str:50} => Not disabled: its name has 'comfyui-manager'")
|
||||
return
|
||||
|
||||
node_spec = unified_manager.resolve_node_spec(node_spec_str, guess_mode='active')
|
||||
@@ -462,11 +470,7 @@ def show_list(kind, simple=False):
|
||||
|
||||
if flag and kind != 'cnr':
|
||||
for k, v in unified_manager.unknown_active_nodes.items():
|
||||
item = repo_unknown.get(k)
|
||||
|
||||
if item is None:
|
||||
continue
|
||||
|
||||
item = repo_unknown.get(k, {'title': k, 'author': 'N/A'})
|
||||
log_item = "[ ENABLED ] ", item['title'], k, item['author']
|
||||
unknown_processed.append(log_item)
|
||||
|
||||
@@ -493,11 +497,7 @@ def show_list(kind, simple=False):
|
||||
|
||||
if flag and kind != 'cnr':
|
||||
for k, v in unified_manager.unknown_inactive_nodes.items():
|
||||
item = repo_unknown.get(k)
|
||||
|
||||
if item is None:
|
||||
continue
|
||||
|
||||
item = repo_unknown.get(k, {'title': k, 'author': 'N/A'})
|
||||
log_item = "[ DISABLED ] ", item['title'], k, item['author']
|
||||
unknown_processed.append(log_item)
|
||||
|
||||
@@ -528,7 +528,7 @@ def show_list(kind, simple=False):
|
||||
if simple:
|
||||
print(title+'@'+ver_spec)
|
||||
else:
|
||||
print(f"{prefix} {title:50} {short_id:30} (author: {author:20}) \\[{ver_spec}]")
|
||||
print(f"{prefix} {title:50} {short_id:30} (author: {author:20}) [{ver_spec}]")
|
||||
|
||||
for x in unknown_processed:
|
||||
prefix, title, short_id, author = x
|
||||
@@ -538,19 +538,19 @@ def show_list(kind, simple=False):
|
||||
print(f"{prefix} {title:50} {short_id:30} (author: {author:20}) [UNKNOWN]")
|
||||
|
||||
|
||||
async def show_snapshot(simple_mode=False):
|
||||
json_obj = await core.get_current_snapshot()
|
||||
def show_snapshot(simple_mode=False):
|
||||
json_obj = asyncio.run(core.get_current_snapshot())
|
||||
|
||||
if simple_mode:
|
||||
print(f"[{json_obj['comfyui']}] comfyui")
|
||||
core.print(f"[{json_obj['comfyui']}] comfyui")
|
||||
for k, v in json_obj['git_custom_nodes'].items():
|
||||
print(f"[{v['hash']}] {k}")
|
||||
core.print(f"[{v['hash']}] {k}")
|
||||
for v in json_obj['file_custom_nodes']:
|
||||
print(f"[ N/A ] {v['filename']}")
|
||||
core.print(f"[ N/A ] {v['filename']}")
|
||||
|
||||
else:
|
||||
formatted_json = json.dumps(json_obj, ensure_ascii=False, indent=4)
|
||||
print(formatted_json)
|
||||
core.print(formatted_json)
|
||||
|
||||
|
||||
def show_snapshot_list(simple_mode=False):
|
||||
@@ -652,7 +652,7 @@ def install(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
no_deps: Annotated[
|
||||
Optional[bool],
|
||||
@@ -694,7 +694,7 @@ def reinstall(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
no_deps: Annotated[
|
||||
Optional[bool],
|
||||
@@ -732,7 +732,7 @@ def uninstall(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
):
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
@@ -743,7 +743,7 @@ def uninstall(
|
||||
def update(
|
||||
nodes: List[str] = typer.Argument(
|
||||
...,
|
||||
help="[all|List of custom nodes to update]"
|
||||
help="all|List of custom nodes to update"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -754,7 +754,7 @@ def update(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -782,7 +782,7 @@ def update(
|
||||
def disable(
|
||||
nodes: List[str] = typer.Argument(
|
||||
...,
|
||||
help="[all|List of custom nodes to disable]"
|
||||
help="all|List of custom nodes to disable"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -793,7 +793,7 @@ def disable(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -813,7 +813,7 @@ def disable(
|
||||
def enable(
|
||||
nodes: List[str] = typer.Argument(
|
||||
...,
|
||||
help="[all|List of custom nodes to enable]"
|
||||
help="all|List of custom nodes to enable"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -824,7 +824,7 @@ def enable(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -844,7 +844,7 @@ def enable(
|
||||
def fix(
|
||||
nodes: List[str] = typer.Argument(
|
||||
...,
|
||||
help="[all|List of custom nodes to fix]"
|
||||
help="all|List of custom nodes to fix"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -855,7 +855,7 @@ def fix(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -886,7 +886,7 @@ def show_versions(node_name: str):
|
||||
@app.command("show", help="Show node list")
|
||||
def show(
|
||||
arg: str = typer.Argument(
|
||||
help="[installed|enabled|not-installed|disabled|all|cnr|snapshot|snapshot-list]"
|
||||
help="installed|enabled|not-installed|disabled|all|cnr|snapshot|snapshot-list"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -897,7 +897,7 @@ def show(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -931,7 +931,7 @@ def show(
|
||||
@app.command("simple-show", help="Show node list (simple mode)")
|
||||
def simple_show(
|
||||
arg: str = typer.Argument(
|
||||
help="[installed|enabled|not-installed|disabled|all|snapshot|snapshot-list]"
|
||||
help="installed|enabled|not-installed|disabled|all|snapshot|snapshot-list"
|
||||
),
|
||||
channel: Annotated[
|
||||
str,
|
||||
@@ -942,7 +942,7 @@ def simple_show(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -959,7 +959,7 @@ def simple_show(
|
||||
"snapshot-list",
|
||||
]
|
||||
if arg not in valid_commands:
|
||||
typer.echo(f"[bold red]Invalid command: `show {arg}`[/bold red]", err=True)
|
||||
typer.echo(f"Invalid command: `show {arg}`", err=True)
|
||||
exit(1)
|
||||
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
@@ -976,7 +976,7 @@ def simple_show(
|
||||
@app.command('cli-only-mode', help="Set whether to use ComfyUI-Manager in CLI-only mode.")
|
||||
def cli_only_mode(
|
||||
mode: str = typer.Argument(
|
||||
..., help="[enable|disable]"
|
||||
..., help="enable|disable"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -995,7 +995,7 @@ def cli_only_mode(
|
||||
os.remove(cli_mode_flag)
|
||||
print("\nINFO: `cli-only-mode` is disabled\n")
|
||||
else:
|
||||
print(f"\n[bold red]Invalid value for cli-only-mode: {mode}[/bold red]\n")
|
||||
print(f"\nInvalid value for cli-only-mode: {mode}\n", style="bold red")
|
||||
exit(1)
|
||||
|
||||
|
||||
@@ -1018,7 +1018,7 @@ def deps_in_workflow(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -1032,7 +1032,7 @@ def deps_in_workflow(
|
||||
output_path = output
|
||||
|
||||
if not os.path.exists(input_path):
|
||||
print(f"[bold red]File not found: {input_path}[/bold red]")
|
||||
print(f"File not found: {input_path}", style="bold red")
|
||||
exit(1)
|
||||
|
||||
used_exts, unknown_nodes = asyncio.run(core.extract_nodes_from_workflow(input_path, mode=cmd_ctx.mode, channel_url=cmd_ctx.channel))
|
||||
@@ -1077,13 +1077,13 @@ def save_snapshot(
|
||||
|
||||
if output is not None:
|
||||
if(not output.endswith('.json') and not output.endswith('.yaml')):
|
||||
print("[bold red]ERROR: output path should be either '.json' or '.yaml' file.[/bold red]")
|
||||
print("ERROR: output path should be either '.json' or '.yaml' file.", style="bold red")
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
dir_path = os.path.dirname(output)
|
||||
|
||||
if(dir_path != '' and not os.path.exists(dir_path)):
|
||||
print(f"[bold red]ERROR: {output} path not exists.[/bold red]")
|
||||
print(f"ERROR: {output} path not exists.", style="bold red")
|
||||
raise typer.Exit(code=1)
|
||||
|
||||
path = asyncio.run(core.save_snapshot_with_postfix('snapshot', output, not full_snapshot))
|
||||
@@ -1142,14 +1142,14 @@ def restore_snapshot(
|
||||
else:
|
||||
snapshot_path = os.path.join(cmd_ctx.get_snapshot_path(), snapshot_name)
|
||||
if not os.path.exists(snapshot_path):
|
||||
print(f"[bold red]ERROR: `{snapshot_path}` is not exists.[/bold red]")
|
||||
print(f"ERROR: `{snapshot_path}` is not exists.", style="bold red")
|
||||
exit(1)
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, core.manager_files_path)
|
||||
try:
|
||||
is_restored = asyncio.run(core.restore_snapshot(snapshot_path, extras))
|
||||
except Exception:
|
||||
print("[bold red]ERROR: Failed to restore snapshot.[/bold red]")
|
||||
print("ERROR: Failed to restore snapshot.", style="bold red")
|
||||
traceback.print_exc()
|
||||
raise typer.Exit(code=1)
|
||||
pip_fixer.fix_broken()
|
||||
@@ -1174,7 +1174,7 @@ def restore_dependencies(
|
||||
for base_path in cmd_ctx.get_custom_nodes_paths():
|
||||
for name in os.listdir(base_path):
|
||||
target = os.path.join(base_path, name)
|
||||
if os.path.isdir(target) and not name.endswith('.disabled'):
|
||||
if os.path.isdir(target) and not name.endswith('.disabled') and name != '__pycache__':
|
||||
node_paths.append(target)
|
||||
|
||||
total = len(node_paths)
|
||||
@@ -1221,7 +1221,7 @@ def install_deps(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -1233,14 +1233,14 @@ def install_deps(
|
||||
asyncio.run(auto_save_snapshot())
|
||||
|
||||
if not os.path.exists(deps):
|
||||
print(f"[bold red]File not found: {deps}[/bold red]")
|
||||
print(f"File not found: {deps}", style="bold red")
|
||||
exit(1)
|
||||
else:
|
||||
with open(deps, 'r', encoding="UTF-8", errors="ignore") as json_file:
|
||||
try:
|
||||
json_obj = json.load(json_file)
|
||||
except:
|
||||
print(f"[bold red]Invalid json file: {deps}[/bold red]")
|
||||
print(f"Invalid json file: {deps}", style="bold red")
|
||||
exit(1)
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, core.manager_files_path)
|
||||
@@ -1251,7 +1251,8 @@ def install_deps(
|
||||
elif state == 'not-installed':
|
||||
asyncio.run(core.gitclone_install(k, instant_execution=True))
|
||||
else: # disabled
|
||||
core.gitclone_set_active([k], False)
|
||||
cnr = unified_manager.get_cnr_by_repo(k)
|
||||
enable_node(cnr['id'] if cnr else core.unknown_node_id(k))
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
print("Dependency installation and activation complete.")
|
||||
@@ -1274,7 +1275,7 @@ def export_custom_node_ids(
|
||||
] = None,
|
||||
mode: str = typer.Option(
|
||||
None,
|
||||
help="[remote|local|cache]"
|
||||
help="remote|local|cache"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
@@ -1303,6 +1304,3 @@ def export_custom_node_ids(
|
||||
if __name__ == '__main__':
|
||||
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
|
||||
sys.exit(app())
|
||||
|
||||
|
||||
print("")
|
||||
|
||||
+280
-219
@@ -14197,17 +14197,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Use ComfyUI with RTX Remix to remaster classic games [a/https://github.com/NVIDIAGameWorks/rtx-remix](https://github.com/NVIDIAGameWorks/rtx-remix)"
|
||||
},
|
||||
{
|
||||
"author": "toxicwind",
|
||||
"title": "TTools for ComfyUI",
|
||||
"id": "ttools",
|
||||
"reference": "https://github.com/toxicwind/ComfyUI-TTools",
|
||||
"files": [
|
||||
"https://github.com/toxicwind/ComfyUI-TTools"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text Randomization and Formatting, JSON Extraction and Processing, SD3 Resolution Solver"
|
||||
},
|
||||
{
|
||||
"author": "Yanick112",
|
||||
"title": "ComfyUI-ToSVG",
|
||||
@@ -39860,16 +39849,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom node suite integrating multiple AI image generation APIs (Gemini, Flux.1 Kontext Pro) with unified authentication via ComfyUI API Key and real-time cost tracking. (Description by CC)"
|
||||
},
|
||||
{
|
||||
"author": "StarIICraft",
|
||||
"title": "ComfyUI-Simple-Selector",
|
||||
"reference": "https://github.com/StarIICraft/ComfyUI-Simple-Selector",
|
||||
"files": [
|
||||
"https://github.com/StarIICraft/ComfyUI-Simple-Selector"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Logic control node with 5 universal input ports that checks connections in reverse priority order and outputs the index of the first valid active input, with support for muted nodes and any data type."
|
||||
},
|
||||
{
|
||||
"author": "wwzhifeng",
|
||||
"title": "comfyui-jsonprompt",
|
||||
@@ -40223,16 +40202,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "MiniMax H3 for ComfyUI: one drag-and-drop input node covering t2va/fl2va/ref2va, plus step caching, partial decode and profiling."
|
||||
},
|
||||
{
|
||||
"author": "huygiatrng",
|
||||
"title": "Facefusion_comfyui",
|
||||
"reference": "https://github.com/huygiatrng/Facefusion_comfyui",
|
||||
"files": [
|
||||
"https://github.com/huygiatrng/Facefusion_comfyui"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Advanced face swapping for ComfyUI with local ONNX inference - no API required!"
|
||||
},
|
||||
{
|
||||
"author": "obvirm",
|
||||
"title": "ComfyUI-WhisperXX",
|
||||
@@ -40417,16 +40386,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Three custom ComfyUI nodes: Empty Image RGB, Text Line Break, and Random Chars (Append) for convenient utilities. (Description by CC)"
|
||||
},
|
||||
{
|
||||
"author": "Zeknes",
|
||||
"title": "Comfyui-LLM-Chat",
|
||||
"reference": "https://github.com/Zeknes/Comfyui-LLM-Chat",
|
||||
"files": [
|
||||
"https://github.com/Zeknes/Comfyui-LLM-Chat"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Custom ComfyUI node providing unified access to multiple Large Language Models including OpenAI-compatible APIs and local Ollama instances with image support."
|
||||
},
|
||||
{
|
||||
"author": "xiaoshengyvlin",
|
||||
"title": "ComfyUI-MetaData-ZaKo",
|
||||
@@ -42688,16 +42647,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "A ComfyUI custom node pack that embeds a playable Tetris game inside a node UI, with image outputs for the live board and next-piece preview."
|
||||
},
|
||||
{
|
||||
"author": "latentastronaut",
|
||||
"title": "comfyui-latent-astronaut-suite",
|
||||
"reference": "https://github.com/latentastronaut/comfyui-latent-astronaut-suite",
|
||||
"files": [
|
||||
"https://github.com/latentastronaut/comfyui-latent-astronaut-suite"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI nodes for batch processing, loops, and iteration workflows"
|
||||
},
|
||||
{
|
||||
"author": "d3cker",
|
||||
"title": "comfyui_remove_background",
|
||||
@@ -48908,16 +48857,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Variables Board is a floating control center for ComfyUI workflows that centralizes parameters into a customizable overlay."
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Clone Output",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-clone-output",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-clone-output"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Clone Output"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Color Correct",
|
||||
@@ -48948,16 +48887,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Alert"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Booleangate",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-booleangate",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-booleangate"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Booleangate"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Delay",
|
||||
@@ -48978,16 +48907,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Color Postpro"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Basic Nodes",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-basic-nodes",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-basic-nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Basic Nodes"
|
||||
},
|
||||
{
|
||||
"author": "hassan-mb",
|
||||
"title": "HB ComfyUI Nodes",
|
||||
@@ -51365,16 +51284,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom node to rotate OpenPose figures around their torso"
|
||||
},
|
||||
{
|
||||
"author": "evanscho",
|
||||
"title": "Advanced Mask Nodes",
|
||||
"reference": "https://github.com/evanscho/ComfyUI-advanced-mask-nodes",
|
||||
"files": [
|
||||
"https://github.com/evanscho/ComfyUI-advanced-mask-nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A collection of custom nodes for ComfyUI"
|
||||
},
|
||||
{
|
||||
"author": "initialb-util",
|
||||
"title": "InitialB Util",
|
||||
@@ -52504,16 +52413,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom nodes for uploading and loading images from S3 buckets"
|
||||
},
|
||||
{
|
||||
"author": "Herony82",
|
||||
"title": "WanAnimatePreprocess Track",
|
||||
"reference": "https://github.com/Herony82/ComfyUI-WanAnimatePreprocess-track",
|
||||
"files": [
|
||||
"https://github.com/Herony82/ComfyUI-WanAnimatePreprocess-track"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "TrackedPoseAndFaceDetection - PoseAndFaceDetection con selezione manuale dei punti di tracking e optical flow (Lucas-Kanade). Richiede ComfyUI-WanAnimatePreprocess."
|
||||
},
|
||||
{
|
||||
"author": "hiroki-abe-58",
|
||||
"title": "comfyui-acemusic",
|
||||
@@ -54541,7 +54440,7 @@
|
||||
"https://github.com/Moon-NE/MoonNe_Nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text utilities and NTD11 video mosaic nodes. Includes weighted random prompts, text concatenation, a video file picker, folder batch processing, and audio preservation. Video detection requires an NVIDIA CUDA GPU."
|
||||
"description": "Text utilities and NTD11 mosaic nodes for single videos, video folders, and still-image folders. Videos preserve audio and support optional SAM2 contour tracking. Images are saved as PNG with transparency. Detection requires an NVIDIA CUDA GPU."
|
||||
},
|
||||
{
|
||||
"author": "younestft",
|
||||
@@ -55369,16 +55268,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI node package for BYOK (bring-your-own-key) access to external generative APIs: Gemini, Veo, and more via LiteLLM."
|
||||
},
|
||||
{
|
||||
"author": "Ave-Mollan",
|
||||
"title": "civitai-sdk-api-nodes-for-comfyui",
|
||||
"reference": "https://github.com/Ave-Mollan/CivitAI-SDK-API-nodes-for-ComfyUI",
|
||||
"files": [
|
||||
"https://github.com/Ave-Mollan/CivitAI-SDK-API-nodes-for-ComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom nodes for CivitAI cloud image generation via API"
|
||||
},
|
||||
{
|
||||
"author": "stratopause-lsc",
|
||||
"title": "ComfyUI-MacMemoryMonitor",
|
||||
@@ -57231,13 +57120,13 @@
|
||||
},
|
||||
{
|
||||
"author": "alphaziod",
|
||||
"title": "saya-comfy-couple-plus",
|
||||
"reference": "https://github.com/alphaziod/saya-comfy-couple-plus",
|
||||
"title": "Saya Couple",
|
||||
"reference": "https://github.com/alphaziod/saya-studio-x-couple",
|
||||
"files": [
|
||||
"https://github.com/alphaziod/saya-comfy-couple-plus"
|
||||
"https://github.com/alphaziod/saya-studio-x-couple"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Saya Comfy Couple+ is a modified Comfy Couple node for ComfyUI made for cleaner solo, duo, and dual-character workflows with better control over prompts, masks, and IPAdapter routing."
|
||||
"description": "Separate MAIN scene / ACTION / P1 / P2 prompts for each character, in couple or solo mode, with no changes to the ComfyUI core."
|
||||
},
|
||||
{
|
||||
"author": "andreyvagner74-art",
|
||||
@@ -59030,16 +58919,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Self-contained ComfyUI remove core extension with region editing and mask processing for image inpainting. (Description by CC)"
|
||||
},
|
||||
{
|
||||
"author": "isam2024",
|
||||
"title": "ComfyUI-FluxHallucinate",
|
||||
"reference": "https://github.com/isam2024/ComfyUI-FluxHallucinate",
|
||||
"files": [
|
||||
"https://github.com/isam2024/ComfyUI-FluxHallucinate"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Intentionally degrade Flux dev.1's prompt adherence to recreate the loose, random, *hallucinatory* feel of SD1.5 / SDXL."
|
||||
},
|
||||
{
|
||||
"author": "Tulut114",
|
||||
"title": "tulut_comfyui_Gadget",
|
||||
@@ -60557,94 +60436,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Copy the shot, not the actors: reference video → depth map, OpenPose skeleton (DWPose, tracked and smoothed) or canny line video for Seedance 2.0/2.5 reference video, MiniMax H3 Fun ControlNet (depth / pose / canny) and Wan VACE. Six nodes: Depth / Pose / Canny as IMAGE→IMAGE and VIDEO→VIDEO with the model presets (fps, frame-size multiples) applied. Apache-2.0."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-Kavel",
|
||||
"id": "comfyui-kavel",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-Kavel",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-Kavel"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images through the kavel.ai API. Works without an API key on the free tier; add a key to use your account's models (Nano Banana 2, GPT Image 2, Seedream)."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-SayMaker",
|
||||
"id": "comfyui-saymaker",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-SayMaker",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-SayMaker"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images and animate them into video through the SayMaker API (Veo 3.1, Kling 3.0, Seedance 2.0, Nano Banana 2, GPT Image 2.5). No local GPU; needs a SayMaker API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-emaki",
|
||||
"id": "comfyui-emaki",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-emaki",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-emaki"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Seedance 2.5 text to video and image to video through the emaki API (Seedance 2.0, MiniMax H3, Veo 3.1 and Nano Banana 2 for first frames too). No local GPU; needs an emaki API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-Veida",
|
||||
"id": "comfyui-veida",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-Veida",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-Veida"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images through the Veida AI API. Works without an API key on the free tier; add a key to use your account's models (GPT Image 2.5, GPT Image 2, Nano Banana 2, Seedream 5.0)."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-FreeImageToVideo",
|
||||
"id": "comfyui-freeimagetovideo",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-FreeImageToVideo",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-FreeImageToVideo"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to video and image to video with sound (MiniMax H3) through the Free Image to Video API: connect any IMAGE as the first frame or leave it empty for text to video; the MP4 is saved to the output folder. No local GPU; needs a Free Image to Video API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-aigifmaker",
|
||||
"id": "comfyui-aigifmaker",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-aigifmaker",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-aigifmaker"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to animated GIF through the AI GIF Maker API (native GIF generation, not a converted video). Outputs every frame as an IMAGE batch plus the saved .gif. No local GPU; needs an AI GIF Maker API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-movoa",
|
||||
"id": "comfyui-movoa",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-movoa",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-movoa"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to video and photo to video with sound via Movoa (movoa.ai). Standard library only; requires a Movoa API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-abvg",
|
||||
"id": "comfyui-abvg",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-abvg",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-abvg"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "AI birthday video generator from a single photo: they pop champagne on a park bench, blow out a Scorpio cake, or light a crown cake at the car window. Generate 12s 720p vertical birthday clips on Seedance 2 Mini via https://aibirthdayvideogenerator.com/."
|
||||
},
|
||||
{
|
||||
"author": "lostmywind",
|
||||
"title": "Workflow Doctor",
|
||||
@@ -60861,6 +60652,16 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Translate image prompts and plain text locally through LM Studio with PLaMo 3 Translate. Supports 53 language choices, side-by-side editors, and automatic splitting for long text."
|
||||
},
|
||||
{
|
||||
"author": "ukr8b3g-cmyk",
|
||||
"title": "Anima Character Sheet Designer",
|
||||
"reference": "https://github.com/ukr8b3g-cmyk/Anima-Character-Sheet-Designer",
|
||||
"files": [
|
||||
"https://github.com/ukr8b3g-cmyk/Anima-Character-Sheet-Designer"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create character sheets in ComfyUI with Anima, using prompt text or local image tags. Generate up to 13 independent views with editable prompts and assemble them into a sheet."
|
||||
},
|
||||
{
|
||||
"author": "D33MO",
|
||||
"title": "ComfyUI Prompt Warehouse",
|
||||
@@ -61916,7 +61717,7 @@
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Suno by Ace Data Cloud",
|
||||
"title": "Suno",
|
||||
"id": "ace-suno",
|
||||
"reference": "https://github.com/AceDataCloud/SunoComfyUI",
|
||||
"files": [
|
||||
@@ -61925,6 +61726,204 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Suno music through your Ace Data Cloud account, query the same task ID, and load completed audio into ComfyUI. Requires an Ace Data Cloud API key; generation consumes Credits. Cloud API only, with no local model or GPU needed."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Ace Chat",
|
||||
"id": "ace-chat",
|
||||
"reference": "https://github.com/AceDataCloud/AceChatComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/AceChatComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "List chat model IDs and send chat messages from a ComfyUI workflow. Requires an Ace Data Cloud API key. Chat requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Face Transform",
|
||||
"id": "face-transform",
|
||||
"reference": "https://github.com/AceDataCloud/FaceTransformComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FaceTransformComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Analyze or transform a face in a supplied image. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Fish Audio",
|
||||
"id": "fish-audio",
|
||||
"reference": "https://github.com/AceDataCloud/FishAudioComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FishAudioComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate speech with Fish Audio and retrieve the resulting audio. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Flux",
|
||||
"id": "flux",
|
||||
"reference": "https://github.com/AceDataCloud/FluxComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FluxComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create images with FLUX through the hosted API. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Google Search",
|
||||
"id": "google-search",
|
||||
"reference": "https://github.com/AceDataCloud/GoogleSearchComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GoogleSearchComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Search Google from a workflow and return structured results. Requires an Ace Data Cloud API key. Searches are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Grok",
|
||||
"id": "grok",
|
||||
"reference": "https://github.com/AceDataCloud/GrokComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GrokComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Grok videos and retrieve the result of a submitted task. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Happy Horse",
|
||||
"id": "happy-horse",
|
||||
"reference": "https://github.com/AceDataCloud/HappyHorseComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/HappyHorseComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit Happy Horse videos and retrieve the original task. Requires an Ace Data Cloud API key. Video requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Kling",
|
||||
"id": "kling",
|
||||
"reference": "https://github.com/AceDataCloud/KlingComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/KlingComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit Kling videos and retrieve task results. Requires an Ace Data Cloud API key. Video requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Midjourney",
|
||||
"id": "midjourney",
|
||||
"reference": "https://github.com/AceDataCloud/MidjourneyComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/MidjourneyComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Midjourney images and retrieve the original task. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "MiniMax H3",
|
||||
"id": "ace-minimax-h3",
|
||||
"reference": "https://github.com/AceDataCloud/MiniMaxH3ComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/MiniMaxH3ComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate MiniMax H3 videos and retrieve task results. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Nano Banana",
|
||||
"id": "nano-banana",
|
||||
"reference": "https://github.com/AceDataCloud/NanoBananaComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/NanoBananaComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit images with Nano Banana and load completed images. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Qwen Image",
|
||||
"id": "qwen-image",
|
||||
"reference": "https://github.com/AceDataCloud/QwenImageComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/QwenImageComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit an image with Qwen Image. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Seedance",
|
||||
"id": "ace-seedance",
|
||||
"reference": "https://github.com/AceDataCloud/SeedanceComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/SeedanceComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate a Seedance video and load the completed video from its task ID. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Seedream",
|
||||
"id": "seedream",
|
||||
"reference": "https://github.com/AceDataCloud/SeedreamComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/SeedreamComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create, edit or decompose images with Seedream. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Veo",
|
||||
"id": "veo",
|
||||
"reference": "https://github.com/AceDataCloud/VeoComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/VeoComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate a Veo video and check its task status. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Wan",
|
||||
"id": "wan",
|
||||
"reference": "https://github.com/AceDataCloud/WanComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/WanComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Wan videos and retrieve task results. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "ACE Music",
|
||||
"id": "ace-acemusic",
|
||||
"reference": "https://github.com/AceDataCloud/ACEMusicComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/ACEMusicComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate ACE Music songs and lyrics, import reference assets, and retrieve results by task ID. Requires an Ace Data Cloud API key. Generation and reference imports are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "GPT Image",
|
||||
"id": "gpt-image",
|
||||
"reference": "https://github.com/AceDataCloud/GPTImageComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GPTImageComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images with GPT Image, retrieve task results, and load the resulting images in ComfyUI. Requires an Ace Data Cloud API key. Generation and editing are metered."
|
||||
},
|
||||
{
|
||||
"author": "NotUsingGithub",
|
||||
"title": "Wan27",
|
||||
@@ -62523,12 +62522,12 @@
|
||||
},
|
||||
{
|
||||
"author": "Statite",
|
||||
"title": "ComfyUI-SpecAR",
|
||||
"title": "ComfyUI-StrideAR",
|
||||
"id": "comfyui-specar",
|
||||
"reference": "https://github.com/statite-ai/ComfyUI-SpecAR",
|
||||
"files": ["https://github.com/statite-ai/ComfyUI-SpecAR"],
|
||||
"reference": "https://github.com/statite-ai/ComfyUI-StrideAR",
|
||||
"files": ["https://github.com/statite-ai/ComfyUI-StrideAR"],
|
||||
"install_type": "git-clone",
|
||||
"description": "SpecAR: Training-free 2.04x-2.81x speedup on Krea Realtime 14B + Self-Forcing 1.3B (up to 23.1 FPS real-time on B200, 2.67x on H100) with lazy target KV caching and low-VRAM offload."
|
||||
"description": "StrideAR: Training-free 2.04x-2.81x speedup on Krea Realtime 14B + Self-Forcing 1.3B (up to 23.1 FPS real-time on B200, 2.67x on H100) with lazy target KV caching and low-VRAM offload."
|
||||
},
|
||||
{
|
||||
"author": "bi-toru-to",
|
||||
@@ -62769,6 +62768,68 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Makeshift helper nodes, mostly for Anima (2B / 2.9B): INT8 quantize on load, 2.9B LoRA remap, Spectrum, SPEED, block compile, guider model tracking, SnapRef."
|
||||
},
|
||||
{
|
||||
"author": "Zrn59",
|
||||
"title": "ComfyUI-GGUF-Next",
|
||||
"id": "comfyui-gguf-next",
|
||||
"reference": "https://github.com/Zrn59/ComfyUI-GGUF-Next",
|
||||
"files": [
|
||||
"https://github.com/Zrn59/ComfyUI-GGUF-Next"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Fork of city96/ComfyUI-GGUF with the same node IDs: all 35 ggml quant types dequantized in torch on the GPU (IQ1/IQ2/IQ3, TQ, MXFP4, NVFP4), any diffusion architecture ComfyUI detects, more text encoders (Gemma 2, Qwen2, Mistral 3, Qwen3-VL incl. 32B, the Gemma 4 encoder of LTX-2.5), and models bigger than RAM kept memory-mapped. Disable the original ComfyUI-GGUF first: both register the same node names."
|
||||
},
|
||||
{
|
||||
"author": "2867297362mjb-sketch",
|
||||
"title": "comfyui-teamorouter",
|
||||
"reference": "https://github.com/2867297362mjb-sketch/comfyui-teamorouter",
|
||||
"files": [
|
||||
"https://github.com/2867297362mjb-sketch/comfyui-teamorouter"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A chat node for the TeamoRouter API: write or expand prompts, caption an input image with a vision model, or translate text with Claude, GPT, Gemini, DeepSeek, GLM, Kimi or Qwen through one OpenAI-compatible API key. You need your own TeamoRouter API key and prepaid balance. No extra dependencies."
|
||||
},
|
||||
{
|
||||
"author": "alaintural",
|
||||
"title": "SyncTile for MiniMax H3",
|
||||
"id": "synctile-h3",
|
||||
"reference": "https://github.com/alaintural/synctile-h3",
|
||||
"files": [
|
||||
"https://github.com/alaintural/synctile-h3"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "SyncTileRefine takes a MiniMax H3 video to 1080p, 2K or 4K on one 24 GB card. Overlapping tiles are blended in latent space after every sampling step, so the result has no seams. A ready workflow is included."
|
||||
},
|
||||
{
|
||||
"author": "bewizsky",
|
||||
"title": "Eyes4AI Text Repair",
|
||||
"reference": "https://github.com/bewizsky/eyes4ai-text-repair",
|
||||
"files": [
|
||||
"https://github.com/bewizsky/eyes4ai-text-repair"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Find misspelled text in photos and AI-generated images with Gemini, then use an image-editing workflow to fix localized text and review spelling and style. Includes check-only and SenseNova U1.6 examples."
|
||||
},
|
||||
{
|
||||
"author": "Raykosan (RaykoStudio)",
|
||||
"title": "ComfyUI-RS_WorkspaceManager",
|
||||
"reference": "https://github.com/Raykosan/ComfyUI-RS_WorkspaceManager",
|
||||
"files": [
|
||||
"https://github.com/Raykosan/ComfyUI-RS_WorkspaceManager"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Workflow Preset Manager and Interface Settings Backup for ComfyUI."
|
||||
},
|
||||
{
|
||||
"author": "assetfeed",
|
||||
"title": "AssetFeed",
|
||||
"reference": "https://github.com/assetfeed/comfyui-assetfeed",
|
||||
"files": [
|
||||
"https://github.com/assetfeed/comfyui-assetfeed"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Nodes for the AssetFeed API: AssetFeed OCR reads the text in an image, and AssetFeed AI Text Check estimates the AI-written share of an English text. Needs an ASSETFEED_API_KEY environment variable; images and text are sent to api.assetfeed.com; data handling is in the README."
|
||||
},
|
||||
{
|
||||
"author": "ntdviet",
|
||||
"title": "ntdviet/comfyui-ext",
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ ComfyUI-Loopchain
|
||||
|
||||
* Detailed Operations
|
||||
* `install`: Installs the specified custom nodes.
|
||||
* `reinstall`: Removes and then reinstalls the specified custom nodes.
|
||||
* `reinstall`: Removes and then reinstalls the specified custom nodes. A nodepack named without a version is reinstalled at the version that is installed.
|
||||
* `uninstall`: Uninstalls the specified custom nodes.
|
||||
* `update`: Updates the specified custom nodes.
|
||||
* `disable`: Disables the specified custom nodes.
|
||||
|
||||
@@ -38,3 +38,13 @@ services:
|
||||
options:
|
||||
max-size: 1m
|
||||
```
|
||||
|
||||
## aria2 on the same machine, without a container
|
||||
|
||||
The Manager asks aria2 to save a file into `/models/...` or `/custom_nodes`. The container above sees the `models` and `custom_nodes` folders of ComfyUI there, through its volumes.
|
||||
|
||||
An aria2 that runs on the same machine as ComfyUI, without a container, sees these folders where ComfyUI sees them. For it, set one more variable. The Manager then gives aria2 each folder as it is.
|
||||
|
||||
```bash
|
||||
export COMFYUI_MANAGER_ARIA2_SAME_PATHS=true
|
||||
```
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ ComfyUI-Loopchain
|
||||
|
||||
* 세부 동작
|
||||
* `install`: 지정된 커스텀 노드들을 설치합니다
|
||||
* `reinstall`: 지정된 커스텀 노드를 삭제하고 재설치 합니다.
|
||||
* `reinstall`: 지정된 커스텀 노드를 삭제하고 재설치 합니다. 버전 없이 이름만 지정하면 설치되어 있는 버전으로 재설치합니다.
|
||||
* `uninstall`: 지정된 커스텀 노드들을 삭제합니다.
|
||||
* `update`: 지정된 커스텀 노드들을 업데이트합니다.
|
||||
* `disable`: 지정된 커스텀 노드들을 비활성화합니다.
|
||||
|
||||
@@ -211,6 +211,7 @@ def read_cnr_info(fullpath):
|
||||
|
||||
project = data.get('project', {})
|
||||
name = project.get('name').strip().lower()
|
||||
original_name = project.get('name')
|
||||
|
||||
# normalize version
|
||||
# for example: 2.5 -> 2.5.0
|
||||
@@ -222,6 +223,7 @@ def read_cnr_info(fullpath):
|
||||
if name and version: # repository is optional
|
||||
return {
|
||||
"id": name,
|
||||
"original_name": original_name,
|
||||
"version": version,
|
||||
"url": repository
|
||||
}
|
||||
|
||||
+118
-146
@@ -46,17 +46,17 @@ import manager_migration
|
||||
from node_package import InstalledNodePackage, InvalidInstallation, is_link
|
||||
|
||||
|
||||
def print(*objects, sep=" ", end="\n", file=None):
|
||||
# rich's print with its highlighting only, so that a path, a URL or an error text is written as it is
|
||||
def print(*objects, sep=" ", end="\n", file=None, style=None):
|
||||
console = rich.get_console() if file is None else Console(file=file)
|
||||
console.print(*objects, sep=sep, end=end, markup=False, emoji=False, soft_wrap=True)
|
||||
console.print(*objects, sep=sep, end=end, style=style, highlight=style is None, markup=False, emoji=False, soft_wrap=True)
|
||||
|
||||
|
||||
version_code = [3, 43, 3]
|
||||
version_code = [3, 44]
|
||||
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
|
||||
DEFAULT_CHANNEL = "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main"
|
||||
DEFAULT_CHANNEL_URLS = {"https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main", "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main"}
|
||||
|
||||
|
||||
default_custom_nodes_path = None
|
||||
@@ -279,26 +279,21 @@ valid_channels = {'default', 'local'}
|
||||
channel_list = None
|
||||
|
||||
|
||||
def remap_pip_package(pkg):
|
||||
if pkg in cm_global.pip_overrides:
|
||||
res = cm_global.pip_overrides[pkg]
|
||||
print(f"[ComfyUI-Manager] '{pkg}' is remapped to '{res}'")
|
||||
return res
|
||||
else:
|
||||
return pkg
|
||||
|
||||
|
||||
def is_blacklisted(name):
|
||||
return manager_util.pip_block_reason(name, cm_global.pip_blacklist, cm_global.pip_downgrade_blacklist) is not None
|
||||
|
||||
|
||||
def normalize_channel_url(url):
|
||||
return DEFAULT_CHANNEL if url in DEFAULT_CHANNEL_URLS else url
|
||||
|
||||
|
||||
def normalize_channel(channel):
|
||||
if channel == 'local':
|
||||
return channel
|
||||
elif channel is None:
|
||||
return None
|
||||
elif channel.startswith('https://'):
|
||||
return channel
|
||||
return normalize_channel_url(channel)
|
||||
elif channel.startswith('http://') and get_config()['http_channel_enabled'] == True:
|
||||
return channel
|
||||
|
||||
@@ -476,11 +471,12 @@ class UnifiedManager:
|
||||
|
||||
if latest is not None:
|
||||
version_spec = str(latest[0])
|
||||
elif node_name in self.nightly_inactive_nodes:
|
||||
version_spec = "nightly"
|
||||
elif node_name in self.unknown_inactive_nodes:
|
||||
version_spec = "unknown"
|
||||
else:
|
||||
if node_name in self.nightly_inactive_nodes:
|
||||
version_spec = "nightly"
|
||||
else:
|
||||
version_spec = "unknown"
|
||||
return None
|
||||
|
||||
elif node_name in self.unknown_inactive_nodes:
|
||||
version_spec = "unknown"
|
||||
@@ -518,7 +514,8 @@ class UnifiedManager:
|
||||
|
||||
spec = node_name.split('@')
|
||||
|
||||
if len(spec) == 2:
|
||||
# 'latest' names no installed version: with a guess mode the installed one is guessed, as for a bare name
|
||||
if len(spec) == 2 and (spec[1] != 'latest' or guess_mode is None):
|
||||
node_name = spec[0]
|
||||
version_spec = spec[1]
|
||||
|
||||
@@ -529,6 +526,11 @@ class UnifiedManager:
|
||||
else:
|
||||
version_spec = self.cnr_map[node_name]['latest_version']['version']
|
||||
|
||||
if guess_mode == 'active' and not self.is_enabled(node_name, version_spec):
|
||||
return None
|
||||
elif guess_mode == 'inactive' and not self.is_disabled(node_name, version_spec):
|
||||
return None
|
||||
|
||||
elif guess_mode in ['active', 'inactive']:
|
||||
node_name = spec[0]
|
||||
version_spec = self.resolve_unspecified_version(node_name, guess_mode=guess_mode)
|
||||
@@ -645,6 +647,12 @@ class UnifiedManager:
|
||||
for folder in folders:
|
||||
self.invalid_installations.pop(folder, None)
|
||||
|
||||
def forget_gone_disabled_versions_if_one_is_left(self, node_id):
|
||||
disabled = self.cnr_inactive_nodes.get(node_id, {})
|
||||
gone = [x for x in disabled.values() if not os.path.exists(x)]
|
||||
if len(gone) < len(disabled):
|
||||
self.forget_folders(gone)
|
||||
|
||||
def move_invalid_installation(self, from_path, to_path, enabled):
|
||||
x = self.invalid_installations.pop(from_path, None)
|
||||
if x is not None:
|
||||
@@ -705,8 +713,12 @@ class UnifiedManager:
|
||||
elif node_id in self.unknown_inactive_nodes:
|
||||
return True
|
||||
|
||||
# cnr_inactive_nodes holds a version -> path dict; comparing the dict
|
||||
# to version_spec (None here) is always False, so a disabled CNR pack
|
||||
# looked active and enable never restored it. Any non-nightly inactive
|
||||
# version counts, mirroring the explicit "cnr" branch above.
|
||||
target = self.cnr_inactive_nodes.get(node_id, None)
|
||||
if target is not None and target == version_spec:
|
||||
if target and any(ver != 'nightly' for ver in target.keys()):
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -749,13 +761,8 @@ class UnifiedManager:
|
||||
|
||||
latest = None
|
||||
for k, v in ver_map.items():
|
||||
if latest is None:
|
||||
latest = self.safe_version(k), v
|
||||
continue
|
||||
|
||||
cur_ver = self.safe_version(k)
|
||||
if cur_ver > latest[0]:
|
||||
latest = cur_ver, v
|
||||
if latest is None or self.safe_version(k) > self.safe_version(latest[0]):
|
||||
latest = k, v
|
||||
|
||||
return latest
|
||||
|
||||
@@ -899,12 +906,14 @@ class UnifiedManager:
|
||||
# a fix is held back by what the same fix has done, and not by an install or another fix of the session
|
||||
done = self.processed_install if fixed is None else fixed
|
||||
for line in lines:
|
||||
package_name = remap_pip_package(line.strip())
|
||||
if package_name and not package_name.startswith('#') and package_name not in done:
|
||||
clean_package_name = package_name.split('#')[0].strip()
|
||||
install_cmd = manager_util.make_pip_cmd(["install", clean_package_name]) if fixed is None else manager_util.fix_cmd(clean_package_name)
|
||||
if clean_package_name != "" and not clean_package_name.startswith('#'):
|
||||
res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||
install_args = manager_util.pip_install_args(line, cm_global.pip_overrides)
|
||||
package_name = ' '.join(install_args)
|
||||
names_a_path = any(os.path.exists(os.path.join(repo_path, re.split(r'[\[;]', arg)[0].strip())) for arg in install_args)
|
||||
if names_a_path:
|
||||
package_name = f'{repo_path}: {package_name}'
|
||||
if install_args and package_name not in done:
|
||||
install_cmd = manager_util.make_pip_cmd(["install", *install_args]) if fixed is None else manager_util.fix_cmd(install_args)
|
||||
res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||
if res:
|
||||
self.processed_install.add(package_name)
|
||||
done.add(package_name)
|
||||
@@ -1041,6 +1050,22 @@ class UnifiedManager:
|
||||
|
||||
return result
|
||||
|
||||
def disable_for_replacement(self, node_id, to_path):
|
||||
"""
|
||||
Disable the enabled version of node_id, for another version that goes to to_path.
|
||||
Fails with nothing changed when anything but the folder of the enabled version is at to_path.
|
||||
"""
|
||||
result = ManagedResult('disable')
|
||||
enabled = self.active_nodes.get(node_id)
|
||||
on_disk = enabled is not None and os.path.exists(enabled[1])
|
||||
if os.path.lexists(to_path) and not (on_disk and os.path.samestat(os.lstat(enabled[1]), os.lstat(to_path))):
|
||||
return result.fail(f'Destination already exists: {to_path}')
|
||||
|
||||
if on_disk:
|
||||
return self.unified_disable(node_id, False)
|
||||
|
||||
return result
|
||||
|
||||
def unified_enable(self, node_id: str, version_spec=None):
|
||||
"""
|
||||
priority if version_spec == None
|
||||
@@ -1058,7 +1083,7 @@ class UnifiedManager:
|
||||
|
||||
if version_spec is None:
|
||||
version_spec = self.resolve_unspecified_version(node_id, guess_mode='inactive')
|
||||
if version is None:
|
||||
if version_spec is None and not self.is_enabled(node_id):
|
||||
return result.fail(f'Specified inactive node not exists: {node_id}')
|
||||
|
||||
if self.is_enabled(node_id, version_spec):
|
||||
@@ -1079,14 +1104,12 @@ class UnifiedManager:
|
||||
base_path = extract_base_custom_nodes_dir(from_path)
|
||||
to_path = os.path.join(base_path, node_id)
|
||||
elif version_spec == 'nightly':
|
||||
self.unified_disable(node_id, False)
|
||||
from_path = self.nightly_inactive_nodes.get(node_id)
|
||||
if from_path is None:
|
||||
return result.fail(f'Specified inactive node not exists: {node_id}@nightly')
|
||||
base_path = extract_base_custom_nodes_dir(from_path)
|
||||
to_path = os.path.join(base_path, node_id)
|
||||
elif version_spec is not None:
|
||||
self.unified_disable(node_id, False)
|
||||
cnr_info = self.cnr_inactive_nodes.get(node_id)
|
||||
|
||||
if cnr_info is None or len(cnr_info) == 0:
|
||||
@@ -1105,6 +1128,14 @@ class UnifiedManager:
|
||||
if from_path is None or not os.path.exists(from_path):
|
||||
return result.fail(f'Specified inactive node path not exists: {from_path}')
|
||||
|
||||
if version_spec == 'unknown':
|
||||
if os.path.lexists(to_path):
|
||||
return result.fail(f'Destination already exists: {to_path}')
|
||||
else:
|
||||
res = self.disable_for_replacement(node_id, to_path)
|
||||
if not res.result:
|
||||
return res
|
||||
|
||||
# move from disk
|
||||
shutil.move(from_path, to_path)
|
||||
|
||||
@@ -1147,6 +1178,8 @@ class UnifiedManager:
|
||||
|
||||
base_path = extract_base_custom_nodes_dir(repo_and_path[1])
|
||||
to_path = os.path.join(base_path, '.disabled', node_id)
|
||||
if os.path.lexists(to_path):
|
||||
return result.fail(f'Destination already exists: {to_path}')
|
||||
|
||||
shutil.move(repo_and_path[1], to_path)
|
||||
result.append((repo_and_path[1], to_path))
|
||||
@@ -1166,6 +1199,9 @@ class UnifiedManager:
|
||||
|
||||
# NOTE: A disabled node may have multiple versions, so preserve it using the `@ suffix`.
|
||||
to_path = os.path.join(base_path, '.disabled', f"{node_id}@{ver_and_path[0].replace('.', '_')}")
|
||||
if os.path.lexists(to_path):
|
||||
return result.fail(f'Destination already exists: {to_path}')
|
||||
|
||||
shutil.move(ver_and_path[1], to_path)
|
||||
result.append((ver_and_path[1], to_path))
|
||||
|
||||
@@ -1289,7 +1325,11 @@ class UnifiedManager:
|
||||
if os.path.exists(install_path):
|
||||
return result.fail(f'Install path already exists: {install_path}')
|
||||
|
||||
manager_downloader.download_url(node_info.download_url, get_default_custom_nodes_path(), archive_name)
|
||||
try:
|
||||
manager_downloader.download_url(node_info.download_url, get_default_custom_nodes_path(), archive_name)
|
||||
except Exception:
|
||||
manager_downloader.remove_failed_download(get_default_custom_nodes_path(), archive_name)
|
||||
raise
|
||||
os.makedirs(install_path, exist_ok=True)
|
||||
try:
|
||||
extracted = manager_util.extract_package_as_zip(download_path, install_path)
|
||||
@@ -1498,6 +1538,8 @@ class UnifiedManager:
|
||||
|
||||
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)
|
||||
if self.is_enabled(node_id):
|
||||
return ManagedResult('skip')
|
||||
elif self.is_disabled(node_id):
|
||||
@@ -1532,22 +1574,26 @@ class UnifiedManager:
|
||||
return ManagedResult('install-cnr').fail(f'not available node: {node_id}@{version_spec}')
|
||||
version_spec = node_info.version
|
||||
|
||||
if self.is_enabled(node_id, 'nightly'):
|
||||
# disable nightly nodes
|
||||
self.unified_disable(node_id, False) # NOTE: don't return from here
|
||||
|
||||
if self.is_disabled(node_id, version_spec):
|
||||
# enable and return if specified version is disabled
|
||||
return self.unified_enable(node_id, version_spec)
|
||||
|
||||
if self.is_disabled(node_id, "cnr"):
|
||||
# enable and switch version if cnr is disabled (not specified version)
|
||||
self.unified_enable(node_id, "cnr")
|
||||
res = self.unified_enable(node_id, "cnr")
|
||||
if not res.result:
|
||||
return res
|
||||
return self._cnr_switch_version(node_id, node_info, instant_execution, no_deps, return_postinstall)
|
||||
|
||||
if self.is_enabled(node_id, "cnr"):
|
||||
return self._cnr_switch_version(node_id, node_info, instant_execution, no_deps, return_postinstall)
|
||||
|
||||
if self.is_enabled(node_id, 'nightly'):
|
||||
# disable nightly nodes
|
||||
res = self.disable_for_replacement(node_id, os.path.join(get_default_custom_nodes_path(), node_id))
|
||||
if not res.result:
|
||||
return res
|
||||
|
||||
res = self._cnr_install(node_id, node_info, instant_execution, no_deps, return_postinstall)
|
||||
if res.result:
|
||||
self.active_nodes[node_id] = version_spec, res.to_path
|
||||
@@ -1570,7 +1616,9 @@ class UnifiedManager:
|
||||
if version_spec == 'nightly':
|
||||
# disable cnr nodes
|
||||
if self.is_enabled(node_id, 'cnr'):
|
||||
self.unified_disable(node_id, False)
|
||||
res = self.disable_for_replacement(node_id, to_path)
|
||||
if not res.result:
|
||||
return res
|
||||
|
||||
res = self.repo_install(repo_url, to_path, instant_execution=instant_execution, no_deps=no_deps, return_postinstall=return_postinstall)
|
||||
if res.result:
|
||||
@@ -1671,7 +1719,7 @@ def identify_node_pack_from_path(fullpath):
|
||||
# cnr
|
||||
cnr = cnr_utils.read_cnr_info(fullpath)
|
||||
if cnr is not None:
|
||||
return module_name, cnr['version'], cnr['id'], None
|
||||
return module_name, cnr['version'], cnr['original_name'], None
|
||||
|
||||
return None
|
||||
else:
|
||||
@@ -1847,8 +1895,9 @@ def get_channel_dict():
|
||||
for x in channels.split('\n'):
|
||||
channel_info = x.split("::")
|
||||
if len(channel_info) == 2:
|
||||
channel_dict[channel_info[0]] = channel_info[1]
|
||||
valid_channels.add(channel_info[1])
|
||||
channel_url = normalize_channel_url(channel_info[1])
|
||||
channel_dict[channel_info[0]] = channel_url
|
||||
valid_channels.add(channel_url)
|
||||
|
||||
return channel_dict
|
||||
|
||||
@@ -2073,7 +2122,7 @@ def read_config():
|
||||
# read as written: a path of Windows may hold a `%`, which the parser takes as the start of a reference
|
||||
'git_exe': default_conf.get('git_exe', '', raw=True),
|
||||
'use_uv': get_bool('use_uv', False),
|
||||
'channel_url': default_conf.get('channel_url', DEFAULT_CHANNEL),
|
||||
'channel_url': normalize_channel_url(default_conf.get('channel_url', DEFAULT_CHANNEL)),
|
||||
'default_cache_as_channel_url': get_bool('default_cache_as_channel_url', False),
|
||||
'share_option': default_conf.get('share_option', 'all').lower(),
|
||||
'bypass_ssl': get_bool('bypass_ssl', False),
|
||||
@@ -2318,27 +2367,10 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
if os.path.exists(requirements_path) and not no_deps:
|
||||
print("Install: pip packages")
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, manager_files_path if manager_migration.has_system_user_api() else None)
|
||||
with open(requirements_path, "r") as requirements_file:
|
||||
for line in requirements_file:
|
||||
#handle comments
|
||||
if '#' in line:
|
||||
if line.strip()[0] == '#':
|
||||
print("Line is comment...skipping")
|
||||
continue
|
||||
else:
|
||||
line = line.split('#')[0].strip()
|
||||
|
||||
package_name = remap_pip_package(line.strip())
|
||||
|
||||
if package_name and not package_name.startswith('#'):
|
||||
if '--index-url' in package_name:
|
||||
s = package_name.split('--index-url')
|
||||
install_cmd = manager_util.make_pip_cmd(["install", s[0].strip(), '--index-url', s[1].strip()])
|
||||
else:
|
||||
install_cmd = manager_util.make_pip_cmd(["install", package_name])
|
||||
|
||||
if package_name.strip() != "" and not package_name.startswith('#'):
|
||||
try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||
for line in manager_util.read_requirements_lines(requirements_path):
|
||||
install_args = manager_util.pip_install_args(line, cm_global.pip_overrides)
|
||||
if install_args:
|
||||
try_install_script(url, repo_path, manager_util.make_pip_cmd(["install", *install_args]), instant_execution=instant_execution)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
if os.path.exists(install_script_path):
|
||||
@@ -2570,19 +2602,14 @@ def git_pull(path):
|
||||
|
||||
|
||||
async def get_data_by_mode(mode, filename, channel_url=None):
|
||||
if channel_url in get_channel_dict():
|
||||
channel_url = get_channel_dict()[channel_url]
|
||||
|
||||
try:
|
||||
local_uri = os.path.join(manager_util.comfyui_manager_path, filename)
|
||||
|
||||
if mode == "local":
|
||||
json_obj = await manager_util.get_data(local_uri)
|
||||
else:
|
||||
if channel_url is None:
|
||||
uri = get_config()['channel_url'] + '/' + filename
|
||||
else:
|
||||
uri = channel_url + '/' + filename
|
||||
channel_url = normalize_channel(channel_url) or get_config()['channel_url']
|
||||
uri = channel_url + '/' + filename
|
||||
|
||||
cache_uri = str(manager_util.simple_hash(uri))+'_'+filename
|
||||
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
|
||||
@@ -2710,70 +2737,6 @@ def gitclone_uninstall(files):
|
||||
return True
|
||||
|
||||
|
||||
def gitclone_set_active(files, is_disable):
|
||||
import os
|
||||
|
||||
if is_disable:
|
||||
action_name = "Disable"
|
||||
else:
|
||||
action_name = "Enable"
|
||||
|
||||
print(f"{action_name}: {files}")
|
||||
for url in files:
|
||||
if url.endswith("/"):
|
||||
url = url[:-1]
|
||||
try:
|
||||
for custom_nodes_dir in get_custom_nodes_paths():
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_dir, dir_name)
|
||||
|
||||
# safety check
|
||||
if dir_path == '/' or dir_path[1:] == ":/" or dir_path == '':
|
||||
print(f"{action_name}(git-clone) error: invalid path '{dir_path}' for '{url}'")
|
||||
return False
|
||||
|
||||
if is_disable:
|
||||
current_path = dir_path
|
||||
base_path = extract_base_custom_nodes_dir(current_path)
|
||||
new_path = os.path.join(base_path, ".disabled", dir_name)
|
||||
|
||||
if not os.path.exists(current_path):
|
||||
continue
|
||||
else:
|
||||
current_path1 = os.path.join(get_default_custom_nodes_path(), ".disabled", dir_name)
|
||||
current_path2 = dir_path + ".disabled"
|
||||
|
||||
if os.path.exists(current_path1):
|
||||
current_path = current_path1
|
||||
elif os.path.exists(current_path2):
|
||||
current_path = current_path2
|
||||
else:
|
||||
continue
|
||||
|
||||
base_path = extract_base_custom_nodes_dir(current_path)
|
||||
new_path = os.path.join(base_path, dir_name)
|
||||
|
||||
shutil.move(current_path, new_path)
|
||||
|
||||
if is_disable:
|
||||
if os.path.exists(os.path.join(new_path, "disable.py")):
|
||||
disable_script = [sys.executable, "disable.py"]
|
||||
try_install_script(url, new_path, disable_script)
|
||||
else:
|
||||
if os.path.exists(os.path.join(new_path, "enable.py")):
|
||||
enable_script = [sys.executable, "enable.py"]
|
||||
try_install_script(url, new_path, enable_script)
|
||||
|
||||
break # for safety
|
||||
|
||||
except Exception as e:
|
||||
print(f"{action_name}(git-clone) error: {url} / {e}", file=sys.stderr)
|
||||
return False
|
||||
|
||||
print(f"{action_name} was successful.")
|
||||
return True
|
||||
|
||||
|
||||
def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefix="", no_deps=False):
|
||||
import os
|
||||
|
||||
@@ -2943,11 +2906,11 @@ def lookup_installed_custom_nodes_legacy(repo_name):
|
||||
|
||||
|
||||
def simple_check_custom_node(url):
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(get_default_custom_nodes_path(), dir_name)
|
||||
if os.path.exists(dir_path):
|
||||
cnr = unified_manager.get_cnr_by_repo(url)
|
||||
node_id = cnr['id'] if cnr else unknown_node_id(url)
|
||||
if unified_manager.is_enabled(node_id):
|
||||
return 'installed'
|
||||
elif os.path.exists(dir_path+'.disabled'):
|
||||
elif unified_manager.installed_folders_of(node_id):
|
||||
return 'disabled'
|
||||
|
||||
return 'not-installed'
|
||||
@@ -3047,6 +3010,9 @@ async def get_current_snapshot(custom_nodes_only = False):
|
||||
else:
|
||||
commit_hash = git_utils.get_commit_hash(fullpath)
|
||||
url = git_utils.git_url(fullpath)
|
||||
# of two clones of a repository, the enabled one is what a restore brings back
|
||||
if is_disabled and url in git_custom_nodes:
|
||||
continue
|
||||
git_custom_nodes[url] = dict(hash=commit_hash, disabled=is_disabled)
|
||||
except:
|
||||
print(f"Failed to extract snapshots for the custom node '{path}'.")
|
||||
@@ -3344,8 +3310,8 @@ async def get_unified_total_nodes(channel, mode, regsitry_cache_mode='cache'):
|
||||
if cnr_id in unified_manager.active_nodes:
|
||||
# installed
|
||||
state = 'enabled'
|
||||
updatable = unified_manager.is_updatable(cnr_id)
|
||||
active_version = unified_manager.active_nodes[cnr['id']][0]
|
||||
updatable = active_version != 'nightly' and unified_manager.is_updatable(cnr_id)
|
||||
ver = active_version
|
||||
|
||||
if cm_global.try_call(api="cm.is_import_failed_extension", name=unified_manager.active_nodes[cnr_id][1]):
|
||||
@@ -3368,6 +3334,8 @@ async def get_unified_total_nodes(channel, mode, regsitry_cache_mode='cache'):
|
||||
item = dict(author=author, title=title, reference=reference, repository=repository, install_type=install_type,
|
||||
description=description, state=state, updatable=updatable, version=ver)
|
||||
|
||||
item['update-state'] = 'true' if updatable else 'false'
|
||||
|
||||
if active_version:
|
||||
item['active_version'] = active_version
|
||||
|
||||
@@ -3536,10 +3504,14 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
|
||||
|
||||
norm_k = git_utils.normalize_url(k)
|
||||
|
||||
# a node pack saved at a version of the registry has the clone it keeps disabled as a git entry
|
||||
# a clone saved as disabled is left out: the restore then disables it, leaves it disabled or does not clone it.
|
||||
# A nodepack saved at a version of the registry has such a clone, which is restored when that version could not be
|
||||
cnr = unified_manager.repo_cnr_map.get(norm_k)
|
||||
version = (cnr_info or {}).get(cnr['id']) if cnr is not None else None
|
||||
if version is not None and unified_manager.is_enabled(cnr['id'], 'cnr') and f"{cnr['id']}@{version}" not in failed:
|
||||
if version is None:
|
||||
if v.get('disabled'):
|
||||
continue
|
||||
elif unified_manager.is_enabled(cnr['id'], 'cnr') and f"{cnr['id']}@{version}" not in failed:
|
||||
continue
|
||||
|
||||
git_info[norm_k] = v
|
||||
|
||||
@@ -80,17 +80,26 @@ def aria2_download_url(model_url: str, model_dir: str, filename: str):
|
||||
import tqdm
|
||||
import time
|
||||
|
||||
if model_dir.startswith(core.comfy_path):
|
||||
model_dir = model_dir[len(core.comfy_path) :]
|
||||
local_path = os.path.join(model_dir, filename)
|
||||
|
||||
download_dir = model_dir if model_dir.startswith('/') else os.path.join('/models', model_dir)
|
||||
same_paths = os.environ.get('COMFYUI_MANAGER_ARIA2_SAME_PATHS', '').lower() == 'true'
|
||||
|
||||
if not same_paths and model_dir.startswith(core.comfy_path):
|
||||
rel = model_dir[len(core.comfy_path):]
|
||||
download_dir = rel if rel.startswith('/') else os.path.join('/models', rel)
|
||||
elif os.path.isabs(model_dir):
|
||||
download_dir = model_dir
|
||||
else:
|
||||
download_dir = os.path.join('/models', model_dir)
|
||||
|
||||
download = aria2_find_task(download_dir, filename)
|
||||
if download is None:
|
||||
if download is not None and download.is_complete and os.path.exists(local_path):
|
||||
return
|
||||
if download is None or not (download.is_active or download.is_waiting):
|
||||
options = {'dir': download_dir, 'out': filename}
|
||||
download = aria2.add(model_url, options)[0]
|
||||
|
||||
if download.is_active:
|
||||
if download.is_active or download.is_waiting:
|
||||
with tqdm.tqdm(
|
||||
total=download.total_length,
|
||||
bar_format='{l_bar}{bar}{r_bar}',
|
||||
@@ -98,13 +107,27 @@ def aria2_download_url(model_url: str, model_dir: str, filename: str):
|
||||
unit='B',
|
||||
unit_scale=True,
|
||||
) as progress_bar:
|
||||
while download.is_active:
|
||||
while download.is_active or download.is_waiting:
|
||||
if progress_bar.total == 0 and download.total_length != 0:
|
||||
progress_bar.reset(download.total_length)
|
||||
progress_bar.update(download.completed_length - progress_bar.n)
|
||||
time.sleep(1)
|
||||
download.update()
|
||||
|
||||
if not download.is_complete:
|
||||
raise Exception(f"aria2 failed to download '{model_url}' into '{download_dir}': {download.error_message or download.status}")
|
||||
if not os.path.exists(local_path):
|
||||
raise Exception(f"aria2 saved '{filename}' into its '{download_dir}', but the file is not at '{local_path}'. "
|
||||
"See docs/en/use_aria2.md for where aria2 must see the folders of ComfyUI.")
|
||||
|
||||
|
||||
def remove_failed_download(model_dir: str, filename: str):
|
||||
for name in (filename, filename + '.aria2'):
|
||||
try:
|
||||
os.remove(os.path.join(model_dir, name))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def download_url_with_agent(url, save_path):
|
||||
try:
|
||||
|
||||
+95
-48
@@ -143,7 +143,7 @@ def is_allowed_security_level(level):
|
||||
|
||||
async def get_risky_level(files, pip_packages):
|
||||
json_data1 = await core.get_data_by_mode('local', 'custom-node-list.json')
|
||||
json_data2 = await core.get_data_by_mode('cache', 'custom-node-list.json', channel_url='https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main')
|
||||
json_data2 = await core.get_data_by_mode('cache', 'custom-node-list.json', channel_url=core.DEFAULT_CHANNEL)
|
||||
|
||||
all_urls = set()
|
||||
for x in json_data1['custom_nodes'] + json_data2['custom_nodes']:
|
||||
@@ -207,7 +207,6 @@ core.comfy_path = os.path.dirname(folder_paths.__file__)
|
||||
core.js_path = os.path.join(core.comfy_path, "web", "extensions")
|
||||
|
||||
local_db_model = os.path.join(manager_util.comfyui_manager_path, "model-list.json")
|
||||
local_db_alter = os.path.join(manager_util.comfyui_manager_path, "alter-list.json")
|
||||
local_db_custom_node_list = os.path.join(manager_util.comfyui_manager_path, "custom-node-list.json")
|
||||
local_db_extension_node_mappings = os.path.join(manager_util.comfyui_manager_path, "extension-node-map.json")
|
||||
|
||||
@@ -598,9 +597,10 @@ async def task_worker():
|
||||
try:
|
||||
res = core.unified_manager.unified_disable(node_name, is_unknown)
|
||||
|
||||
if res:
|
||||
if res.result:
|
||||
return 'success'
|
||||
|
||||
logging.error(f"[ComfyUI-Manager] Failed to disable '{node_name}': {res.msg}")
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
@@ -781,6 +781,75 @@ async def fetch_updates(request):
|
||||
status=410,
|
||||
)
|
||||
|
||||
def collect_node_types_in_graph(graph, subgraph_definitions, node_set, workflow_file_path, visited_subgraph_ids):
|
||||
"""
|
||||
collect the node type info of a single graph (the root workflow, or a subgraph definition)
|
||||
into node_set, recursing into any subgraph that the graph instantiates
|
||||
"""
|
||||
# a subgraph definition can carry its own nested definitions - register them before walking the nodes
|
||||
nested_definitions = graph.get("definitions")
|
||||
if isinstance(nested_definitions, dict):
|
||||
nested_subgraphs = nested_definitions.get("subgraphs")
|
||||
if isinstance(nested_subgraphs, list):
|
||||
for subgraph in nested_subgraphs:
|
||||
if isinstance(subgraph, dict) and "id" in subgraph:
|
||||
subgraph_definitions.setdefault(subgraph["id"], subgraph)
|
||||
|
||||
nodes = graph.get("nodes")
|
||||
if not isinstance(nodes, list):
|
||||
logging.warning(f"{workflow_file_path} has a malformed 'nodes' value - skipping this graph")
|
||||
return
|
||||
|
||||
for node in nodes:
|
||||
# a malformed entry shouldn't take the whole workflow down with it
|
||||
if not isinstance(node, dict):
|
||||
logging.warning(f"Found a non-object node in {workflow_file_path} - skipping it")
|
||||
continue
|
||||
if "id" not in node:
|
||||
logging.warning("Found a node with no ID - possibly corrupt/invalid workflow?")
|
||||
continue
|
||||
# if there's no type, throw a warning
|
||||
if "type" not in node:
|
||||
logging.warning(f"Node type not found in {workflow_file_path} for node ID {node['id']}")
|
||||
# skip to next node
|
||||
continue
|
||||
|
||||
node_type = node["type"]
|
||||
# an unhashable type (list/dict) would blow up the subgraph lookup below, and any
|
||||
# non-string is junk in the report either way
|
||||
if not isinstance(node_type, str):
|
||||
logging.warning(f"Node {node['id']} has a non-string type in {workflow_file_path} - skipping it")
|
||||
continue
|
||||
|
||||
# a node whose type is a subgraph id is an instance of that subgraph, not a real node type:
|
||||
# descend into the definition instead of reporting the (meaningless) subgraph uuid
|
||||
if node_type in subgraph_definitions:
|
||||
# guard against a subgraph that (directly or indirectly) instantiates itself
|
||||
if node_type not in visited_subgraph_ids:
|
||||
visited_subgraph_ids.add(node_type)
|
||||
collect_node_types_in_graph(subgraph_definitions[node_type], subgraph_definitions, node_set,
|
||||
workflow_file_path, visited_subgraph_ids)
|
||||
continue
|
||||
|
||||
node_data_to_return = {"type": node_type}
|
||||
properties = node.get("properties")
|
||||
if not isinstance(properties, dict):
|
||||
logging.warning(f"Node {node['id']} has no properties field - can't determine cnr_id")
|
||||
else:
|
||||
for property_key in ["cnr_id", "ver"]:
|
||||
if property_key in properties:
|
||||
# a non-string cnr_id reaches findPackageByCnrId on the client, where
|
||||
# cnrId.toLowerCase() throws and takes the whole usage analysis with it
|
||||
if property_key == "cnr_id" and not isinstance(properties[property_key], str):
|
||||
logging.warning(f"Node {node['id']} has a non-string cnr_id in {workflow_file_path} - ignoring it")
|
||||
continue
|
||||
node_data_to_return[property_key] = properties[property_key]
|
||||
|
||||
# add it to the list for this workflow
|
||||
if not node_data_to_return in node_set:
|
||||
node_set.append(node_data_to_return)
|
||||
|
||||
|
||||
@routes.get("/customnode/get_node_types_in_workflows")
|
||||
async def get_node_types_in_workflows(request):
|
||||
try:
|
||||
@@ -796,7 +865,7 @@ async def get_node_types_in_workflows(request):
|
||||
if not os.path.isdir(workflow_files_base_path):
|
||||
logging.debug("workflows base path doesn't exist - nothing to do...")
|
||||
return web.Response(status=204)
|
||||
|
||||
|
||||
# get all JSON files under the workflow directory
|
||||
workflow_file_relative_paths: list[str] = glob.glob(pathname="**/*.json", root_dir=workflow_files_base_path, recursive=True)
|
||||
|
||||
@@ -812,7 +881,8 @@ async def get_node_types_in_workflows(request):
|
||||
workflow_file_absolute_path = os.path.abspath(os.path.join(workflow_files_base_path, workflow_file_path))
|
||||
logging.debug(f"starting work on {workflow_file_absolute_path}")
|
||||
# load the JSON file
|
||||
workflow_file_data = json.load(open(workflow_file_absolute_path, "r", encoding="utf-8-sig"))
|
||||
with open(workflow_file_absolute_path, "r", encoding="utf-8-sig") as workflow_file:
|
||||
workflow_file_data = json.load(workflow_file)
|
||||
|
||||
# make sure there's a nodes key (otherwise this might not actually be a workflow file)
|
||||
if "nodes" not in workflow_file_data:
|
||||
@@ -825,38 +895,26 @@ async def get_node_types_in_workflows(request):
|
||||
# we can't use an actual set, because you can't use dicts as set members
|
||||
node_set = []
|
||||
|
||||
# iterate over each node in the workflow
|
||||
for node in workflow_file_data["nodes"]:
|
||||
if "id" not in node:
|
||||
logging.warning("Found a node with no ID - possibly corrupt/invalid workflow?")
|
||||
continue
|
||||
# if there's no type, throw a warning
|
||||
if "type" not in node:
|
||||
logging.warning(f"Node type not found in {workflow_file_path} for node ID {node['id']}")
|
||||
# skip to next node
|
||||
continue
|
||||
# subgraph definitions are stored flat at the root of the workflow, keyed by their uuid;
|
||||
# nodes inside them never appear in the root "nodes" list, so they have to be walked separately
|
||||
subgraph_definitions = {}
|
||||
definitions = workflow_file_data.get("definitions")
|
||||
if isinstance(definitions, dict):
|
||||
for subgraph in definitions.get("subgraphs", []):
|
||||
if isinstance(subgraph, dict) and "id" in subgraph:
|
||||
subgraph_definitions[subgraph["id"]] = subgraph
|
||||
|
||||
node_data_to_return = {"type": node["type"]}
|
||||
if "properties" not in node:
|
||||
logging.warning(f"Node ${node['id']} has no properties field - can't determine cnr_id")
|
||||
else:
|
||||
for property_key in ["cnr_id", "ver"]:
|
||||
if property_key in node["properties"]:
|
||||
node_data_to_return[property_key] = node["properties"][property_key]
|
||||
|
||||
# add it to the list for this workflow
|
||||
if not node_data_to_return in node_set:
|
||||
node_set.append(node_data_to_return)
|
||||
collect_node_types_in_graph(workflow_file_data, subgraph_definitions, node_set,
|
||||
workflow_file_path, set())
|
||||
|
||||
# annoyingly, Python can't serialize sets to JSON
|
||||
new_mapping["node_types"] = list(node_set)
|
||||
workflow_node_mappings.append(new_mapping)
|
||||
workflow_node_mappings.append(new_mapping)
|
||||
|
||||
except Exception as e:
|
||||
logging.warning(f"Couldn't open {workflow_file_path}: {e}")
|
||||
|
||||
return web.json_response(workflow_node_mappings, content_type='application/json')
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return web.Response(status=500)
|
||||
@@ -1097,21 +1155,6 @@ async def fetch_customnode_list(request):
|
||||
return web.json_response(result, content_type='application/json')
|
||||
|
||||
|
||||
@routes.get("/customnode/alternatives")
|
||||
async def fetch_customnode_alternatives(request):
|
||||
alter_json = await core.get_data_by_mode(request.rel_url.query["mode"], 'alter-list.json')
|
||||
|
||||
res = {}
|
||||
|
||||
for item in alter_json['items']:
|
||||
populate_markdown(item)
|
||||
res[item['id']] = item
|
||||
|
||||
res = core.map_to_unified_keys(res)
|
||||
|
||||
return web.json_response(res, content_type='application/json')
|
||||
|
||||
|
||||
def check_model_installed(json_obj):
|
||||
def is_exists(model_dir_name, filename, url):
|
||||
if filename == '<huggingface>':
|
||||
@@ -1160,8 +1203,10 @@ def check_model_installed(json_obj):
|
||||
filename = item['filename']
|
||||
|
||||
fullpath = os.path.join(folder_paths.models_dir, item['save_path'], filename)
|
||||
subpath = os.path.join(item['save_path'].partition('/')[2], filename)
|
||||
found = os.path.exists(fullpath) or folder_paths.get_full_path(model_dir_name, subpath)
|
||||
|
||||
item['installed'] = 'True' if os.path.exists(fullpath) else 'False'
|
||||
item['installed'] = 'True' if found else 'False'
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(8) as executor:
|
||||
for item in json_obj['models']:
|
||||
@@ -1487,7 +1532,10 @@ async def _queue_node_install(request, operation):
|
||||
if json_data['version'] != 'unknown' and selected_version != 'unknown':
|
||||
if skip_post_install:
|
||||
if cnr_id in core.unified_manager.nightly_inactive_nodes or cnr_id in core.unified_manager.cnr_inactive_nodes:
|
||||
core.unified_manager.unified_enable(cnr_id)
|
||||
res = core.unified_manager.unified_enable(cnr_id)
|
||||
if not res.result:
|
||||
logging.error(f"[ComfyUI-Manager] Failed to enable '{cnr_id}': {res.msg}")
|
||||
return web.Response(status=400, text=res.msg)
|
||||
# Mirror the pair of events (in_progress then done) that the async
|
||||
# task_worker normally emits for queued operations. The in_progress
|
||||
# event is what sets item.restart=true on the client row so the
|
||||
@@ -2173,10 +2221,9 @@ async def default_cache_update():
|
||||
a = get_cache("custom-node-list.json")
|
||||
b = get_cache("extension-node-map.json")
|
||||
c = get_cache("model-list.json")
|
||||
d = get_cache("alter-list.json")
|
||||
e = get_cache("github-stats.json")
|
||||
d = get_cache("github-stats.json")
|
||||
|
||||
await asyncio.gather(a, b, c, d, e)
|
||||
await asyncio.gather(a, b, c, d)
|
||||
|
||||
if core.get_config()['network_mode'] == 'private':
|
||||
logging.info("[ComfyUI-Manager] The private comfyregistry is not yet supported in `network_mode=private`.")
|
||||
|
||||
+479
-27
@@ -2,6 +2,8 @@
|
||||
description:
|
||||
`manager_util` is the lightest module shared across the prestartup_script, main code, and cm-cli of ComfyUI-Manager.
|
||||
"""
|
||||
import csv
|
||||
import sysconfig
|
||||
import importlib.metadata
|
||||
import traceback
|
||||
import ipaddress
|
||||
@@ -9,14 +11,17 @@ import socket
|
||||
|
||||
import aiohttp
|
||||
import json
|
||||
import math
|
||||
import threading
|
||||
import os
|
||||
import shutil
|
||||
import contextlib
|
||||
from datetime import datetime
|
||||
import subprocess
|
||||
import tempfile
|
||||
import sys
|
||||
import re
|
||||
import codecs
|
||||
import logging
|
||||
import platform
|
||||
import shlex
|
||||
@@ -543,6 +548,9 @@ def normalize_pip_name(name):
|
||||
|
||||
|
||||
_PIP_LINE_TAIL_PATTERN = re.compile(r'\s[#-]') # a comment or a pip option after the requirement
|
||||
_PIP_COMMENT_PATTERN = re.compile(r'(^|\s)#.*') # as pip reads it: the '#' of a URL fragment starts no comment
|
||||
_PIP_INDEX_OPTIONS = {'--index-url', '--extra-index-url'}
|
||||
_PIP_EDITABLE_PATTERN = re.compile(r'(?:-e\s*|--editable(?:\s+|=))(\S+)') # how pip reads -e and its target
|
||||
_PIP_MALFORMED_PATTERN = re.compile(r'([A-Za-z0-9][A-Za-z0-9._-]*)\s*(\[[^\]]*\]\s*)?[<>=!~(]')
|
||||
_PIP_URL_PATTERN = re.compile(r'[A-Za-z][A-Za-z0-9+.-]*://')
|
||||
|
||||
@@ -583,6 +591,54 @@ def parse_pip_spec(spec):
|
||||
return name, extras, [(specifier.operator, specifier.version) for specifier in requirement.specifier]
|
||||
|
||||
|
||||
def installer_args(requirement):
|
||||
"""The arguments of a requirement as the installer in use takes them.
|
||||
|
||||
uv installs an editable from a local folder only: where the arguments are `-e`
|
||||
and a git URL, uv gets the URL alone, as a normal install, and a line says so.
|
||||
"""
|
||||
if requirement[0] == '-e' and requirement[1].startswith('git+') and 'uv' in get_pip_cmd(force_uv=use_uv):
|
||||
print(f"[ComfyUI-Manager] uv installs an editable from a local folder only: '{requirement[1]}' is installed without -e")
|
||||
return requirement[1:]
|
||||
return requirement
|
||||
|
||||
|
||||
def pip_install_args(line, overrides):
|
||||
"""The arguments that a line of requirements.txt gives to `pip install`, or [] if it has none.
|
||||
|
||||
Each line is installed on its own, and an option applies to its line only. The
|
||||
comment is left out as pip leaves it out, so a URL keeps its fragment. A line that
|
||||
`overrides` (pip_overrides.json) names is replaced. An editable requirement
|
||||
(`-e path`, `--editable=path`) is `-e` and its target. A requirement followed by
|
||||
index options, such as `--extra-index-url URL`, gives the requirement and the
|
||||
options; any other line with a requirement is one argument, with the spaces of an
|
||||
environment marker. Where `-e` and a git URL are two arguments, uv gets the URL
|
||||
alone: it installs an editable from a local folder only. A line that starts with
|
||||
another option than `-e`, such as `-r other.txt`, names no requirement and gives
|
||||
none.
|
||||
"""
|
||||
text = _PIP_COMMENT_PATTERN.sub('', line).strip()
|
||||
if text in overrides:
|
||||
print(f"[ComfyUI-Manager] '{text}' is remapped to '{overrides[text]}'")
|
||||
text = overrides[text]
|
||||
if not text:
|
||||
return []
|
||||
editable = _PIP_EDITABLE_PATTERN.match(text)
|
||||
if editable is not None:
|
||||
requirement, options = ['-e', editable.group(1)], text[editable.end():].split()
|
||||
elif text.startswith('-'):
|
||||
print(f"[ComfyUI-Manager] skip '{text}': the Manager installs requirements one row at a time and does not apply this row")
|
||||
return []
|
||||
else:
|
||||
tail = _PIP_LINE_TAIL_PATTERN.search(text)
|
||||
if tail is None:
|
||||
return [text]
|
||||
requirement, options = [text[:tail.start()].rstrip()], text[tail.start():].split()
|
||||
if len(options) % 2 == 0 and set(options[::2]) <= _PIP_INDEX_OPTIONS:
|
||||
return [*installer_args(requirement), *options]
|
||||
return [text]
|
||||
|
||||
|
||||
def _upper_bound_state(operator, version, installed):
|
||||
"""Where an installed version sits against one upper-bound clause.
|
||||
|
||||
@@ -869,15 +925,15 @@ def installed_from(url, name=None):
|
||||
return None
|
||||
|
||||
|
||||
def fix_cmd(requirement):
|
||||
"""The pip command with which a fix installs a requirement.
|
||||
def fix_cmd(install_args):
|
||||
"""The pip command with which a fix installs the arguments of a requirement line, from `pip_install_args()`.
|
||||
|
||||
A direct reference is installed again by force, whatever is installed: nothing but
|
||||
its URL says what it should be. That command is run with `reinstall()`. Any other
|
||||
requirement is installed as an install does it.
|
||||
"""
|
||||
cmd = make_pip_cmd(['install', requirement])
|
||||
clauses = parse_pip_spec(requirement)[2]
|
||||
cmd = make_pip_cmd(['install', *install_args])
|
||||
clauses = parse_pip_spec(install_args[0])[2]
|
||||
if clauses and clauses[0][0] == '@':
|
||||
# --no-deps: without it every package the distribution needs is installed again as well, torch among them.
|
||||
# The cache is left out: with it uv installs the wheel it has built of the commit before, forced or not, and so
|
||||
@@ -1040,9 +1096,21 @@ def parse_requirement_line(line):
|
||||
|
||||
|
||||
torch_torchvision_torchaudio_version_map = {
|
||||
'2.15.0': ('0.29.2', '2.11.*'),
|
||||
'2.14.1': ('0.29.1', '2.11.*'),
|
||||
'2.14.0': ('0.29.0', '2.11.*'),
|
||||
'2.13.0': ('0.28.0', '2.11.*'),
|
||||
'2.12.1': ('0.27.1', '2.11.*'),
|
||||
'2.12.0': ('0.27.0', '2.11.*'),
|
||||
'2.11.0': ('0.26.0', '2.11.*'),
|
||||
'2.10.0': ('0.25.0', '2.10.0'),
|
||||
'2.9.1': ('0.24.1', '2.9.1'),
|
||||
'2.9.0': ('0.24.0', '2.9.0'),
|
||||
'2.8.0': ('0.23.0', '2.8.0'),
|
||||
'2.7.1': ('0.22.1', '2.7.1'),
|
||||
'2.7.0': ('0.22.0', '2.7.0'),
|
||||
'2.6.0': ('0.21.0', '2.6.0'),
|
||||
'2.5.1': ('0.20.0', '2.5.0'),
|
||||
'2.5.1': ('0.20.1', '2.5.1'),
|
||||
'2.5.0': ('0.20.0', '2.5.0'),
|
||||
'2.4.1': ('0.19.1', '2.4.1'),
|
||||
'2.4.0': ('0.19.0', '2.4.0'),
|
||||
@@ -1054,19 +1122,19 @@ torch_torchvision_torchaudio_version_map = {
|
||||
'2.1.2': ('0.16.2', '2.1.2'),
|
||||
'2.1.1': ('0.16.1', '2.1.1'),
|
||||
'2.1.0': ('0.16.0', '2.1.0'),
|
||||
'2.0.1': ('0.15.2', '2.0.1'),
|
||||
'2.0.1': ('0.15.2', '2.0.2'),
|
||||
'2.0.0': ('0.15.1', '2.0.0'),
|
||||
}
|
||||
|
||||
|
||||
def torch_rollback(prev):
|
||||
def torch_rollback_by_version_table(prev, packages, options=()):
|
||||
spec = prev.split('+')
|
||||
if len(spec) > 1:
|
||||
platform = spec[1]
|
||||
else:
|
||||
cmd = make_pip_cmd(['install', '--force', 'torch', 'torchvision', 'torchaudio'])
|
||||
cmd = make_pip_cmd(['install', '--force', *packages, *options])
|
||||
logging.info("[ComfyUI-Manager] restore PyTorch to the newest release")
|
||||
subprocess.check_output(cmd, universal_newlines=True)
|
||||
logging.error(cmd)
|
||||
return
|
||||
|
||||
torch_ver = StrictVersion(spec[0])
|
||||
@@ -1074,21 +1142,350 @@ def torch_rollback(prev):
|
||||
torch_torchvision_torchaudio_ver = torch_torchvision_torchaudio_version_map.get(torch_ver)
|
||||
|
||||
if torch_torchvision_torchaudio_ver is None:
|
||||
cmd = make_pip_cmd(['install', '--pre', 'torch', 'torchvision', 'torchaudio',
|
||||
'--index-url', f"https://download.pytorch.org/whl/nightly/{platform}"])
|
||||
cmd = make_pip_cmd(['install', '--pre', *packages,
|
||||
'--index-url', f"https://download.pytorch.org/whl/nightly/{platform}", *options])
|
||||
logging.info("[ComfyUI-Manager] restore PyTorch to nightly version")
|
||||
else:
|
||||
torchvision_ver, torchaudio_ver = torch_torchvision_torchaudio_ver
|
||||
cmd = make_pip_cmd(['install', f'torch=={torch_ver}', f'torchvision=={torchvision_ver}', f"torchaudio=={torchaudio_ver}",
|
||||
'--index-url', f"https://download.pytorch.org/whl/{platform}"])
|
||||
versions = {'torch': torch_ver, 'torchvision': torchvision_ver, 'torchaudio': torchaudio_ver}
|
||||
cmd = make_pip_cmd(['install', *[f'{name}=={versions[name]}' for name in packages],
|
||||
'--index-url', f"https://download.pytorch.org/whl/{platform}", *options])
|
||||
logging.info(f"[ComfyUI-Manager] restore PyTorch to {torch_ver}+{platform}")
|
||||
|
||||
subprocess.check_output(cmd, universal_newlines=True)
|
||||
|
||||
|
||||
def _pytorch_index(build, option):
|
||||
from packaging.version import Version
|
||||
|
||||
version = Version(build)
|
||||
if version.is_devrelease:
|
||||
return ['--pre', option, f"https://download.pytorch.org/whl/nightly/{version.local or 'cpu'}"]
|
||||
if version.local is not None:
|
||||
return [option, f"https://download.pytorch.org/whl/{version.local}"]
|
||||
return []
|
||||
|
||||
|
||||
def _installed_version(name):
|
||||
try:
|
||||
return importlib.metadata.version(name)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
def _recorded_files(name):
|
||||
try:
|
||||
distribution = importlib.metadata.distribution(name)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
return []
|
||||
# From the RECORD itself: files() leaves out the missing ones from Python 3.12 on
|
||||
return [(distribution.locate_file(row[0]), int(row[2]))
|
||||
for row in csv.reader((distribution.read_text('RECORD') or '').splitlines()) if len(row) == 3 and row[2]]
|
||||
|
||||
|
||||
def _required_here(name, extras=frozenset()):
|
||||
from packaging.requirements import InvalidRequirement, Requirement
|
||||
|
||||
found = []
|
||||
for line in importlib.metadata.requires(name) or []:
|
||||
try:
|
||||
requirement = Requirement(line)
|
||||
except InvalidRequirement:
|
||||
continue
|
||||
if requirement.marker is None or any(requirement.marker.evaluate({'extra': extra}) for extra in {*extras, ''}):
|
||||
found.append((normalize_pip_name(requirement.name), set(requirement.extras)))
|
||||
return found
|
||||
|
||||
|
||||
def _size_of_pytorch():
|
||||
extras, todo = {}, [(name, set()) for name in ('torch', 'torchvision', 'torchaudio')]
|
||||
while todo:
|
||||
name, wanted = todo.pop()
|
||||
if _installed_version(name) is None or name in extras and wanted <= extras[name]:
|
||||
continue
|
||||
extras[name] = extras.get(name, set()) | wanted
|
||||
todo += _required_here(name, extras[name])
|
||||
return {name: sum(size for _, size in _recorded_files(name)) for name in extras}
|
||||
|
||||
|
||||
def _space_to_restore(installed_before, installed_after, overwritten, size_of_pytorch, times_the_size):
|
||||
return int(times_the_size * sum(size for name, size in size_of_pytorch.items()
|
||||
if installed_after.get(name) != installed_before.get(name) or name in overwritten))
|
||||
|
||||
|
||||
def _overwritten(installed_before, installed_after, required_by_torch):
|
||||
# cuDNN, cuSPARSELt, NCCL and NVSHMEM ship one distribution per CUDA version, all writing the same file paths.
|
||||
return {name: installed_after[name] for name in sorted(required_by_torch)
|
||||
if name in installed_after and installed_before.get(name) == installed_after[name]
|
||||
and any(os.path.isfile(file) and os.path.getsize(file) != size for file, size in _recorded_files(name))}
|
||||
|
||||
|
||||
def _incomplete(required_by_torch):
|
||||
return {name: _installed_version(name) for name in sorted(required_by_torch)
|
||||
if any(not os.path.isfile(file) for file, _ in _recorded_files(name))}
|
||||
|
||||
|
||||
# The metadata of a torchvision or torchaudio can fit torch while its native library does not load beside it: a build
|
||||
# for another CUDA version, or the PyPI build beside a CPU torch. torch imports beside a cuDNN older than the one it
|
||||
# was built for; cudnn.version() compares the two without a GPU, and a CPU build has none to compare.
|
||||
_PYTORCH_CHECKS = {
|
||||
'torch': 'import torch; torch.backends.cudnn.version()',
|
||||
'torchvision': 'import torch, torchvision; torchvision.ops.nms(torch.rand(3, 4) * 10, torch.rand(3), 0.5)',
|
||||
'torchaudio': 'import torch, torchaudio.functional as F; F.lowpass_biquad(torch.rand(1, 100), 16000, 300.0)',
|
||||
}
|
||||
|
||||
|
||||
_CHECK_TIME_LIMIT = 300
|
||||
|
||||
# A .pth file or a module can print to the same stdout when Python starts, and can leave its line without an end.
|
||||
_CHECK_LINE = '[ComfyUI-Manager] PyTorch check:'
|
||||
_CHECK_DID_NOT_RUN = None
|
||||
|
||||
|
||||
def _not_working(names):
|
||||
code = f"print({_CHECK_LINE!r}, flush=True)\n" + ''.join(
|
||||
f"try:\n {_PYTORCH_CHECKS[name]}\n print({f'{_CHECK_LINE} {name}'!r}, flush=True)\nexcept Exception:\n"
|
||||
f" pass\n" for name in names)
|
||||
try:
|
||||
printed = subprocess.run([sys.executable, '-c', code], capture_output=True, text=True,
|
||||
timeout=_CHECK_TIME_LIMIT).stdout.splitlines()
|
||||
except subprocess.TimeoutExpired:
|
||||
return _CHECK_DID_NOT_RUN
|
||||
def told(line):
|
||||
return any(found.endswith(line) for found in printed)
|
||||
|
||||
if not told(_CHECK_LINE):
|
||||
return _CHECK_DID_NOT_RUN
|
||||
return [name for name in names if not told(f'{_CHECK_LINE} {name}')]
|
||||
|
||||
|
||||
class _Pip:
|
||||
# Measured: pip holds a wheel in its temporary folder while it writes the files, at the peak 1.7 times the size of
|
||||
# the files. With its cache it holds the wheel there too, at the peak 2.35 times for a CUDA torch for Windows.
|
||||
times_the_size = 2
|
||||
|
||||
@contextlib.contextmanager
|
||||
def environment(self):
|
||||
before = os.environ.get('PIP_NO_CACHE_DIR')
|
||||
os.environ['PIP_NO_CACHE_DIR'] = '1'
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
if before is None:
|
||||
del os.environ['PIP_NO_CACHE_DIR']
|
||||
else:
|
||||
os.environ['PIP_NO_CACHE_DIR'] = before
|
||||
|
||||
def install(self, name, build, *options):
|
||||
command = make_pip_cmd(['install', *options, f'{name}==={build}', *_pytorch_index(build, '--extra-index-url')])
|
||||
try:
|
||||
subprocess.check_output(command, universal_newlines=True)
|
||||
except subprocess.CalledProcessError:
|
||||
return False
|
||||
return True
|
||||
|
||||
@contextlib.contextmanager
|
||||
def putting_back(self, overwritten, torch):
|
||||
# pip installs no distribution of a command again without all the others.
|
||||
pins = [f'{name}=={version}' for name, version in overwritten.items()]
|
||||
with tempfile.TemporaryDirectory() as wheels:
|
||||
if pins:
|
||||
try:
|
||||
subprocess.check_output(make_pip_cmd(['download', '--no-deps', '-d', wheels, *pins,
|
||||
*_pytorch_index(torch, '--extra-index-url')]),
|
||||
universal_newlines=True)
|
||||
except subprocess.CalledProcessError:
|
||||
raise RuntimeError(f"{', '.join(pins)} cannot be had")
|
||||
yield []
|
||||
left = [f'{name}=={version}' for name, version in overwritten.items()
|
||||
if _installed_version(name) == version]
|
||||
if left:
|
||||
subprocess.check_output(make_pip_cmd(['install', '--no-deps', '--force-reinstall', '--no-index',
|
||||
'--find-links', wheels, *left]), universal_newlines=True)
|
||||
|
||||
def own_index(self, torch):
|
||||
return _pytorch_index(torch, '--index-url')
|
||||
|
||||
def install_again(self, broken, requirements, torch):
|
||||
# pip joins PIP_EXTRA_INDEX_URL to an index and takes the highest version of all, which can be a build for
|
||||
# another CUDA version.
|
||||
index = _pytorch_index(torch, '--find-links')
|
||||
if index:
|
||||
*pre, _, url = index
|
||||
index = [*pre, '--no-index', *[option for name in broken for option in ('--find-links', f'{url}/{name}/')]]
|
||||
subprocess.check_output(make_pip_cmd(['install', '--force-reinstall', '--no-deps',
|
||||
*[requirements[name] for name in broken], *index]),
|
||||
universal_newlines=True)
|
||||
|
||||
def install_files_again(self, name, version, torch):
|
||||
subprocess.check_output(make_pip_cmd(['install', '--force-reinstall', '--no-deps', f'{name}=={version}',
|
||||
*_pytorch_index(torch, '--extra-index-url')]), universal_newlines=True)
|
||||
|
||||
|
||||
class _Uv:
|
||||
# Measured: uv unpacks a wheel into its cache and links the files from there, at the peak 1.06 times the size of
|
||||
# the files. Where it copies them, it removes the old build first.
|
||||
times_the_size = 1.5
|
||||
|
||||
def __init__(self):
|
||||
from packaging.version import Version
|
||||
|
||||
# uv's version line can follow what Python prints as it starts.
|
||||
try:
|
||||
printed = subprocess.check_output([*make_pip_cmd([])[:-1], '--version'], universal_newlines=True)
|
||||
except subprocess.CalledProcessError:
|
||||
printed = ''
|
||||
version = re.search(r'^uv (\d+(\.\d+)*)', printed, re.MULTILINE)
|
||||
self.reads_index = version is not None and Version(version[1]) >= Version('0.4.23')
|
||||
|
||||
def environment(self):
|
||||
return contextlib.nullcontext()
|
||||
|
||||
def install(self, name, build, *options):
|
||||
# uv does not put back what it removed when a command fails while it installs, and an install command sent
|
||||
# after it can lay the new build over what is left and report it as installed. uv ends a command when it
|
||||
# cannot reach an index that the command names. A --extra-index-url of the command takes the place of
|
||||
# UV_EXTRA_INDEX_URL.
|
||||
index = _pytorch_index(build, '--extra-index-url')
|
||||
command = make_pip_cmd(['install', *options, f'{name}==={build}', *index])
|
||||
forms = [command, [*command, '--offline']]
|
||||
if index:
|
||||
forms.append([*make_pip_cmd(['install', *options, f'{name}==={build}', *index[:-2]]), '--offline'])
|
||||
for form in forms:
|
||||
try:
|
||||
subprocess.check_output([*form, '--dry-run'], universal_newlines=True, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
if form is command:
|
||||
reason = '\n'.join(line for line in e.stderr.strip().splitlines()
|
||||
if not line.startswith('Using Python '))
|
||||
continue
|
||||
if form is not command:
|
||||
logging.info("[ComfyUI-Manager] restore PyTorch: the command does not resolve with its indexes, "
|
||||
"installing from uv's cache alone")
|
||||
try:
|
||||
subprocess.check_output(form, universal_newlines=True)
|
||||
except subprocess.CalledProcessError:
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: installing {name} {build} failed, "
|
||||
f"sending it once more")
|
||||
subprocess.check_output([*form, '--reinstall-package', name], universal_newlines=True)
|
||||
return True
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: uv does not resolve the command: {reason}")
|
||||
return False
|
||||
|
||||
def putting_back(self, overwritten, torch):
|
||||
return contextlib.nullcontext([option for name in overwritten for option in ('--reinstall-package', name)])
|
||||
|
||||
def own_index(self, torch):
|
||||
# uv reads --index before UV_INDEX, UV_EXTRA_INDEX_URL and the default index, and a --index of the command
|
||||
# takes the place of UV_INDEX.
|
||||
index = _pytorch_index(torch, '--index-url')
|
||||
return [*index, '--index' if self.reads_index else '--extra-index-url', index[-1]] if index else []
|
||||
|
||||
def install_again(self, broken, requirements, torch):
|
||||
again = [option for name in broken for option in ('--reinstall-package', name)]
|
||||
subprocess.check_output(make_pip_cmd(['install', *requirements.values(), *self.own_index(torch), *again]),
|
||||
universal_newlines=True)
|
||||
|
||||
def install_files_again(self, name, version, torch):
|
||||
subprocess.check_output(make_pip_cmd(['install', '--no-deps', f'{name}=={version}',
|
||||
*_pytorch_index(torch, '--extra-index-url'),
|
||||
'--reinstall-package', name]), universal_newlines=True)
|
||||
|
||||
|
||||
def _report_not_working(names):
|
||||
if names is _CHECK_DID_NOT_RUN:
|
||||
logging.warning("[ComfyUI-Manager] restore PyTorch: the check of what works did not run")
|
||||
elif names:
|
||||
logging.error(f"[ComfyUI-Manager] restore PyTorch: does not work after the restore: "
|
||||
f"{', '.join(f'{name} {_installed_version(name)}' for name in names)}")
|
||||
|
||||
|
||||
def torch_rollback(installed_before, installed_after, required_by_torch, size_of_pytorch):
|
||||
from packaging.version import Version
|
||||
|
||||
tool = _Uv() if 'uv' in make_pip_cmd([]) else _Pip()
|
||||
torch = installed_before['torch']
|
||||
packages = [name for name in ('torch', 'torchvision', 'torchaudio')
|
||||
if name in installed_before or name in installed_after]
|
||||
changed = {name: installed_before[name] for name in ('torch', 'torchvision', 'torchaudio')
|
||||
if name in installed_before and installed_after.get(name) != installed_before[name]}
|
||||
logging.info(f"[ComfyUI-Manager] restore PyTorch: {', '.join(f'{name} {build}' for name, build in changed.items())}")
|
||||
|
||||
companions = {name: build for name, build in changed.items() if name != 'torch'}
|
||||
overwritten = _overwritten(installed_before, installed_after, required_by_torch)
|
||||
needed = _space_to_restore(installed_before, installed_after, overwritten, size_of_pytorch, tool.times_the_size)
|
||||
free = shutil.disk_usage(sysconfig.get_path('purelib')).free
|
||||
if free < needed:
|
||||
raise RuntimeError(f"for safety the restore does not start: it can take {math.ceil(needed / 10 ** 6)} MB on "
|
||||
f"the disk of the Python environment, where {free // 10 ** 6} MB are free")
|
||||
with tool.environment():
|
||||
if 'torch' in changed or overwritten:
|
||||
with tool.putting_back(overwritten, torch) as options:
|
||||
torch_installed = tool.install('torch', torch, *options)
|
||||
if not torch_installed:
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: torch {torch} cannot be had, "
|
||||
f"restoring by the version table instead")
|
||||
torch_rollback_by_version_table(torch, packages, options)
|
||||
if not torch_installed:
|
||||
_report_not_working(_not_working(packages))
|
||||
return
|
||||
|
||||
for name, build in companions.items():
|
||||
if not tool.install(name, build, '--no-deps'):
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: {name} {build} cannot be had, "
|
||||
f"installing a {name} that fits torch {torch} instead")
|
||||
|
||||
# torchaudio 2.11.0 declares no requirement on torch, so without a bound the resolver takes it beside an older
|
||||
# torch. The bound is the next minor version of torch, as a patch release of torchaudio can be newer than its
|
||||
# torch: 2.0.2 goes with 2.0.1.
|
||||
version = Version(torch)
|
||||
requirement = {'torch': f'torch==={torch}', 'torchvision': 'torchvision',
|
||||
'torchaudio': f'torchaudio<{version.major}.{version.minor + 1}'}
|
||||
requirements = {name: requirement[name] for name in packages}
|
||||
try:
|
||||
subprocess.check_output(make_pip_cmd(['install', *requirements.values(), *tool.own_index(torch)]),
|
||||
universal_newlines=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: the whole set failed to install, checking what "
|
||||
f"works: {e}")
|
||||
|
||||
broken = _not_working(packages)
|
||||
if broken and 'torch' in broken:
|
||||
# An uninstall takes the files that two distributions share.
|
||||
incomplete = _incomplete(required_by_torch)
|
||||
for name, version in incomplete.items():
|
||||
try:
|
||||
tool.install_files_again(name, version, torch)
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
if incomplete:
|
||||
broken = _not_working(packages)
|
||||
|
||||
if broken and 'torch' not in broken:
|
||||
torchvision = _installed_version('torchvision')
|
||||
if 'torchvision' in broken and torchvision is not None:
|
||||
requirements['torchvision'] = f"torchvision=={Version(torchvision).public}"
|
||||
try:
|
||||
tool.install_again(broken, requirements, torch)
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
broken = _not_working(packages)
|
||||
_report_not_working(broken)
|
||||
|
||||
|
||||
class PIPFixer:
|
||||
def __init__(self, prev_pip_versions, comfyui_path, manager_files_path):
|
||||
self.prev_pip_versions = { **prev_pip_versions }
|
||||
self.required_by_torch, self.size_of_pytorch = set(), {}
|
||||
torch = prev_pip_versions.get('torch')
|
||||
try:
|
||||
list_names_the_installed_torch = torch is not None and _installed_version('torch') == torch
|
||||
if list_names_the_installed_torch:
|
||||
self.required_by_torch, self.size_of_pytorch = ({name for name, _ in _required_here('torch')},
|
||||
_size_of_pytorch())
|
||||
except Exception as e:
|
||||
logging.warning(f"[ComfyUI-Manager] restore PyTorch: what torch requires could not be read, "
|
||||
f"a restore will put no library back: {e!r}")
|
||||
self.comfyui_path = comfyui_path
|
||||
self.manager_files_path = manager_files_path
|
||||
|
||||
@@ -1108,12 +1505,12 @@ class PIPFixer:
|
||||
|
||||
# fix torch - reinstall torch packages if version is changed
|
||||
try:
|
||||
if 'torch' not in self.prev_pip_versions or 'torchvision' not in self.prev_pip_versions or 'torchaudio' not in self.prev_pip_versions:
|
||||
if 'torch' not in self.prev_pip_versions or 'torchvision' not in self.prev_pip_versions:
|
||||
logging.error("[ComfyUI-Manager] PyTorch is not installed")
|
||||
elif self.prev_pip_versions['torch'] != new_pip_versions['torch'] \
|
||||
or self.prev_pip_versions['torchvision'] != new_pip_versions['torchvision'] \
|
||||
or self.prev_pip_versions['torchaudio'] != new_pip_versions['torchaudio']:
|
||||
torch_rollback(self.prev_pip_versions['torch'])
|
||||
elif any(self.prev_pip_versions[name] != new_pip_versions.get(name) for name in ('torch', 'torchvision')):
|
||||
clear_pip_cache()
|
||||
torch_rollback(self.prev_pip_versions, new_pip_versions, self.required_by_torch,
|
||||
self.size_of_pytorch)
|
||||
except Exception as e:
|
||||
logging.error("[ComfyUI-Manager] Failed to restore PyTorch")
|
||||
logging.error(e)
|
||||
@@ -1249,6 +1646,52 @@ def robust_readlines(fullpath):
|
||||
return []
|
||||
|
||||
|
||||
_PRINTABLE_ASCII = re.compile(r'[\t-\r -~]*')
|
||||
_PRINTABLE_ASCII_BYTES = bytes(range(0x09, 0x0e)) + bytes(range(0x20, 0x7f))
|
||||
_WIDE_UNICODE_CODECS = ('utf-16', 'utf-16-le', 'utf-16-be', 'utf-32', 'utf-32-le', 'utf-32-be')
|
||||
|
||||
|
||||
def _is_ascii_compatible_or_wide_unicode(encoding):
|
||||
try:
|
||||
codec = codecs.lookup(encoding)
|
||||
if codec.name in _WIDE_UNICODE_CODECS:
|
||||
return True
|
||||
return codec.decode(_PRINTABLE_ASCII_BYTES)[0] == _PRINTABLE_ASCII_BYTES.decode('ascii')
|
||||
except (LookupError, UnicodeDecodeError):
|
||||
return False
|
||||
|
||||
|
||||
def _hands_pip_only_ascii(line):
|
||||
before_comment = _PIP_COMMENT_PATTERN.sub('', line)
|
||||
return before_comment.isspace() or _PRINTABLE_ASCII.fullmatch(before_comment) is not None
|
||||
|
||||
|
||||
def read_requirements_lines(fullpath):
|
||||
try:
|
||||
with open(fullpath, "r") as f:
|
||||
return f.readlines()
|
||||
except UnicodeDecodeError:
|
||||
import chardet
|
||||
with open(fullpath, "rb") as f:
|
||||
encoding = chardet.detect(f.read())['encoding']
|
||||
|
||||
lines = None
|
||||
if encoding is not None and _is_ascii_compatible_or_wide_unicode(encoding):
|
||||
try:
|
||||
with open(fullpath, "r", encoding=encoding) as f:
|
||||
lines = f.readlines()
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
|
||||
if lines:
|
||||
# chardet 7.1.0 names UTF-16-LE for a UTF-16 file with a byte order mark, which then stays in the text
|
||||
lines[0] = lines[0].lstrip('\ufeff')
|
||||
|
||||
if lines is None or not all(_hands_pip_only_ascii(line) for line in lines):
|
||||
raise
|
||||
return lines
|
||||
|
||||
|
||||
def build_restart_command(argv, drop_args=()):
|
||||
"""
|
||||
Rebuild the command line used to re-exec the current ComfyUI process.
|
||||
@@ -1285,13 +1728,22 @@ def restore_pip_snapshot(pips, options):
|
||||
if k.startswith("torch==") or k.startswith("torchvision==") or k.startswith("torchaudio==") or k.startswith("nvidia-"):
|
||||
continue
|
||||
|
||||
if v == "":
|
||||
# pip freeze prints an editable install as `-e <path or url>`, after a comment line
|
||||
if k.startswith('#'):
|
||||
continue
|
||||
elif k.startswith('-e '):
|
||||
v = k[3:]
|
||||
args = ['-e', v]
|
||||
elif v == "":
|
||||
non_url.append(k)
|
||||
continue
|
||||
else:
|
||||
if v.startswith('file:'):
|
||||
local_url.append(v)
|
||||
else:
|
||||
non_local_url.append(v)
|
||||
args = [v]
|
||||
|
||||
if v.startswith('file:') or '://' not in v:
|
||||
local_url.append(args)
|
||||
else:
|
||||
non_local_url.append(args)
|
||||
|
||||
|
||||
# restore other pips
|
||||
@@ -1320,23 +1772,23 @@ def restore_pip_snapshot(pips, options):
|
||||
for x in non_local_url:
|
||||
res = 1
|
||||
try:
|
||||
res = subprocess.check_call(make_pip_cmd(['install', '--no-deps', x]))
|
||||
res = subprocess.check_call(make_pip_cmd(['install', '--no-deps', *installer_args(x)]))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if res != 0:
|
||||
failed.append(x)
|
||||
failed.append(' '.join(x))
|
||||
|
||||
if '--pip-local-url' in options:
|
||||
for x in local_url:
|
||||
res = 1
|
||||
try:
|
||||
res = subprocess.check_call(make_pip_cmd(['install', '--no-deps', x]))
|
||||
res = subprocess.check_call(make_pip_cmd(['install', '--no-deps', *installer_args(x)]))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if res != 0:
|
||||
failed.append(x)
|
||||
failed.append(' '.join(x))
|
||||
|
||||
print(f"Installation failed for pip packages: {failed}")
|
||||
return failed
|
||||
|
||||
+15
-25
@@ -133,17 +133,6 @@ docStyle.innerHTML = `
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#alternatives-grid a {
|
||||
color: #5555FF;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#alternatives-grid a:hover {
|
||||
color: #7777FF;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.cm-notice-board {
|
||||
width: auto;
|
||||
height: 280px;
|
||||
@@ -425,13 +414,22 @@ const style = `
|
||||
#cm-manual-button-menu {
|
||||
z-index: 10000000000 !important;
|
||||
}
|
||||
.cm-share-none .cm-share-button {
|
||||
display: none;
|
||||
}
|
||||
`;
|
||||
|
||||
// the frontend mounts the new style buttons into its top bar after setup(), so they are hidden by a class of the page
|
||||
function update_share_buttons() {
|
||||
document.body.classList.toggle("cm-share-none", share_option === 'none');
|
||||
}
|
||||
|
||||
async function init_share_option() {
|
||||
api.fetchApi('/manager/share_option')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
share_option = to_share_option(data);
|
||||
update_share_buttons();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -706,7 +704,7 @@ async function onQueueStatus(event) {
|
||||
|
||||
let msg = "";
|
||||
|
||||
if(success_list.length == 0 && comfyui_state.startsWith('skip')) {
|
||||
if(success_list.length == 0 && (comfyui_state == null || comfyui_state.startsWith('skip'))) {
|
||||
if(failed_list.length == 0) {
|
||||
msg += "You are already up to date.";
|
||||
}
|
||||
@@ -718,7 +716,7 @@ async function onQueueStatus(event) {
|
||||
msg += "ComfyUI has been updated to latest nightly version.<BR><BR>";
|
||||
infoToast("ComfyUI has been updated to the latest nightly version.");
|
||||
}
|
||||
else if(comfyui_state.startsWith('success-stable')) {
|
||||
else if(comfyui_state?.startsWith('success-stable')) {
|
||||
const ver = comfyui_state.split("-").pop();
|
||||
msg += `ComfyUI has been updated to ${ver}.<BR><BR>`;
|
||||
infoToast(`ComfyUI has been updated to ${ver}`);
|
||||
@@ -1160,12 +1158,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
const value = event.target.value;
|
||||
share_option = value;
|
||||
api.fetchApi('/manager/share_option', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ value }) });
|
||||
const shareButton = document.getElementById("shareButton");
|
||||
if (value === 'none') {
|
||||
shareButton.style.display = "none";
|
||||
} else {
|
||||
shareButton.style.display = "inline-block";
|
||||
}
|
||||
update_share_buttons();
|
||||
});
|
||||
|
||||
const shareSetttingItem = createSettingsCombo("Share", share_combo);
|
||||
@@ -1621,7 +1614,8 @@ app.registerExtension({
|
||||
}
|
||||
ShareDialogChooser.instance.show();
|
||||
},
|
||||
tooltip: "Share"
|
||||
tooltip: "Share",
|
||||
classList: "comfyui-button cm-share-button"
|
||||
}).element
|
||||
);
|
||||
|
||||
@@ -1661,11 +1655,7 @@ app.registerExtension({
|
||||
// make the background color a gradient of blue to green
|
||||
shareButton.style.background = "linear-gradient(90deg, #00C9FF 0%, #92FE9D 100%)";
|
||||
shareButton.style.color = "black";
|
||||
|
||||
// Load share option from local storage to determine whether to show
|
||||
// the share button.
|
||||
const shouldShowShareButton = share_option !== 'none';
|
||||
shareButton.style.display = shouldShowShareButton ? "inline-block" : "none";
|
||||
shareButton.className = "cm-share-button";
|
||||
|
||||
menu.append(shareButton);
|
||||
},
|
||||
|
||||
+13
-2
@@ -732,7 +732,7 @@ export async function uninstallNodes(nodeList, options = {}) {
|
||||
let errorMsg = "";
|
||||
let target_items = [];
|
||||
|
||||
await api.fetchApi('/manager/queue/reset');
|
||||
await api.fetchApi('/manager/queue/reset', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
|
||||
|
||||
for (const nodeItem of nodeList) {
|
||||
target_items.push(nodeItem);
|
||||
@@ -770,7 +770,18 @@ export async function uninstallNodes(nodeList, options = {}) {
|
||||
show_message("[Uninstall Errors]\n" + errorMsg);
|
||||
return { success: false, error: errorMsg, targets: target_items };
|
||||
} else {
|
||||
await api.fetchApi('/manager/queue/start');
|
||||
// the queue endpoints are POST-only - a GET here silently fails to start the
|
||||
// worker, leaving every queued uninstall sitting untouched in the queue
|
||||
// 200 = worker started, 201 = a worker was already running and will pick up
|
||||
// the items just queued - both mean the uninstall is under way
|
||||
const startRes = await api.fetchApi('/manager/queue/start', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
|
||||
if (startRes.status !== 200 && startRes.status !== 201) {
|
||||
errorMsg = `Couldn't start the uninstall queue (HTTP ${startRes.status}). Nothing was uninstalled.\n`;
|
||||
onError(errorMsg);
|
||||
show_message("[Uninstall Errors]\n" + errorMsg);
|
||||
return { success: false, error: errorMsg, targets: target_items };
|
||||
}
|
||||
|
||||
onSuccess(target_items);
|
||||
showTerminal();
|
||||
return { success: true, targets: target_items };
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
|
||||
.cn-manager-grid .cn-pack-conflicts {
|
||||
color: orange;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.cn-popover {
|
||||
@@ -590,20 +591,6 @@
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.cn-tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.cn-tag-list > div {
|
||||
background-color: var(--border-color);
|
||||
border-radius: 5px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.cn-install-buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+41
-75
@@ -43,7 +43,6 @@ const ShowMode = {
|
||||
UPDATE: "Update",
|
||||
MISSING: "Missing",
|
||||
FAVORITES: "Favorites",
|
||||
ALTERNATIVES: "Alternatives",
|
||||
IN_WORKFLOW: "In Workflow",
|
||||
USED_IN_ANY_WORKFLOW: "Used In Any Workflow",
|
||||
NOT_USED_IN_ANY_WORKFLOW: "Installed and Unused",
|
||||
@@ -298,10 +297,6 @@ export class CustomNodesManager {
|
||||
label: "Favorites",
|
||||
value: ShowMode.FAVORITES,
|
||||
hasData: false
|
||||
}, {
|
||||
label: "Alternatives of A1111",
|
||||
value: ShowMode.ALTERNATIVES,
|
||||
hasData: false
|
||||
}];
|
||||
this.filterList = filterList;
|
||||
$filter.innerHTML = filterList.map(item => {
|
||||
@@ -618,7 +613,7 @@ export class CustomNodesManager {
|
||||
bindContainerResize: true,
|
||||
|
||||
cellResizeObserver: (rowItem, columnItem) => {
|
||||
const autoHeightColumns = ['title', 'action', 'description', "alternatives"];
|
||||
const autoHeightColumns = ['title', 'action', 'description'];
|
||||
return autoHeightColumns.includes(columnItem.id)
|
||||
},
|
||||
|
||||
@@ -636,9 +631,6 @@ export class CustomNodesManager {
|
||||
rowFilter: (rowItem) => {
|
||||
|
||||
const searchableColumns = ["title", "author", "description"];
|
||||
if (this.hasAlternatives()) {
|
||||
searchableColumns.push("alternatives");
|
||||
}
|
||||
|
||||
let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
|
||||
|
||||
@@ -753,10 +745,6 @@ export class CustomNodesManager {
|
||||
return 1 / distance;
|
||||
}
|
||||
|
||||
hasAlternatives() {
|
||||
return this.filter === ShowMode.ALTERNATIVES
|
||||
}
|
||||
|
||||
async handleImportFail(rowItem) {
|
||||
var info;
|
||||
if(rowItem.version == 'unknown'){
|
||||
@@ -909,16 +897,12 @@ export class CustomNodesManager {
|
||||
if (rowItem.conflicts) {
|
||||
list.push(`<div class="cn-pack-conflicts">${rowItem.conflicts} conflict${(rowItem.conflicts>1?'s':'')}</div>`);
|
||||
}
|
||||
if (rowItem.potentialConflicts) {
|
||||
list.push(`<div class="cn-pack-conflicts">${rowItem.potentialConflicts} potential conflict${(rowItem.potentialConflicts>1?'s':'')}</div>`);
|
||||
}
|
||||
list.push('</div>');
|
||||
return list.join("");
|
||||
}
|
||||
}, {
|
||||
id: "alternatives",
|
||||
name: "Alternatives",
|
||||
width: 400,
|
||||
maxWidth: 5000,
|
||||
invisible: !this.hasAlternatives(),
|
||||
classMap: 'cn-pack-desc'
|
||||
}, {
|
||||
id: 'description',
|
||||
name: 'Description',
|
||||
@@ -1004,11 +988,6 @@ export class CustomNodesManager {
|
||||
updateGrid() {
|
||||
if (this.grid) {
|
||||
this.grid.update();
|
||||
if (this.hasAlternatives()) {
|
||||
this.grid.showColumn("alternatives");
|
||||
} else {
|
||||
this.grid.hideColumn("alternatives");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,8 +1265,9 @@ export class CustomNodesManager {
|
||||
list.push(`<div class="cn-nodes-list">`);
|
||||
|
||||
nodesList.forEach((it, i) => {
|
||||
const conflicts = it.conflicts || it.potentialConflicts;
|
||||
let rowClass = 'cn-nodes-row'
|
||||
if (it.conflicts) {
|
||||
if (conflicts) {
|
||||
rowClass += ' cn-nodes-conflict';
|
||||
}
|
||||
|
||||
@@ -1296,8 +1276,9 @@ export class CustomNodesManager {
|
||||
// extName via /customnode/getmappings, no server sanitize: escaped at the sink.
|
||||
list.push(`<div class="cn-nodes-name">${sanitizeHTML(String(it.name))}</div>`);
|
||||
|
||||
if (it.conflicts) {
|
||||
list.push(`<div class="cn-conflicts-list"><div class="cn-nodes-conflict cn-icon">${icons.conflicts}</div><b>Conflict with</b>${it.conflicts.map(c => {
|
||||
if (conflicts) {
|
||||
const label = it.conflicts ? 'Conflict with enabled packs' : 'Potential conflict if installed/enabled with';
|
||||
list.push(`<div class="cn-conflicts-list"><div class="cn-nodes-conflict cn-icon">${icons.conflicts}</div><b>${label}</b>${conflicts.map(c => {
|
||||
return `<div class="cn-nodes-pack" hash="${c.hash}">${c.title}</div>`;
|
||||
}).join("<b>,</b>")}</div>`);
|
||||
}
|
||||
@@ -1340,6 +1321,7 @@ export class CustomNodesManager {
|
||||
}
|
||||
|
||||
const conflictsMap = {};
|
||||
const nodesMapByPack = new Map();
|
||||
|
||||
// add nodes data
|
||||
Object.keys(data).forEach(k => {
|
||||
@@ -1352,9 +1334,12 @@ export class CustomNodesManager {
|
||||
// deduped
|
||||
const eList = Array.from(new Set(nodes));
|
||||
|
||||
nodeItem.nodes = eList.length;
|
||||
const nodesMap = {};
|
||||
const nodesMap = nodesMapByPack.get(nodeItem) || {};
|
||||
nodesMapByPack.set(nodeItem, nodesMap);
|
||||
eList.forEach(extName => {
|
||||
if (nodesMap[extName]) {
|
||||
return;
|
||||
}
|
||||
nodesMap[extName] = {
|
||||
name: extName
|
||||
};
|
||||
@@ -1366,6 +1351,7 @@ export class CustomNodesManager {
|
||||
cList.push(nodeItem.key);
|
||||
});
|
||||
nodeItem.nodesMap = nodesMap;
|
||||
nodeItem.nodes = Object.keys(nodesMap).length;
|
||||
} else {
|
||||
// should be removed
|
||||
// console.log("not found", k, title, nodes)
|
||||
@@ -1382,13 +1368,17 @@ export class CustomNodesManager {
|
||||
cList.forEach(key => {
|
||||
const nodeItem = node_packs[key];
|
||||
const extItem = nodeItem.nodesMap[extName];
|
||||
if(!extItem.conflicts) {
|
||||
extItem.conflicts = []
|
||||
// Catalog entries are not necessarily installed or enabled. Only
|
||||
// enabled peers can conflict; inactive packs get a separate preview.
|
||||
const conflictsList = cList.filter(k => k !== key && node_packs[k].state === 'enabled');
|
||||
if (!conflictsList.length) {
|
||||
return;
|
||||
}
|
||||
const conflictsList = cList.filter(k => k !== key);
|
||||
const field = nodeItem.state === 'enabled' ? 'conflicts' : 'potentialConflicts';
|
||||
extItem[field] = [];
|
||||
conflictsList.forEach(k => {
|
||||
const nItem = node_packs[k];
|
||||
extItem.conflicts.push({
|
||||
extItem[field].push({
|
||||
key: k,
|
||||
title: nItem.title,
|
||||
hash: nItem.hash
|
||||
@@ -1402,6 +1392,7 @@ export class CustomNodesManager {
|
||||
if (nodeItem.nodesMap) {
|
||||
nodeItem.nodesList = Object.values(nodeItem.nodesMap);
|
||||
nodeItem.conflicts = nodeItem.nodesList.filter(it => it.conflicts).length;
|
||||
nodeItem.potentialConflicts = nodeItem.nodesList.filter(it => it.potentialConflicts).length;
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1851,6 +1842,21 @@ export class CustomNodesManager {
|
||||
return allUsedNodes;
|
||||
}
|
||||
|
||||
getNodepackByCnrId(cnr_id) {
|
||||
let item = this.custom_nodes[cnr_id];
|
||||
// comfy-core is ComfyUI itself, not a nodepack that is named so in another case
|
||||
if(item || cnr_id == 'comfy-core') {
|
||||
return item;
|
||||
}
|
||||
|
||||
const normalized_id = String(cnr_id).toLowerCase();
|
||||
for(let k in this.custom_nodes) {
|
||||
if(k.toLowerCase() == normalized_id) {
|
||||
return this.custom_nodes[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getMissingNodes() {
|
||||
let unresolved_missing_nodes = new Set();
|
||||
let hashMap = {};
|
||||
@@ -1875,7 +1881,7 @@ export class CustomNodesManager {
|
||||
outdated_comfyui = true;
|
||||
}
|
||||
|
||||
let item = this.custom_nodes[node.properties.cnr_id];
|
||||
let item = this.getNodepackByCnrId(node.properties.cnr_id);
|
||||
if(item) {
|
||||
hashMap[item.hash] = true;
|
||||
}
|
||||
@@ -2061,41 +2067,6 @@ export class CustomNodesManager {
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
async getAlternatives() {
|
||||
const mode = manager_instance.datasrc_combo.value;
|
||||
this.showStatus(`Loading alternatives (${mode}) ...`);
|
||||
const res = await fetchData(`/customnode/alternatives?mode=${mode}`);
|
||||
if (res.error) {
|
||||
this.showError(`Failed to get alternatives: ${sanitizeHTML(String(res.error))}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const hashMap = {};
|
||||
const items = res.data;
|
||||
|
||||
for(let i in items) {
|
||||
let item = items[i];
|
||||
let custom_node = this.custom_nodes[i];
|
||||
|
||||
if (!custom_node) {
|
||||
console.log(`Not found custom node: ${item.id}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// tags (alter-list.json) is not server-transformed, so escape before innerHTML.
|
||||
const tags = `${item.tags}`.split(",").map(tag => {
|
||||
return `<div>${sanitizeHTML(tag.trim())}</div>`;
|
||||
}).join("");
|
||||
|
||||
hashMap[custom_node.hash] = {
|
||||
alternatives: `<div class="cn-tag-list">${tags}</div> ${item.description}`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return hashMap;
|
||||
}
|
||||
|
||||
async getUsedInAnyWorkflow() {
|
||||
this.showStatus(`Loading workflow usage analysis ...`);
|
||||
|
||||
@@ -2214,8 +2185,6 @@ export class CustomNodesManager {
|
||||
}
|
||||
} else if(this.show_mode == ShowMode.MISSING) {
|
||||
hashMap = await this.getMissingNodes();
|
||||
} else if(this.show_mode == ShowMode.ALTERNATIVES) {
|
||||
hashMap = await this.getAlternatives();
|
||||
} else if(this.show_mode == ShowMode.FAVORITES) {
|
||||
hashMap = await this.getFavorites();
|
||||
} else if(this.show_mode == ShowMode.IN_WORKFLOW) {
|
||||
@@ -2266,9 +2235,6 @@ export class CustomNodesManager {
|
||||
if (value === ShowMode.MISSING) {
|
||||
nodeItem['missing-node'] = "true";
|
||||
}
|
||||
if (typeof hashData === "object") {
|
||||
Object.assign(nodeItem, hashData);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (nodeItem.state === value) {
|
||||
|
||||
+10
-21
@@ -256,31 +256,20 @@ export class ModelManager {
|
||||
rowFilter: (rowItem) => {
|
||||
|
||||
const searchableColumns = ["name", "type", "base", "description", "filename", "save_path"];
|
||||
const models_extensions = ['.ckpt', '.pt', '.pt2', '.bin', '.pth', '.safetensors', '.pkl', '.sft'];
|
||||
|
||||
let shouldShown = grid.highlightKeywordsFilter(rowItem, searchableColumns, this.keywords);
|
||||
|
||||
if (shouldShown) {
|
||||
if(this.filter) {
|
||||
if (this.filter == "in_workflow") {
|
||||
rowItem.in_workflow = null;
|
||||
if (Array.isArray(app.graph._nodes)) {
|
||||
app.graph._nodes.forEach((item, i) => {
|
||||
if (Array.isArray(item.widgets_values)) {
|
||||
item.widgets_values.forEach((_item, i) => {
|
||||
if (rowItem.in_workflow === null && _item !== null && models_extensions.includes("." + _item.toString().split('.').pop())) {
|
||||
let filename = _item.match(/([^\/]+)(?=\.\w+$)/)[0];
|
||||
if (grid.highlightKeywordsFilter(rowItem, searchableColumns, filename)) {
|
||||
rowItem.in_workflow = "True";
|
||||
grid.highlightKeywordsFilter(rowItem, searchableColumns, "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return ((this.filter == "installed" && rowItem.installed == "True") || (this.filter == "not_installed" && rowItem.installed == "False") || (this.filter == "in_workflow" && rowItem.in_workflow == "True"));
|
||||
if(this.filter == "installed" && rowItem.installed !== "True") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.filter == "not_installed" && rowItem.installed !== "False") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.filter == "in_workflow" && !app.graph._nodes.some(node => Array.isArray(node.widgets_values) && node.widgets_values.some(value => String(value).split(/[\\/]/).pop() === rowItem.filename))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.type && rowItem.type !== this.type) {
|
||||
|
||||
@@ -101,7 +101,7 @@ export class NodeUsageAnalyzer {
|
||||
|
||||
".nu-manager-stop": {
|
||||
click: () => {
|
||||
api.fetchApi('/manager/queue/reset');
|
||||
api.fetchApi('/manager/queue/reset', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
|
||||
infoToast('Cancel', 'Remaining tasks will stop after completing the current task.');
|
||||
}
|
||||
},
|
||||
@@ -340,7 +340,7 @@ export class NodeUsageAnalyzer {
|
||||
let needRefresh = false;
|
||||
let errorMsg = "";
|
||||
|
||||
await api.fetchApi('/manager/queue/reset');
|
||||
await api.fetchApi('/manager/queue/reset', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
|
||||
|
||||
let target_items = [];
|
||||
|
||||
@@ -388,7 +388,7 @@ export class NodeUsageAnalyzer {
|
||||
}
|
||||
}
|
||||
else {
|
||||
await api.fetchApi('/manager/queue/start');
|
||||
await api.fetchApi('/manager/queue/start', { method: 'POST', headers: { 'Content-Type': 'application/json' } });
|
||||
this.ui.showStop();
|
||||
showTerminal();
|
||||
}
|
||||
@@ -610,6 +610,13 @@ export class NodeUsageAnalyzer {
|
||||
Object.keys(node_packs).forEach((packKey, index) => {
|
||||
const pack = node_packs[packKey];
|
||||
|
||||
// packs that aren't in the node DB come back without an 'id'; the uninstall
|
||||
// endpoint keys off it, so backfill it from the pack key (as the custom node
|
||||
// manager does) or the uninstall is queued against a null node name
|
||||
if (pack.id === undefined) {
|
||||
pack.id = packKey;
|
||||
}
|
||||
|
||||
// Only include installed packages (filter out "not-installed" packages)
|
||||
if (pack.state === "not-installed") {
|
||||
return; // Skip non-installed packages
|
||||
@@ -625,6 +632,7 @@ export class NodeUsageAnalyzer {
|
||||
used_in_count: usedCount,
|
||||
workflowDetails: workflowDetails,
|
||||
name: packKey,
|
||||
hash: md5(packKey),
|
||||
originalData: pack
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ class WorkflowMetadataExtension {
|
||||
this.installedNodes[nodePackageName.toLowerCase()] ??
|
||||
{};
|
||||
|
||||
if (cnr_id === "comfy-core") return; // don't allow hijacking comfy-core name
|
||||
if (cnr_id?.toLowerCase() === "comfy-core") return; // don't allow hijacking comfy-core name
|
||||
if (cnr_id) nodeProperties.cnr_id = cnr_id;
|
||||
else nodeProperties.aux_id = aux_id;
|
||||
if (ver) nodeProperties.ver = ver.trim();
|
||||
|
||||
@@ -805,16 +805,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "Audio duration analysis node. (Description by CC)\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "lunaaispace-eng",
|
||||
"title": "LLM_Prompt [WIP]",
|
||||
"reference": "https://github.com/lunaaispace-eng/LLM_Prompt",
|
||||
"files": [
|
||||
"https://github.com/lunaaispace-eng/LLM_Prompt"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "LLM prompt node for ComfyUI. (Description by CC)\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "lyeeedar",
|
||||
"title": "Keep Largest Blob [WIP]",
|
||||
@@ -865,16 +855,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "A ComfyUI custom node that routes detected face SEGS to separate outputs by matching each face crop to text prompts via CLIP image-text cosine similarity.\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "Agnuxo1",
|
||||
"title": "silicon-comfyui-node [WIP]",
|
||||
"reference": "https://github.com/Agnuxo1/silicon-comfyui-node",
|
||||
"files": [
|
||||
"https://github.com/Agnuxo1/silicon-comfyui-node"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A ComfyUI custom node that embeds and verifies cryptographic watermarks in images using SiliconSignature technology.\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "Bigornh2o",
|
||||
"title": "ComfyUI-Bigornh2oSmartResolution [WIP]",
|
||||
@@ -2538,16 +2518,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom node for sending generated videos to Telegram, enabling direct output sharing to messaging platforms. (Description by CC)[w/This nodepack contains a node that has a vulnerability allowing write to arbitrary file paths.]"
|
||||
},
|
||||
{
|
||||
"author": "Laolilzp",
|
||||
"title": "Laoli3D [UNSAFE]",
|
||||
"reference": "https://github.com/Laolilzp/Laoli3D",
|
||||
"files": [
|
||||
"https://github.com/Laolilzp/Laoli3D"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI 3D pose editor enabling visual character manipulation and ControlNet image generation for precise AI figure control without prompt description. (Description by CC)[w/This nodepack contains a node that has a vulnerability allowing write to arbitrary file paths.]"
|
||||
},
|
||||
{
|
||||
"author": "Goldlionren",
|
||||
"title": "ComfyUI_Bridge_fabric [UNSAFE]",
|
||||
@@ -7155,16 +7125,6 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "A collection of utility nodes for handling condition tensors in ComfyUI."
|
||||
},
|
||||
{
|
||||
"author": "gordon123",
|
||||
"title": "ComfyUI_DreamBoard [WIP]",
|
||||
"reference": "https://github.com/gordon123/ComfyUI_DreamBoard",
|
||||
"files": [
|
||||
"https://github.com/gordon123/ComfyUI_DreamBoard"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "for making storyboard UNDERCONSTRUCTION!"
|
||||
},
|
||||
{
|
||||
"author": "erosDiffusion",
|
||||
"title": "Select key from JSON (Alpha) [UNSAFE]",
|
||||
|
||||
@@ -1,5 +1,254 @@
|
||||
{
|
||||
"custom_nodes": [
|
||||
{
|
||||
"author": "lunaaispace-eng",
|
||||
"title": "LLM_Prompt [WIP] [REMOVED]",
|
||||
"reference": "https://github.com/lunaaispace-eng/LLM_Prompt",
|
||||
"files": [
|
||||
"https://github.com/lunaaispace-eng/LLM_Prompt"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "LLM prompt node for ComfyUI. (Description by CC)\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "Laolilzp",
|
||||
"title": "Laoli3D [UNSAFE] [REMOVED]",
|
||||
"reference": "https://github.com/Laolilzp/Laoli3D",
|
||||
"files": [
|
||||
"https://github.com/Laolilzp/Laoli3D"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI 3D pose editor enabling visual character manipulation and ControlNet image generation for precise AI figure control without prompt description. (Description by CC)[w/This nodepack contains a node that has a vulnerability allowing write to arbitrary file paths.]"
|
||||
},
|
||||
{
|
||||
"author": "gordon123",
|
||||
"title": "ComfyUI_DreamBoard [WIP] [REMOVED]",
|
||||
"reference": "https://github.com/gordon123/ComfyUI_DreamBoard",
|
||||
"files": [
|
||||
"https://github.com/gordon123/ComfyUI_DreamBoard"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "for making storyboard UNDERCONSTRUCTION!"
|
||||
},
|
||||
{
|
||||
"author": "Agnuxo1",
|
||||
"title": "silicon-comfyui-node [WIP] [REMOVED]",
|
||||
"reference": "https://github.com/Agnuxo1/silicon-comfyui-node",
|
||||
"files": [
|
||||
"https://github.com/Agnuxo1/silicon-comfyui-node"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A ComfyUI custom node that embeds and verifies cryptographic watermarks in images using SiliconSignature technology.\nNOTE: The files in the repo are not organized."
|
||||
},
|
||||
{
|
||||
"author": "Zeknes",
|
||||
"title": "Comfyui-LLM-Chat [REMOVED]",
|
||||
"reference": "https://github.com/Zeknes/Comfyui-LLM-Chat",
|
||||
"files": [
|
||||
"https://github.com/Zeknes/Comfyui-LLM-Chat"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Custom ComfyUI node providing unified access to multiple Large Language Models including OpenAI-compatible APIs and local Ollama instances with image support."
|
||||
},
|
||||
{
|
||||
"author": "toxicwind",
|
||||
"title": "TTools for ComfyUI [REMOVED]",
|
||||
"id": "ttools",
|
||||
"reference": "https://github.com/toxicwind/ComfyUI-TTools",
|
||||
"files": [
|
||||
"https://github.com/toxicwind/ComfyUI-TTools"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text Randomization and Formatting, JSON Extraction and Processing, SD3 Resolution Solver"
|
||||
},
|
||||
{
|
||||
"author": "StarIICraft",
|
||||
"title": "ComfyUI-Simple-Selector [REMOVED]",
|
||||
"reference": "https://github.com/StarIICraft/ComfyUI-Simple-Selector",
|
||||
"files": [
|
||||
"https://github.com/StarIICraft/ComfyUI-Simple-Selector"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Logic control node with 5 universal input ports that checks connections in reverse priority order and outputs the index of the first valid active input, with support for muted nodes and any data type."
|
||||
},
|
||||
{
|
||||
"author": "latentastronaut",
|
||||
"title": "comfyui-latent-astronaut-suite [REMOVED]",
|
||||
"reference": "https://github.com/latentastronaut/comfyui-latent-astronaut-suite",
|
||||
"files": [
|
||||
"https://github.com/latentastronaut/comfyui-latent-astronaut-suite"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI nodes for batch processing, loops, and iteration workflows"
|
||||
},
|
||||
{
|
||||
"author": "isam2024",
|
||||
"title": "ComfyUI-FluxHallucinate [REMOVED]",
|
||||
"reference": "https://github.com/isam2024/ComfyUI-FluxHallucinate",
|
||||
"files": [
|
||||
"https://github.com/isam2024/ComfyUI-FluxHallucinate"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Intentionally degrade Flux dev.1's prompt adherence to recreate the loose, random, *hallucinatory* feel of SD1.5 / SDXL."
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Clone Output [REMOVED]",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-clone-output",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-clone-output"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Clone Output"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Booleangate [REMOVED]",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-booleangate",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-booleangate"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Booleangate"
|
||||
},
|
||||
{
|
||||
"author": "IA-gyz",
|
||||
"title": "Magik Basic Nodes [REMOVED]",
|
||||
"reference": "https://github.com/IA-gyz/comfyui-magik-basic-nodes",
|
||||
"files": [
|
||||
"https://github.com/IA-gyz/comfyui-magik-basic-nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Magik Basic Nodes"
|
||||
},
|
||||
{
|
||||
"author": "huygiatrng",
|
||||
"title": "Facefusion_comfyui [REMOVED]",
|
||||
"reference": "https://github.com/huygiatrng/Facefusion_comfyui",
|
||||
"files": [
|
||||
"https://github.com/huygiatrng/Facefusion_comfyui"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Advanced face swapping for ComfyUI with local ONNX inference - no API required!"
|
||||
},
|
||||
{
|
||||
"author": "Herony82",
|
||||
"title": "WanAnimatePreprocess Track [REMOVED]",
|
||||
"reference": "https://github.com/Herony82/ComfyUI-WanAnimatePreprocess-track",
|
||||
"files": [
|
||||
"https://github.com/Herony82/ComfyUI-WanAnimatePreprocess-track"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "TrackedPoseAndFaceDetection - PoseAndFaceDetection con selezione manuale dei punti di tracking e optical flow (Lucas-Kanade). Richiede ComfyUI-WanAnimatePreprocess."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-Veida [REMOVED]",
|
||||
"id": "comfyui-veida",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-Veida",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-Veida"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images through the Veida AI API. Works without an API key on the free tier; add a key to use your account's models (GPT Image 2.5, GPT Image 2, Nano Banana 2, Seedream 5.0)."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-SayMaker [REMOVED]",
|
||||
"id": "comfyui-saymaker",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-SayMaker",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-SayMaker"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images and animate them into video through the SayMaker API (Veo 3.1, Kling 3.0, Seedance 2.0, Nano Banana 2, GPT Image 2.5). No local GPU; needs a SayMaker API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-movoa [REMOVED]",
|
||||
"id": "comfyui-movoa",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-movoa",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-movoa"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to video and photo to video with sound via Movoa (movoa.ai). Standard library only; requires a Movoa API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-Kavel [REMOVED]",
|
||||
"id": "comfyui-kavel",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-Kavel",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-Kavel"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images through the kavel.ai API. Works without an API key on the free tier; add a key to use your account's models (Nano Banana 2, GPT Image 2, Seedream)."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-FreeImageToVideo [REMOVED]",
|
||||
"id": "comfyui-freeimagetovideo",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-FreeImageToVideo",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-FreeImageToVideo"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to video and image to video with sound (MiniMax H3) through the Free Image to Video API: connect any IMAGE as the first frame or leave it empty for text to video; the MP4 is saved to the output folder. No local GPU; needs a Free Image to Video API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-emaki [REMOVED]",
|
||||
"id": "comfyui-emaki",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-emaki",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-emaki"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Seedance 2.5 text to video and image to video through the emaki API (Seedance 2.0, MiniMax H3, Veo 3.1 and Nano Banana 2 for first frames too). No local GPU; needs an emaki API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-aigifmaker [REMOVED]",
|
||||
"id": "comfyui-aigifmaker",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-aigifmaker",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-aigifmaker"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Text to animated GIF through the AI GIF Maker API (native GIF generation, not a converted video). Outputs every frame as an IMAGE batch plus the saved .gif. No local GPU; needs an AI GIF Maker API key."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
"title": "ComfyUI-abvg [REMOVED]",
|
||||
"id": "comfyui-abvg",
|
||||
"reference": "https://github.com/hanshs474/ComfyUI-abvg",
|
||||
"files": [
|
||||
"https://github.com/hanshs474/ComfyUI-abvg"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "AI birthday video generator from a single photo: they pop champagne on a park bench, blow out a Scorpio cake, or light a crown cake at the car window. Generate 12s 720p vertical birthday clips on Seedance 2 Mini via https://aibirthdayvideogenerator.com/."
|
||||
},
|
||||
{
|
||||
"author": "evanscho",
|
||||
"title": "Advanced Mask Nodes [REMOVED]",
|
||||
"reference": "https://github.com/evanscho/ComfyUI-advanced-mask-nodes",
|
||||
"files": [
|
||||
"https://github.com/evanscho/ComfyUI-advanced-mask-nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A collection of custom nodes for ComfyUI"
|
||||
},
|
||||
{
|
||||
"author": "Ave-Mollan",
|
||||
"title": "civitai-sdk-api-nodes-for-comfyui [REMOVED]",
|
||||
"reference": "https://github.com/Ave-Mollan/CivitAI-SDK-API-nodes-for-ComfyUI",
|
||||
"files": [
|
||||
"https://github.com/Ave-Mollan/CivitAI-SDK-API-nodes-for-ComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom nodes for CivitAI cloud image generation via API"
|
||||
},
|
||||
{
|
||||
"author": "papcorns",
|
||||
"title": "ComfyUI-Papcorns-Node-UploadToGCS [REMOVED]",
|
||||
|
||||
@@ -1,5 +1,275 @@
|
||||
{
|
||||
"custom_nodes": [
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "GPT Image",
|
||||
"id": "gpt-image",
|
||||
"reference": "https://github.com/AceDataCloud/GPTImageComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GPTImageComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit images with GPT Image, retrieve task results, and load the resulting images in ComfyUI. Requires an Ace Data Cloud API key. Generation and editing are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "ACE Music",
|
||||
"id": "ace-acemusic",
|
||||
"reference": "https://github.com/AceDataCloud/ACEMusicComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/ACEMusicComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate ACE Music songs and lyrics, import reference assets, and retrieve results by task ID. Requires an Ace Data Cloud API key. Generation and reference imports are metered."
|
||||
},
|
||||
{
|
||||
"author": "assetfeed",
|
||||
"title": "AssetFeed",
|
||||
"reference": "https://github.com/assetfeed/comfyui-assetfeed",
|
||||
"files": [
|
||||
"https://github.com/assetfeed/comfyui-assetfeed"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Nodes for the AssetFeed API: AssetFeed OCR reads the text in an image, and AssetFeed AI Text Check estimates the AI-written share of an English text. Needs an ASSETFEED_API_KEY environment variable; images and text are sent to api.assetfeed.com; data handling is in the README."
|
||||
},
|
||||
{
|
||||
"author": "Raykosan (RaykoStudio)",
|
||||
"title": "ComfyUI-RS_WorkspaceManager",
|
||||
"reference": "https://github.com/Raykosan/ComfyUI-RS_WorkspaceManager",
|
||||
"files": [
|
||||
"https://github.com/Raykosan/ComfyUI-RS_WorkspaceManager"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Workflow Preset Manager and Interface Settings Backup for ComfyUI."
|
||||
},
|
||||
{
|
||||
"author": "bewizsky",
|
||||
"title": "Eyes4AI Text Repair",
|
||||
"reference": "https://github.com/bewizsky/eyes4ai-text-repair",
|
||||
"files": [
|
||||
"https://github.com/bewizsky/eyes4ai-text-repair"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Find misspelled text in photos and AI-generated images with Gemini, then use an image-editing workflow to fix localized text and review spelling and style. Includes check-only and SenseNova U1.6 examples."
|
||||
},
|
||||
{
|
||||
"author": "ukr8b3g-cmyk",
|
||||
"title": "Anima Character Sheet Designer",
|
||||
"reference": "https://github.com/ukr8b3g-cmyk/Anima-Character-Sheet-Designer",
|
||||
"files": [
|
||||
"https://github.com/ukr8b3g-cmyk/Anima-Character-Sheet-Designer"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create character sheets in ComfyUI with Anima, using prompt text or local image tags. Generate up to 13 independent views with editable prompts and assemble them into a sheet."
|
||||
},
|
||||
{
|
||||
"author": "alaintural",
|
||||
"title": "SyncTile for MiniMax H3",
|
||||
"id": "synctile-h3",
|
||||
"reference": "https://github.com/alaintural/synctile-h3",
|
||||
"files": [
|
||||
"https://github.com/alaintural/synctile-h3"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "SyncTileRefine takes a MiniMax H3 video to 1080p, 2K or 4K on one 24 GB card. Overlapping tiles are blended in latent space after every sampling step, so the result has no seams. A ready workflow is included."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Wan",
|
||||
"id": "wan",
|
||||
"reference": "https://github.com/AceDataCloud/WanComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/WanComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Wan videos and retrieve task results. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Veo",
|
||||
"id": "veo",
|
||||
"reference": "https://github.com/AceDataCloud/VeoComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/VeoComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate a Veo video and check its task status. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Seedream",
|
||||
"id": "seedream",
|
||||
"reference": "https://github.com/AceDataCloud/SeedreamComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/SeedreamComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create, edit or decompose images with Seedream. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Seedance",
|
||||
"id": "ace-seedance",
|
||||
"reference": "https://github.com/AceDataCloud/SeedanceComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/SeedanceComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate a Seedance video and load the completed video from its task ID. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Qwen Image",
|
||||
"id": "qwen-image",
|
||||
"reference": "https://github.com/AceDataCloud/QwenImageComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/QwenImageComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit an image with Qwen Image. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Nano Banana",
|
||||
"id": "nano-banana",
|
||||
"reference": "https://github.com/AceDataCloud/NanoBananaComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/NanoBananaComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit images with Nano Banana and load completed images. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "MiniMax H3",
|
||||
"id": "ace-minimax-h3",
|
||||
"reference": "https://github.com/AceDataCloud/MiniMaxH3ComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/MiniMaxH3ComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate MiniMax H3 videos and retrieve task results. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Midjourney",
|
||||
"id": "midjourney",
|
||||
"reference": "https://github.com/AceDataCloud/MidjourneyComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/MidjourneyComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Midjourney images and retrieve the original task. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Kling",
|
||||
"id": "kling",
|
||||
"reference": "https://github.com/AceDataCloud/KlingComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/KlingComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate or edit Kling videos and retrieve task results. Requires an Ace Data Cloud API key. Video requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Happy Horse",
|
||||
"id": "happy-horse",
|
||||
"reference": "https://github.com/AceDataCloud/HappyHorseComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/HappyHorseComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate and edit Happy Horse videos and retrieve the original task. Requires an Ace Data Cloud API key. Video requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Grok",
|
||||
"id": "grok",
|
||||
"reference": "https://github.com/AceDataCloud/GrokComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GrokComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate Grok videos and retrieve the result of a submitted task. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Google Search",
|
||||
"id": "google-search",
|
||||
"reference": "https://github.com/AceDataCloud/GoogleSearchComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/GoogleSearchComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Search Google from a workflow and return structured results. Requires an Ace Data Cloud API key. Searches are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Flux",
|
||||
"id": "flux",
|
||||
"reference": "https://github.com/AceDataCloud/FluxComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FluxComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Create images with FLUX through the hosted API. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Fish Audio",
|
||||
"id": "fish-audio",
|
||||
"reference": "https://github.com/AceDataCloud/FishAudioComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FishAudioComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Generate speech with Fish Audio and retrieve the resulting audio. Requires an Ace Data Cloud API key. Generation is metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Face Transform",
|
||||
"id": "face-transform",
|
||||
"reference": "https://github.com/AceDataCloud/FaceTransformComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/FaceTransformComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Analyze or transform a face in a supplied image. Requires an Ace Data Cloud API key. Image requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Ace Chat",
|
||||
"id": "ace-chat",
|
||||
"reference": "https://github.com/AceDataCloud/AceChatComfyUI",
|
||||
"files": [
|
||||
"https://github.com/AceDataCloud/AceChatComfyUI"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "List chat model IDs and send chat messages from a ComfyUI workflow. Requires an Ace Data Cloud API key. Chat requests are metered."
|
||||
},
|
||||
{
|
||||
"author": "2867297362mjb-sketch",
|
||||
"title": "comfyui-teamorouter",
|
||||
"reference": "https://github.com/2867297362mjb-sketch/comfyui-teamorouter",
|
||||
"files": [
|
||||
"https://github.com/2867297362mjb-sketch/comfyui-teamorouter"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A chat node for the TeamoRouter API: write or expand prompts, caption an input image with a vision model, or translate text with Claude, GPT, Gemini, DeepSeek, GLM, Kimi or Qwen through one OpenAI-compatible API key. You need your own TeamoRouter API key and prepaid balance. No extra dependencies."
|
||||
},
|
||||
{
|
||||
"author": "Zrn59",
|
||||
"title": "ComfyUI-GGUF-Next",
|
||||
"id": "comfyui-gguf-next",
|
||||
"reference": "https://github.com/Zrn59/ComfyUI-GGUF-Next",
|
||||
"files": [
|
||||
"https://github.com/Zrn59/ComfyUI-GGUF-Next"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Fork of city96/ComfyUI-GGUF with the same node IDs: all 35 ggml quant types dequantized in torch on the GPU (IQ1/IQ2/IQ3, TQ, MXFP4, NVFP4), any diffusion architecture ComfyUI detects, more text encoders (Gemma 2, Qwen2, Mistral 3, Qwen3-VL incl. 32B, the Gemma 4 encoder of LTX-2.5), and models bigger than RAM kept memory-mapped. Disable the original ComfyUI-GGUF first: both register the same node names."
|
||||
},
|
||||
{
|
||||
"author": "sorryhyun",
|
||||
"title": "Anima Pixel Decoder",
|
||||
@@ -569,12 +839,12 @@
|
||||
},
|
||||
{
|
||||
"author": "Statite",
|
||||
"title": "ComfyUI-SpecAR",
|
||||
"title": "ComfyUI-StrideAR",
|
||||
"id": "comfyui-specar",
|
||||
"reference": "https://github.com/statite-ai/ComfyUI-SpecAR",
|
||||
"files": ["https://github.com/statite-ai/ComfyUI-SpecAR"],
|
||||
"reference": "https://github.com/statite-ai/ComfyUI-StrideAR",
|
||||
"files": ["https://github.com/statite-ai/ComfyUI-StrideAR"],
|
||||
"install_type": "git-clone",
|
||||
"description": "SpecAR: Training-free 2.04x-2.81x speedup on Krea Realtime 14B + Self-Forcing 1.3B (up to 23.1 FPS real-time on B200, 2.67x on H100) with lazy target KV caching and low-VRAM offload."
|
||||
"description": "StrideAR: Training-free 2.04x-2.81x speedup on Krea Realtime 14B + Self-Forcing 1.3B (up to 23.1 FPS real-time on B200, 2.67x on H100) with lazy target KV caching and low-VRAM offload."
|
||||
},
|
||||
{
|
||||
"author": "hanshs474",
|
||||
@@ -1502,7 +1772,7 @@
|
||||
},
|
||||
{
|
||||
"author": "AceDataCloud",
|
||||
"title": "Suno by Ace Data Cloud",
|
||||
"title": "Suno",
|
||||
"id": "ace-suno",
|
||||
"reference": "https://github.com/AceDataCloud/SunoComfyUI",
|
||||
"files": [
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
"!echo -= Install dependencies =-\n",
|
||||
"!pip3 install accelerate\n",
|
||||
"!pip3 install einops transformers>=4.28.1 safetensors>=0.4.2 aiohttp pyyaml Pillow scipy tqdm psutil tokenizers>=0.13.3\n",
|
||||
"!pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121\n",
|
||||
"!pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu121\n",
|
||||
"!pip3 install torchsde\n",
|
||||
"!pip3 install kornia>=0.7.1 spandrel soundfile sentencepiece\n",
|
||||
"\n",
|
||||
|
||||
@@ -305,22 +305,6 @@ paths:
|
||||
'500':
|
||||
description: Error occurred
|
||||
|
||||
/customnode/alternatives:
|
||||
get:
|
||||
summary: Get alternative node options
|
||||
description: Provides alternatives for nodes
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/modeParam'
|
||||
responses:
|
||||
'200':
|
||||
description: Successful operation
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: object
|
||||
|
||||
/customnode/versions/{node_name}:
|
||||
get:
|
||||
summary: Get available versions for a node
|
||||
|
||||
+40
-22
@@ -51,6 +51,11 @@ message_collapses = [skip_pip_spam]
|
||||
import_failed_extensions = set()
|
||||
cm_global.variables['cm.on_revision_detected_handler'] = []
|
||||
enable_file_logging = True
|
||||
# When file logging is on, strip ANSI color/escape codes from the bytes written to
|
||||
# the disk log so the file stays plain and readable. The console ALWAYS keeps its
|
||||
# original (colored) output -- this only ever touches the file branch of sync_write.
|
||||
# Default on; set `strip_ansi_file_logging = False` in config.ini to keep ANSI in the file.
|
||||
strip_ansi_file_logging = True
|
||||
|
||||
|
||||
def register_message_collapse(f):
|
||||
@@ -132,12 +137,18 @@ def set_git_executable():
|
||||
if git_exe is not None:
|
||||
os.environ['GIT_PYTHON_GIT_EXECUTABLE'] = git_exe
|
||||
|
||||
def check_strip_ansi_file_logging():
|
||||
global strip_ansi_file_logging
|
||||
if 'strip_ansi_file_logging' in default_conf and default_conf['strip_ansi_file_logging'].lower() == 'false':
|
||||
strip_ansi_file_logging = False
|
||||
|
||||
|
||||
read_config()
|
||||
set_git_executable()
|
||||
read_uv_mode()
|
||||
security_check.security_check()
|
||||
check_file_logging()
|
||||
check_strip_ansi_file_logging()
|
||||
|
||||
cm_global.pip_overrides = {}
|
||||
|
||||
@@ -154,15 +165,6 @@ if os.path.exists(manager_pip_blacklist_path):
|
||||
cm_global.pip_blacklist.add(y)
|
||||
|
||||
|
||||
def remap_pip_package(pkg):
|
||||
if pkg in cm_global.pip_overrides:
|
||||
res = cm_global.pip_overrides[pkg]
|
||||
print(f"[ComfyUI-Manager] '{pkg}' is remapped to '{res}'")
|
||||
return res
|
||||
else:
|
||||
return pkg
|
||||
|
||||
|
||||
std_log_lock = threading.Lock()
|
||||
|
||||
|
||||
@@ -290,6 +292,14 @@ try:
|
||||
pat_tqdm = r'\d+%.*\[(.*?)\]'
|
||||
pat_import_fail = r'seconds \(IMPORT FAILED\):(.*)$'
|
||||
|
||||
# CSI (ECMA-48) escape sequences: ESC [ <params: digits/;/> <?> <final letter>.
|
||||
# Covers SGR colors (\x1b[31m, \x1b[0m, \x1b[1;32m), private modes (\x1b[?25l),
|
||||
# cursor moves and erase codes (\x1b[2J, \x1b[0K). It never matches a real '\n',
|
||||
# so line structure/timestamps are untouched. Self-contained on purpose -- we do
|
||||
# NOT route this through colorama, which is the exact dependency that proved
|
||||
# unreliable in issue #3259.
|
||||
pat_ansi = r'\x1b\[[0-9;?]*[a-zA-Z]'
|
||||
|
||||
is_start_mode = True
|
||||
|
||||
|
||||
@@ -396,15 +406,26 @@ try:
|
||||
except OSError:
|
||||
self.console_is_gone = True
|
||||
|
||||
def _file_message(self, message):
|
||||
# The exact bytes that go to the disk log. When strip_ansi_file_logging
|
||||
# is on, ANSI escape sequences are removed so the file is plain and
|
||||
# readable. This is the ONLY place the file content diverges from what
|
||||
# the console receives -- the console path below always uses the
|
||||
# original, unmodified message, so its coloring is never affected.
|
||||
if strip_ansi_file_logging:
|
||||
return re.sub(pat_ansi, '', message)
|
||||
return message
|
||||
|
||||
def sync_write(self, message, file_only=False):
|
||||
with log_lock:
|
||||
# after close_log() the output goes to the console only
|
||||
if not log_file.closed:
|
||||
file_message = self._file_message(message)
|
||||
timestamp = current_timestamp()
|
||||
if self.last_char != '\n':
|
||||
log_file.write(message)
|
||||
log_file.write(file_message)
|
||||
else:
|
||||
log_file.write(f"[{timestamp}] {message}")
|
||||
log_file.write(f"[{timestamp}] {file_message}")
|
||||
|
||||
try:
|
||||
log_file.flush()
|
||||
@@ -713,16 +734,9 @@ def execute_lazy_install_script(repo_path, executable):
|
||||
|
||||
lines = manager_util.robust_readlines(requirements_path)
|
||||
for line in lines:
|
||||
package_name = remap_pip_package(line.strip())
|
||||
package_name = package_name.split('#')[0].strip()
|
||||
if package_name and not is_installed(package_name):
|
||||
if '--index-url' in package_name:
|
||||
s = package_name.split('--index-url')
|
||||
install_cmd = manager_util.make_pip_cmd(["install", s[0].strip(), '--index-url', s[1].strip()])
|
||||
else:
|
||||
install_cmd = manager_util.make_pip_cmd(["install", package_name])
|
||||
|
||||
process_wrap(install_cmd, repo_path)
|
||||
install_args = manager_util.pip_install_args(line, cm_global.pip_overrides)
|
||||
if install_args and not is_installed(install_args[0]):
|
||||
process_wrap(manager_util.make_pip_cmd(["install", *install_args]), repo_path)
|
||||
|
||||
if os.path.exists(install_script_path) and f'{repo_path}/install.py' not in processed_install:
|
||||
processed_install.add(f'{repo_path}/install.py')
|
||||
@@ -751,7 +765,11 @@ def execute_lazy_cnr_switch(target, zip_url, from_path, to_path, no_deps, custom
|
||||
# 1. download
|
||||
archive_name = f"CNR_temp_{str(uuid.uuid4())}.zip" # should be unpredictable name - security precaution
|
||||
download_path = os.path.join(custom_nodes_path, archive_name)
|
||||
manager_downloader.download_url(zip_url, custom_nodes_path, archive_name)
|
||||
try:
|
||||
manager_downloader.download_url(zip_url, custom_nodes_path, archive_name)
|
||||
except Exception:
|
||||
manager_downloader.remove_failed_download(custom_nodes_path, archive_name)
|
||||
raise
|
||||
|
||||
try:
|
||||
extracted = manager_util.switch_package_files(download_path, from_path)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-manager"
|
||||
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
||||
version = "3.43.3"
|
||||
version = "3.44"
|
||||
license = { file = "LICENSE.txt" }
|
||||
requires-python = ">=3.9"
|
||||
dependencies = ["GitPython", "PyGithub", "matrix-nio", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet", "packaging", "nh3>=0.3.7"]
|
||||
|
||||
@@ -4,7 +4,7 @@ git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
|
||||
cd ..
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130
|
||||
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu130
|
||||
python -m pip install -r requirements.txt
|
||||
python -m pip install -r custom_nodes/comfyui-manager/requirements.txt
|
||||
cd ..
|
||||
|
||||
@@ -4,7 +4,7 @@ git clone https://github.com/ltdrdata/ComfyUI-Manager comfyui-manager
|
||||
cd ..
|
||||
python -m venv venv
|
||||
call venv/Scripts/activate
|
||||
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu130
|
||||
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cu130
|
||||
python -m pip install -r requirements.txt
|
||||
python -m pip install -r custom_nodes/comfyui-manager/requirements.txt
|
||||
cd ..
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from test_install_flags_config import _run_child
|
||||
|
||||
posix_folder = pytest.mark.skipif(os.name == 'nt', reason='the folder that aria2 gets is a POSIX path')
|
||||
|
||||
|
||||
PRELUDE = '''
|
||||
import time
|
||||
md = manager_core.manager_downloader
|
||||
manager_core.comfy_path = tmp
|
||||
time.sleep = lambda seconds: None
|
||||
LOCAL = os.path.join(tmp, 'models', 'checkpoints', 'y.safetensors')
|
||||
TARGET = '/models/checkpoints/y.safetensors'
|
||||
|
||||
class FakeDownload:
|
||||
def __init__(self, statuses, local_file=None, error_message=None, target=None):
|
||||
self._statuses = list(statuses)
|
||||
self.status = self._statuses.pop(0)
|
||||
self._local_file = local_file
|
||||
self.error_message = error_message
|
||||
self.total_length = 10
|
||||
self.completed_length = 0
|
||||
self.files = [type('F', (), {'is_metadata': False, 'path': target})()] if target else []
|
||||
self._write_if_complete()
|
||||
|
||||
def _write_if_complete(self):
|
||||
if self.status == 'complete' and self._local_file:
|
||||
os.makedirs(os.path.dirname(self._local_file), exist_ok=True)
|
||||
open(self._local_file, 'wb').close()
|
||||
|
||||
is_active = property(lambda self: self.status == 'active')
|
||||
is_waiting = property(lambda self: self.status == 'waiting')
|
||||
has_failed = property(lambda self: self.status == 'error')
|
||||
is_complete = property(lambda self: self.status == 'complete')
|
||||
|
||||
def update(self):
|
||||
if self._statuses:
|
||||
self.status = self._statuses.pop(0)
|
||||
self._write_if_complete()
|
||||
|
||||
class FakeAria2:
|
||||
def __init__(self, new, existing=()):
|
||||
self.new, self.existing, self.added = new, list(existing), []
|
||||
|
||||
def get_downloads(self):
|
||||
return self.existing
|
||||
|
||||
def add(self, url, options):
|
||||
self.added.append(dict(options))
|
||||
return [self.new]
|
||||
|
||||
def install(fake):
|
||||
md.aria2 = fake
|
||||
error = None
|
||||
try:
|
||||
md.download_url('https://huggingface.co/x/y.safetensors', os.path.dirname(LOCAL), 'y.safetensors')
|
||||
except Exception as e:
|
||||
error = str(e)
|
||||
print(json.dumps({'error': error, 'added': fake.added, 'status': fake.new.status, 'file': os.path.exists(LOCAL)}))
|
||||
'''
|
||||
|
||||
|
||||
def run(body):
|
||||
return _run_child(PRELUDE + body)
|
||||
|
||||
|
||||
def test_a_download_that_aria2_fails_raises_with_its_message():
|
||||
data = run('''
|
||||
install(FakeAria2(FakeDownload(['error'], error_message='Failed to make the directory /models/checkpoints, cause: Permission denied')))
|
||||
''')
|
||||
assert 'Permission denied' in data['error'], data
|
||||
|
||||
|
||||
@pytest.mark.parametrize('status', ['paused', 'removed'])
|
||||
def test_a_download_that_was_stopped_with_a_part_of_the_file_there_raises(status):
|
||||
data = run(f'''
|
||||
os.makedirs(os.path.dirname(LOCAL))
|
||||
open(LOCAL, 'wb').close()
|
||||
install(FakeAria2(FakeDownload(['active', {status!r}])))
|
||||
''')
|
||||
assert status in data['error'], data
|
||||
|
||||
|
||||
def test_a_file_that_aria2_saved_elsewhere_raises():
|
||||
data = run('''
|
||||
install(FakeAria2(FakeDownload(['complete'])))
|
||||
''')
|
||||
assert 'y.safetensors' in data['error'] and 'docs/en/use_aria2.md' in data['error'], data
|
||||
|
||||
|
||||
@posix_folder
|
||||
def test_a_queued_download_is_waited_for():
|
||||
data = run('''
|
||||
install(FakeAria2(FakeDownload(['waiting', 'active', 'complete'], local_file=LOCAL)))
|
||||
''')
|
||||
assert data == {'error': None, 'added': [{'dir': '/models/checkpoints', 'out': 'y.safetensors'}], 'status': 'complete', 'file': True}
|
||||
|
||||
|
||||
@posix_folder
|
||||
def test_a_failed_earlier_download_is_not_reused():
|
||||
data = run('''
|
||||
install(FakeAria2(FakeDownload(['complete'], local_file=LOCAL), existing=[FakeDownload(['error'], target=TARGET)]))
|
||||
''')
|
||||
assert data['error'] is None and len(data['added']) == 1, data
|
||||
|
||||
|
||||
@posix_folder
|
||||
def test_a_finished_earlier_download_whose_file_is_there_is_reused():
|
||||
data = run('''
|
||||
os.makedirs(os.path.dirname(LOCAL))
|
||||
open(LOCAL, 'wb').close()
|
||||
install(FakeAria2(FakeDownload(['complete']), existing=[FakeDownload(['complete'], target=TARGET)]))
|
||||
''')
|
||||
assert data['error'] is None and data['added'] == [], data
|
||||
|
||||
|
||||
@posix_folder
|
||||
def test_an_earlier_download_that_is_still_queued_is_waited_for():
|
||||
data = run('''
|
||||
install(FakeAria2(FakeDownload(['complete']), existing=[FakeDownload(['waiting', 'active', 'complete'], local_file=LOCAL, target=TARGET)]))
|
||||
''')
|
||||
assert data['error'] is None and data['added'] == [] and data['file'], data
|
||||
|
||||
|
||||
def test_a_nodepack_archive_whose_download_fails_leaves_no_file():
|
||||
data = run('''
|
||||
nodes = os.path.join(tmp, 'custom_nodes')
|
||||
os.makedirs(nodes)
|
||||
manager_core.get_default_custom_nodes_path = lambda: nodes
|
||||
|
||||
class Aria2ThatFailsHalfway(FakeAria2):
|
||||
def add(self, url, options):
|
||||
for name in (options['out'], options['out'] + '.aria2'):
|
||||
open(os.path.join(nodes, name), 'wb').close()
|
||||
return super().add(url, options)
|
||||
|
||||
md.aria2 = Aria2ThatFailsHalfway(FakeDownload(['error'], error_message='the speed was too low'))
|
||||
error = None
|
||||
try:
|
||||
manager_core.UnifiedManager()._cnr_install('fixture', types.SimpleNamespace(version='1.0.0', download_url='https://example.invalid/fixture.zip'))
|
||||
except Exception as e:
|
||||
error = str(e)
|
||||
print(json.dumps({'error': error, 'left': os.listdir(nodes)}))
|
||||
''')
|
||||
assert 'the speed was too low' in data['error'] and data['left'] == [], data
|
||||
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
|
||||
from test_install_flags_config import _run_child
|
||||
|
||||
|
||||
PRELUDE = '''
|
||||
md = manager_core.manager_downloader
|
||||
manager_core.comfy_path = tmp
|
||||
|
||||
class FakeDownload:
|
||||
is_active = is_waiting = has_failed = False
|
||||
is_complete = True
|
||||
|
||||
class FakeAria2:
|
||||
def __init__(self):
|
||||
self.added = []
|
||||
|
||||
def get_downloads(self):
|
||||
return []
|
||||
|
||||
def add(self, url, options):
|
||||
self.added.append(dict(options))
|
||||
return [FakeDownload()]
|
||||
|
||||
def dir_given_to_aria2(model_dir):
|
||||
md.aria2 = FakeAria2()
|
||||
os.makedirs(model_dir, exist_ok=True)
|
||||
open(os.path.join(model_dir, 'y.safetensors'), 'wb').close()
|
||||
md.download_url('https://huggingface.co/x/y.safetensors', model_dir, 'y.safetensors')
|
||||
return md.aria2.added[0]['dir']
|
||||
|
||||
checkpoints = os.path.join(tmp, 'models', 'checkpoints')
|
||||
custom_nodes = os.path.join(tmp, 'custom_nodes')
|
||||
outside = os.path.join(tempfile.mkdtemp(), 'checkpoints')
|
||||
print(json.dumps({
|
||||
'checkpoints': [checkpoints, dir_given_to_aria2(checkpoints)],
|
||||
'custom_nodes': [custom_nodes, dir_given_to_aria2(custom_nodes)],
|
||||
'outside': [outside, dir_given_to_aria2(outside)],
|
||||
}))
|
||||
'''
|
||||
|
||||
|
||||
def run(setting):
|
||||
return _run_child(f"os.environ['COMFYUI_MANAGER_ARIA2_SAME_PATHS'] = {setting!r}\n" + PRELUDE)
|
||||
|
||||
|
||||
def test_by_default_aria2_gets_the_comfyui_folder_as_its_root():
|
||||
for setting in ('', 'false'):
|
||||
data = run(setting)
|
||||
assert data['checkpoints'][1] == os.sep + os.path.join('models', 'checkpoints')
|
||||
assert data['custom_nodes'][1] == os.sep + 'custom_nodes'
|
||||
assert data['outside'][1] == data['outside'][0]
|
||||
|
||||
|
||||
def test_with_same_paths_aria2_gets_each_folder_as_it_is():
|
||||
data = run('true')
|
||||
for local, given in data.values():
|
||||
assert given == local
|
||||
@@ -37,7 +37,7 @@ def load_get_data_by_mode(manager_util, channel_url):
|
||||
assert len(nodes) == 1
|
||||
config = {"channel_url": channel_url, "network_mode": "public"}
|
||||
namespace = {"os": os, "json": json, "manager_util": manager_util,
|
||||
"get_config": lambda: config, "get_channel_dict": lambda: {}}
|
||||
"get_config": lambda: config, "normalize_channel": lambda channel: channel}
|
||||
exec(compile(ast.Module(body=nodes, type_ignores=[]), "manager_core.py", "exec"), namespace)
|
||||
return namespace["get_data_by_mode"]
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def run_the_queue(*tasks):
|
||||
order = []
|
||||
config['model_download_by_agent'] = True
|
||||
core.update_path = lambda path: order.append('ComfyUI is updated') or 'skipped'
|
||||
manager.unified_disable = lambda node_name, is_unknown: order.append('the task') or True
|
||||
manager.unified_disable = lambda node_name, is_unknown: order.append('the task') or core.ManagedResult('disable')
|
||||
manager.unified_update = lambda node_name, node_ver: order.append('the task') or SimpleNamespace(ver='unknown', result=True, action='skip')
|
||||
task_queue = queue.Queue()
|
||||
for task in tasks:
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
from test_snapshot_restore_pins import run
|
||||
|
||||
PACKS = '''
|
||||
import ast, io, traceback
|
||||
from typing_extensions import Annotated, List
|
||||
import typer
|
||||
from rich.console import Console
|
||||
|
||||
def cm_cli(*names):
|
||||
found = [node for node in ast.parse(pathlib.Path('cm-cli.py').read_text(encoding='utf-8')).body if isinstance(node, ast.FunctionDef)
|
||||
and node.name in names]
|
||||
for node in found:
|
||||
node.decorator_list = []
|
||||
out = io.StringIO()
|
||||
scope = {'typer': typer, 'List': List, 'Annotated': Annotated, 'asyncio': asyncio, 'traceback': traceback,
|
||||
'print': Console(file=out, width=1000, color_system=None).print,
|
||||
'cmd_ctx': Mock(no_deps=False), 'unified_manager': manager, 'auto_save_snapshot': AsyncMock()}
|
||||
exec(compile(ast.Module(body=found, type_ignores=[]), 'cm-cli.py', 'exec'), scope)
|
||||
return scope, lambda: [' '.join(line.split()) for line in out.getvalue().splitlines() if 'pack' in line]
|
||||
|
||||
def command(name):
|
||||
scope, said = cm_cli(name, 'for_each_nodes', 'get_all_installed_node_specs', 'enable_node', 'disable_node')
|
||||
scope[name](['all'], None, None, None)
|
||||
return [line.split('=>')[-1].strip() for line in said()]
|
||||
|
||||
for name in ('enabled-pack', '.disabled/registry-pack@1_0_0', '.disabled/rc-pack@1_0_0-rc1', '.disabled/git-pack'):
|
||||
(nodes / name).mkdir(parents=True)
|
||||
manager.active_nodes['enabled-pack'] = ('2.0.0', str(nodes / 'enabled-pack'))
|
||||
manager.cnr_inactive_nodes['registry-pack'] = {'1.0.0': str(nodes / '.disabled/registry-pack@1_0_0')}
|
||||
manager.cnr_inactive_nodes['rc-pack'] = {'1.0.0-rc1': str(nodes / '.disabled/rc-pack@1_0_0-rc1')}
|
||||
manager.unknown_inactive_nodes['git-pack'] = ('https://github.com/owner/git-pack', str(nodes / '.disabled/git-pack'))
|
||||
'''
|
||||
|
||||
|
||||
def all_of(name):
|
||||
return run(PACKS + f'''
|
||||
said = command({name!r})
|
||||
print(json.dumps({{'said': said, 'enabled': sorted(os.listdir(nodes)), 'disabled': sorted(os.listdir(nodes / '.disabled'))}}))
|
||||
''')
|
||||
|
||||
|
||||
def test_enable_all_enables_every_disabled_nodepack():
|
||||
result = all_of('enable')
|
||||
|
||||
assert result['enabled'] == ['.disabled', 'enabled-pack', 'git-pack', 'rc-pack', 'registry-pack']
|
||||
assert result['disabled'] == []
|
||||
assert result['said'][0] == 'Already enabled'
|
||||
|
||||
|
||||
def test_disable_all_disables_every_enabled_nodepack_and_leaves_the_disabled_ones():
|
||||
result = all_of('disable')
|
||||
|
||||
assert result['enabled'] == ['.disabled']
|
||||
assert result['disabled'] == ['enabled-pack@2_0_0', 'git-pack', 'rc-pack@1_0_0-rc1', 'registry-pack@1_0_0']
|
||||
assert result['said'][1:] == ['Already disabled', 'Already disabled', 'Already disabled']
|
||||
|
||||
|
||||
def test_latest_names_the_installed_nodepack_as_a_bare_id_does():
|
||||
result = run(PACKS + '''
|
||||
for name, latest in (('enabled-pack', '3.0.0'), ('registry-pack', '1.5.0')):
|
||||
manager.cnr_map[name] = {'id': name, 'latest_version': {'version': latest}}
|
||||
manager.unified_update = lambda node_id, version_spec=None, **kwargs: core.ManagedResult('update').with_target('3.0.0')
|
||||
manager.unified_fix = lambda node_id, version_spec, **kwargs: core.ManagedResult('fix')
|
||||
scope, said = cm_cli('update_node', 'fix_node', 'disable_node', 'enable_node')
|
||||
for act, name in (('update_node', 'enabled-pack'), ('fix_node', 'enabled-pack'), ('disable_node', 'enabled-pack'), ('enable_node', 'registry-pack')):
|
||||
scope[act](name + '@latest')
|
||||
print(json.dumps({'said': said(), 'enabled': sorted(os.listdir(nodes)), 'disabled': sorted(os.listdir(nodes / '.disabled'))}))
|
||||
''')
|
||||
|
||||
assert result['said'] == ['[ UPDATED ]: enabled-pack => (2.0.0 -> 3.0.0)', '[ FIXING ]: enabled-pack [2.0.0]', '[DISABLED] enabled-pack',
|
||||
'[ENABLED] registry-pack']
|
||||
assert result['enabled'] == ['.disabled', 'registry-pack']
|
||||
assert 'enabled-pack@2_0_0' in result['disabled']
|
||||
|
||||
|
||||
def test_a_registry_nodepack_that_is_not_installed_is_not_called_disabled():
|
||||
result = run(PACKS + '''
|
||||
manager.cnr_map['absent-pack'] = {'id': 'absent-pack', 'latest_version': {'version': '1.0.0'}}
|
||||
scope, said = cm_cli('update_node', 'fix_node', 'disable_node', 'enable_node')
|
||||
for name in ('absent-pack', 'absent-pack@latest'):
|
||||
for act in ('update_node', 'fix_node', 'disable_node', 'enable_node'):
|
||||
scope[act](name)
|
||||
print(json.dumps({'said': [line.split('=>')[-1].strip() for line in said()]}))
|
||||
''')
|
||||
|
||||
assert result['said'] == ['Not installed', 'Not installed', 'Not found', 'Not found'] * 2
|
||||
@@ -0,0 +1,304 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from test_snapshot_restore_pins import run
|
||||
|
||||
CLI = '''
|
||||
import ast, inspect, io, sys, threading, concurrent.futures, traceback
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated, List
|
||||
import rich, typer, typer.testing
|
||||
|
||||
def binds_print(node):
|
||||
if isinstance(node, ast.Assign):
|
||||
return any(isinstance(target, ast.Name) and target.id == 'print' for target in node.targets)
|
||||
return isinstance(node, ast.ImportFrom) and any((name.asname or name.name) == 'print' for name in node.names)
|
||||
|
||||
def cm_cli(*names, width=1000, color_system=None, **more):
|
||||
found = [node for node in ast.parse(pathlib.Path('cm-cli.py').read_text(encoding='utf-8')).body
|
||||
if isinstance(node, ast.FunctionDef) and node.name in names or binds_print(node)]
|
||||
if 'app' not in more:
|
||||
for node in found:
|
||||
node.decorator_list = []
|
||||
out = io.StringIO()
|
||||
rich.reconfigure(file=out, width=width, color_system=color_system, no_color=False)
|
||||
scope = {'typer': typer, 'List': List, 'Annotated': Annotated, 'Optional': Optional, 'asyncio': asyncio, 'traceback': traceback,
|
||||
'os': os, 'sys': sys, 'json': json, 'threading': threading, 'concurrent': concurrent,
|
||||
'core': core, 'cnr_utils': cnr_utils,
|
||||
'cmd_ctx': Mock(no_deps=False, channel='default', mode='cache'), 'unified_manager': manager,
|
||||
'auto_save_snapshot': AsyncMock(), 'manager_util': Mock(), 'comfy_path': tmp, **more}
|
||||
exec(compile(ast.Module(body=found, type_ignores=[]), 'cm-cli.py', 'exec'), scope)
|
||||
return scope, lambda: [' '.join(line.split()) for line in out.getvalue().splitlines() if line.strip()]
|
||||
|
||||
def command(scope, name, **given):
|
||||
try:
|
||||
scope[name](**{**dict.fromkeys(inspect.signature(scope[name]).parameters), **given})
|
||||
except (SystemExit, typer.Exit):
|
||||
pass
|
||||
|
||||
GIT_PACK = ('https://example.invalid/git-pack', str(nodes / 'git-pack'))
|
||||
folder = os.path.join(tmp, '[my] files')
|
||||
os.mkdir(folder)
|
||||
'''
|
||||
|
||||
|
||||
def said(body):
|
||||
return run(CLI + body + '\nprint(json.dumps(lines()))\n')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installed, name, label', [
|
||||
("manager.unknown_active_nodes['git-pack'] = GIT_PACK", 'git-pack', '[unknown]'),
|
||||
("manager.active_nodes['git-pack'] = ('nightly', GIT_PACK[1])", 'git-pack@nightly', '[nightly]'),
|
||||
], ids=['unknown', 'nightly'])
|
||||
def test_fix_names_the_version_of_a_git_nodepack(installed, name, label):
|
||||
assert said(f'''
|
||||
{installed}
|
||||
manager.unified_fix = lambda node_id, version_spec, **kwargs: core.ManagedResult('fix')
|
||||
scope, lines = cm_cli('fix_node')
|
||||
scope['fix_node']({name!r}, cnt_msg='1/1')
|
||||
''') == [f'1/1 [ FIXING ]: git-pack {label}']
|
||||
|
||||
|
||||
def test_fix_that_fails_says_why():
|
||||
assert said('''
|
||||
manager.unknown_active_nodes['git-pack'] = GIT_PACK
|
||||
manager.unified_fix = lambda node_id, version_spec, **kwargs: core.ManagedResult('fix').fail('cannot fix [the reason]')
|
||||
scope, lines = cm_cli('fix_node')
|
||||
scope['fix_node']('git-pack', cnt_msg='1/1')
|
||||
''')[1:] == ['ERROR: cannot fix [the reason]']
|
||||
|
||||
|
||||
def test_fix_all_has_a_line_for_each_nodepack_it_counts():
|
||||
assert said('''
|
||||
manager.unknown_active_nodes['git-pack'] = GIT_PACK
|
||||
manager.unknown_inactive_nodes['old-pack'] = ('https://example.invalid/old-pack', str(nodes / '.disabled/old-pack'))
|
||||
manager.unified_fix = lambda node_id, version_spec, **kwargs: core.ManagedResult('fix')
|
||||
scope, lines = cm_cli('fix', 'for_each_nodes', 'get_all_installed_node_specs', 'fix_node')
|
||||
command(scope, 'fix', nodes=['all'])
|
||||
''') == ['1/2 [ FIXING ]: git-pack [unknown]', '2/2 [ SKIPPED ]: old-pack@unknown => Disabled']
|
||||
|
||||
|
||||
def test_url_that_is_not_installed_says_why():
|
||||
assert said('''
|
||||
core.gitclone_install = AsyncMock(return_value=core.ManagedResult('install-git').fail('cannot clone [the reason]'))
|
||||
scope, lines = cm_cli('install_node')
|
||||
scope['install_node'](GIT_PACK[0], cnt_msg='1/1')
|
||||
''') == ['cannot clone [the reason]', "ERROR: An error occurred while installing 'https://example.invalid/git-pack'."]
|
||||
|
||||
|
||||
def test_install_of_an_id_that_no_list_has_says_where_it_was_looked_for():
|
||||
assert said('''
|
||||
scope, lines = cm_cli('install_node')
|
||||
scope['install_node']('no-such-pack', cnt_msg='1/1')
|
||||
''') == ["ERROR: An error occurred while installing 'no-such-pack'.", "Node 'no-such-pack@unknown' not found in [default, cache]"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installed, act, line', [
|
||||
("manager.unknown_inactive_nodes['git-pack'] = GIT_PACK; manager.unified_enable = lambda *args: core.ManagedResult('enable').fail(REASON)",
|
||||
'enable_node', '1/1 [ FAIL ] git-pack => cannot move [the folder]'),
|
||||
("manager.unknown_inactive_nodes['git-pack'] = GIT_PACK; manager.unified_enable = lambda *args: core.ManagedResult('skip').with_msg(REASON)",
|
||||
'enable_node', '1/1 [ SKIP ] git-pack => cannot move [the folder]'),
|
||||
("manager.unknown_active_nodes['git-pack'] = GIT_PACK; manager.unified_disable = lambda *args: core.ManagedResult('disable').fail(REASON)",
|
||||
'disable_node', '1/1 [ FAIL ] git-pack => cannot move [the folder]'),
|
||||
("manager.unknown_active_nodes['git-pack'] = GIT_PACK; manager.unified_disable = lambda *args: core.ManagedResult('skip').with_msg(REASON)",
|
||||
'disable_node', '1/1 [ SKIP ] git-pack => cannot move [the folder]'),
|
||||
("manager.unknown_active_nodes['git-pack'] = GIT_PACK; manager.unified_update = lambda *args, **kwargs: core.ManagedResult('skip').with_msg(REASON)",
|
||||
'update_node', '1/1 [ SKIPPED ]: git-pack => cannot move [the folder]'),
|
||||
], ids=['enable_fails', 'enable_is_skipped', 'disable_fails', 'disable_is_skipped', 'update_is_skipped'])
|
||||
def test_reason_in_square_brackets_is_printed_whole(installed, act, line):
|
||||
assert said(f'''
|
||||
REASON = 'cannot move [the folder]'
|
||||
{installed}
|
||||
scope, lines = cm_cli({act!r})
|
||||
scope[{act!r}]('git-pack', cnt_msg='1/1')
|
||||
''') == [line]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('name, installed, act, line', [
|
||||
('git-pack[old]', "manager.unknown_inactive_nodes[NAME] = PACK; manager.unified_enable = lambda *args: core.ManagedResult('enable')",
|
||||
'enable_node', '1/1 [ENABLED] git-pack[old]'),
|
||||
('git-pack[old]', "manager.unknown_active_nodes[NAME] = PACK; manager.unified_disable = lambda *args: core.ManagedResult('disable')",
|
||||
'disable_node', '1/1 [DISABLED] git-pack[old]'),
|
||||
('comfyui-manager[old]', "manager.unknown_active_nodes[NAME] = PACK",
|
||||
'disable_node', "1/1 [ SKIP ] comfyui-manager[old] => Not disabled: its name has 'comfyui-manager'"),
|
||||
('git-pack[old]', "manager.unknown_inactive_nodes[NAME] = PACK", 'fix_node', '1/1 [ SKIPPED ]: git-pack[old] => Disabled'),
|
||||
('git-pack[old]', "", 'fix_node', '1/1 [ SKIPPED ]: git-pack[old] => Not installed'),
|
||||
('git-pack[old]', "", 'update_node', '1/1 [ SKIPPED ]: git-pack[old] => Not installed'),
|
||||
], ids=['enable', 'disable', 'disable_of_the_manager', 'fix_of_a_disabled_one', 'fix_of_one_that_is_not_installed',
|
||||
'update_of_one_that_is_not_installed'])
|
||||
def test_name_in_square_brackets_is_printed_whole(name, installed, act, line):
|
||||
assert said(f'''
|
||||
NAME = {name!r}
|
||||
PACK = ('https://example.invalid/git-pack', str(nodes / NAME))
|
||||
{installed}
|
||||
scope, lines = cm_cli({act!r})
|
||||
scope[{act!r}](NAME, cnt_msg='1/1')
|
||||
''') == [line]
|
||||
|
||||
|
||||
def test_line_longer_than_the_console_is_wide_is_written_as_one_line():
|
||||
assert said('''
|
||||
manager.unknown_active_nodes['git-pack'] = GIT_PACK
|
||||
scope, lines = cm_cli('enable_node', width=80)
|
||||
scope['enable_node']('git-pack', cnt_msg='1/1')
|
||||
''') == ['1/1 [ SKIP ] git-pack => Already enabled']
|
||||
|
||||
|
||||
def test_error_of_a_nodepack_in_a_run_over_several_is_printed_whole():
|
||||
assert said('''
|
||||
def act(name, **kwargs):
|
||||
raise RuntimeError('no such [thing] for ' + name)
|
||||
|
||||
scope, lines = cm_cli('for_each_nodes', traceback=Mock())
|
||||
scope['for_each_nodes'](['git-pack'], act)
|
||||
''') == ['ERROR: no such [thing] for git-pack']
|
||||
|
||||
|
||||
def test_error_of_an_update_in_a_run_over_several_is_printed_whole():
|
||||
assert said('''
|
||||
scope, lines = cm_cli('update_parallel', update_node=Mock(side_effect=RuntimeError('no such [thing]')), traceback=Mock())
|
||||
scope['update_parallel'](['git-pack'])
|
||||
''') == ['ERROR: no such [thing]']
|
||||
|
||||
|
||||
def test_show_versions_prints_a_changelog_with_square_brackets():
|
||||
assert said('''
|
||||
cnr_utils.all_versions_of_node = lambda name: [{'createdAt': '2026-01-02T03:04:05', 'version': '1.0.1', 'changelog': '[fix] a crash'}]
|
||||
scope, lines = cm_cli('show_versions')
|
||||
scope['show_versions']('git-pack')
|
||||
''') == ['[2026-01-02] 1.0.1 -- [fix] a crash']
|
||||
|
||||
|
||||
def test_show_prints_a_title_and_an_author_with_square_brackets():
|
||||
assert said('''
|
||||
manager.get_custom_nodes = AsyncMock(return_value={
|
||||
'listed-pack': {'title': 'Listed [gist-wrapper] Pack', 'author': 'some[one]', 'files': ['https://github.com/someone/listed-pack']},
|
||||
})
|
||||
manager.cnr_map['registry-pack'] = {'id': 'registry-pack', 'name': 'Registry[official] Pack', 'publisher': {'name': 'someone'},
|
||||
'latest_version': {'version': '1.0.0'}}
|
||||
manager.active_nodes['registry-pack'] = ('1.0.0', str(nodes / 'registry-pack'))
|
||||
manager.unknown_active_nodes['listed-pack'] = ('https://github.com/someone/listed-pack', str(nodes / 'listed-pack'))
|
||||
scope, lines = cm_cli('show', 'simple_show', 'show_list')
|
||||
scope['show']('installed', None, None, None)
|
||||
scope['simple_show']('installed', None, None, None)
|
||||
''') == ['[ ENABLED ] Registry[official] Pack registry-pack (author: someone ) [1.0.0]',
|
||||
'[ ENABLED ] Listed [gist-wrapper] Pack listed-pack (author: some[one] ) [UNKNOWN]',
|
||||
'Registry[official] Pack@1.0.0', 'Listed [gist-wrapper] Pack@unknown']
|
||||
|
||||
|
||||
def test_show_of_a_word_that_is_no_list_is_refused_in_plain_words():
|
||||
assert said('''
|
||||
sys.stderr = refusal = io.StringIO()
|
||||
scope, lines = cm_cli('simple_show')
|
||||
command(scope, 'simple_show', arg='[nodes]')
|
||||
lines = lambda: refusal.getvalue().split()
|
||||
''') == ['Invalid', 'command:', '`show', '[nodes]`']
|
||||
|
||||
|
||||
def test_names_of_snapshots_are_listed_whole():
|
||||
assert said('''
|
||||
open(os.path.join(folder, 'before [the update].json'), 'w').close()
|
||||
scope, lines = cm_cli('show_snapshot_list')
|
||||
scope['cmd_ctx'].get_snapshot_path.return_value = folder
|
||||
scope['show_snapshot_list']()
|
||||
''') == ['before [the update].json']
|
||||
|
||||
|
||||
PATHS = {
|
||||
'restore-snapshot of a file that is not there': (
|
||||
"scope['cmd_ctx'].get_snapshot_path.return_value = folder; command(scope, 'restore_snapshot', snapshot_name='gone.json')",
|
||||
f'ERROR: `{{folder}}{os.sep}gone.json` is not exists.'),
|
||||
'save-snapshot into a folder that is not there': (
|
||||
"command(scope, 'save_snapshot', output=folder + '/gone/snapshot.json')", 'ERROR: {folder}/gone/snapshot.json path not exists.'),
|
||||
'save-snapshot': (
|
||||
"core.save_snapshot_with_postfix = AsyncMock(return_value=folder + '/snapshot.json'); command(scope, 'save_snapshot', output=folder + '/snapshot.json')",
|
||||
'Current snapshot is saved as `{folder}/snapshot.json`'),
|
||||
'deps-in-workflow of a file that is not there': (
|
||||
"command(scope, 'deps_in_workflow', workflow=folder + '/gone.json', output='deps.json')", 'File not found: {folder}/gone.json'),
|
||||
'deps-in-workflow': (
|
||||
"open(folder + '/workflow.json', 'w').close(); core.extract_nodes_from_workflow = AsyncMock(return_value=({}, []));"
|
||||
" command(scope, 'deps_in_workflow', workflow=folder + '/workflow.json', output=folder + '/deps.json')",
|
||||
'Workflow dependencies are being saved into {folder}/deps.json.'),
|
||||
'install-deps of a file that is not there': ("command(scope, 'install_deps', deps=folder + '/gone.json')", 'File not found: {folder}/gone.json'),
|
||||
'install-deps of a file that is not JSON': (
|
||||
"open(folder + '/deps.json', 'w').close(); command(scope, 'install_deps', deps=folder + '/deps.json')", 'Invalid json file: {folder}/deps.json'),
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('case', PATHS)
|
||||
def test_path_with_square_brackets_is_printed_whole(case):
|
||||
call, line = PATHS[case]
|
||||
|
||||
assert said(f'''
|
||||
scope, said = cm_cli('restore_snapshot', 'save_snapshot', 'deps_in_workflow', 'install_deps')
|
||||
{call}
|
||||
lines = lambda: [line.replace(folder, '{{folder}}') for line in said()][-1:]
|
||||
''') == [line]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('path', [r'C:\ComfyUI\[My] files\deps.json', '/nodes/' + 'long-folder-name/' * 5 + 'deps.json', '/nodes/x:100:y/deps.json'],
|
||||
ids=['a backslash before a bracket', 'longer than the console is wide', 'the code of an emoji'])
|
||||
@pytest.mark.parametrize('call, line', [
|
||||
("command(scope, 'install_deps', deps=path)", 'File not found: {}'),
|
||||
("core.save_snapshot_with_postfix = AsyncMock(return_value=path); command(scope, 'save_snapshot')", 'Current snapshot is saved as `{}`'),
|
||||
], ids=['a coloured line', 'a line without a colour'])
|
||||
def test_line_is_written_as_it_is(call, line, path):
|
||||
assert said(f'''
|
||||
path = {path!r}
|
||||
scope, lines = cm_cli('install_deps', 'save_snapshot', width=80)
|
||||
{call}
|
||||
''') == [line.format(path)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('call, line', [
|
||||
("command(scope, 'install_deps', deps='deps.json')", '\x1b[1;31mFile not found: deps.json\x1b[0m'),
|
||||
("open(os.path.join(folder, \"the 'old' one.json\"), 'w').close(); scope['cmd_ctx'].get_snapshot_path.return_value = folder;"
|
||||
" scope['show_snapshot_list']()", "the \x1b[32m'old'\x1b[0m one.json"),
|
||||
], ids=['a line that cm-cli colours', 'a quoted text in another line'])
|
||||
def test_line_keeps_its_colour(call, line):
|
||||
assert said(f'''
|
||||
scope, lines = cm_cli('install_deps', 'show_snapshot_list', color_system='standard')
|
||||
{call}
|
||||
''') == [line]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('app', ['typer.Typer()', 'typer.Typer(rich_markup_mode=None)'], ids=['with rich markup', 'without'])
|
||||
def test_help_names_the_values_that_an_argument_and_an_option_take(app):
|
||||
assert said(f'''
|
||||
scope, said = cm_cli('show', 'update', app={app})
|
||||
help = lambda name: ' '.join(typer.testing.CliRunner().invoke(scope['app'], [name, '--help'], env={{'COLUMNS': '200'}}).output.split())
|
||||
lines = lambda: [text in help(name) and chr(92) not in help(name) for name, text in (
|
||||
('show', 'installed|enabled|not-installed'), ('show', 'remote|local|cache'),
|
||||
('update', 'all|List of custom nodes to update'), ('update', 'remote|local|cache'))]
|
||||
''') == [True, True, True, True]
|
||||
|
||||
|
||||
def test_disable_says_why_the_manager_is_not_disabled():
|
||||
assert said('''
|
||||
scope, lines = cm_cli('disable_node')
|
||||
scope['disable_node']('comfyui-manager', cnt_msg='1/1')
|
||||
''') == ["1/1 [ SKIP ] comfyui-manager => Not disabled: its name has 'comfyui-manager'"]
|
||||
|
||||
|
||||
def test_disable_all_has_a_line_for_each_nodepack_it_counts():
|
||||
assert [line.split()[0] for line in said('''
|
||||
for name in ('comfyui-manager', 'git-pack'):
|
||||
(nodes / name).mkdir()
|
||||
manager.unknown_active_nodes[name] = ('https://example.invalid/' + name, str(nodes / name))
|
||||
scope, lines = cm_cli('disable', 'for_each_nodes', 'get_all_installed_node_specs', 'disable_node')
|
||||
scope['disable'](['all'], None, None, None)
|
||||
''')] == ['1/2', '2/2']
|
||||
|
||||
|
||||
def test_restore_dependencies_runs_for_the_nodepacks_only():
|
||||
assert said('''
|
||||
for name in ('a-pack', '__pycache__', 'b-pack.disabled', '.disabled'):
|
||||
os.mkdir(os.path.join(folder, name))
|
||||
manager.execute_install_script = Mock()
|
||||
scope, said = cm_cli('restore_dependencies')
|
||||
scope['cmd_ctx'].get_custom_nodes_paths.return_value = [folder]
|
||||
command(scope, 'restore_dependencies')
|
||||
lines = lambda: ([line.replace(folder, '{folder}') for line in said() if line.startswith('Restoring')]
|
||||
+ [os.path.basename(call.args[1]) for call in manager.execute_install_script.call_args_list])
|
||||
''') == ['Restoring [1/1]: {folder}' + os.sep + 'a-pack', 'a-pack']
|
||||
@@ -0,0 +1,156 @@
|
||||
import pytest
|
||||
|
||||
from manager_test_utils import load_manager_util
|
||||
from test_install_flags_config import _run_child
|
||||
|
||||
COMFY_ORG = 'https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main'
|
||||
LTDRDATA = 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main'
|
||||
MIRROR = 'https://example.invalid/mirror'
|
||||
FILES = ['custom-node-list.json', 'extension-node-map.json', 'model-list.json', 'github-stats.json']
|
||||
SPELLINGS = [pytest.param(COMFY_ORG, id='Comfy-Org'), pytest.param(LTDRDATA, id='ltdrdata')]
|
||||
CONFIGS = [pytest.param(None, id='no channel_url')] + SPELLINGS
|
||||
CACHED = [pytest.param((), id='DEFAULT_CHANNEL'), pytest.param(('default_cache_as_channel_url = True',), id='channel_url')]
|
||||
|
||||
PRELUDE = '''
|
||||
import ast, asyncio, logging, pathlib, traceback
|
||||
from types import SimpleNamespace
|
||||
from aiohttp import web
|
||||
import cnr_utils
|
||||
import manager_util
|
||||
core = manager_core
|
||||
user = pathlib.Path(tmp)
|
||||
nodes = user / 'custom_nodes'
|
||||
nodes.mkdir()
|
||||
sys.modules['folder_paths'].get_folder_paths = lambda name: [str(nodes)]
|
||||
core.manager_channel_list_path = str(user / 'channels.list')
|
||||
manager_util.cache_dir = str(user / 'cache')
|
||||
manager_util.comfyui_manager_path = str(user / 'manager')
|
||||
os.makedirs(manager_util.cache_dir)
|
||||
os.makedirs(manager_util.comfyui_manager_path)
|
||||
BAR_URL = 'https://github.com/example/ComfyUI-Bar'
|
||||
SERVED = {
|
||||
'custom-node-list.json': {'custom_nodes': [{'author': 'example', 'title': 'ComfyUI-Bar', 'reference': BAR_URL, 'files': [BAR_URL],
|
||||
'install_type': 'git-clone', 'description': ''}]},
|
||||
'extension-node-map.json': {BAR_URL: [['BarNode'], {'title_aux': 'ComfyUI-Bar'}]},
|
||||
'model-list.json': {'models': [{'name': 'served by the channel'}]},
|
||||
'github-stats.json': {BAR_URL: {'stars': 7, 'last_update': '2026-11-01 00:00:00', 'author_account_age_days': 900}},
|
||||
}
|
||||
BUNDLED = {'custom-node-list.json': {'custom_nodes': []}, 'extension-node-map.json': {}, 'model-list.json': {'models': []},
|
||||
'github-stats.json': {}, 'extras.json': {'favorites': []}}
|
||||
for name, data in BUNDLED.items():
|
||||
(pathlib.Path(manager_util.comfyui_manager_path) / name).write_text(json.dumps(data))
|
||||
REGISTRY = [{'id': 'comfyui-foo', 'name': 'Foo', 'repository': 'https://github.com/example/ComfyUI-Foo',
|
||||
'publisher': {'name': 'example'}, 'description': '', 'latest_version': {'version': '1.0.1'}}]
|
||||
requests = []
|
||||
get_data = manager_util.get_data
|
||||
|
||||
async def from_the_channel(uri, silent=False):
|
||||
if uri.startswith('https://'):
|
||||
requests.append(uri)
|
||||
return json.loads(json.dumps(SERVED[os.path.basename(uri)]))
|
||||
return await get_data(uri, silent)
|
||||
|
||||
async def get_cnr_data(*args, **kwargs):
|
||||
return REGISTRY
|
||||
|
||||
manager_util.get_data = from_the_channel
|
||||
cnr_utils.get_cnr_data = get_cnr_data
|
||||
core.unified_manager = core.UnifiedManager()
|
||||
SERVER = pathlib.Path(core.__file__).with_name('manager_server.py')
|
||||
route = lambda path: lambda handler: handler
|
||||
|
||||
def server(*names):
|
||||
functions = [node for node in ast.parse(SERVER.read_text(encoding='utf-8')).body
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name in names]
|
||||
scope = {'core': core, 'manager_util': manager_util, 'os': os, 'logging': logging, 'traceback': traceback, 'asyncio': asyncio,
|
||||
'web': web, 'routes': SimpleNamespace(get=route, post=route), 'populate_markdown': lambda node_pack: None}
|
||||
exec(compile(ast.Module(functions, []), str(SERVER), 'exec'), scope)
|
||||
return scope
|
||||
|
||||
def configure(channel_url, default_url, *lines):
|
||||
config = ['[default]'] + ([f'channel_url = {channel_url}'] if channel_url else []) + list(lines)
|
||||
pathlib.Path(CONFIG_PATH).write_text('\\n'.join(config) + '\\n')
|
||||
(user / 'channels.list').write_text(f'default::{default_url}\\nrecent::{default_url}/node_db/new\\nmirror::https://example.invalid/mirror\\n')
|
||||
|
||||
def start():
|
||||
try:
|
||||
asyncio.run(server('default_cache_update')['default_cache_update']())
|
||||
except Exception as e:
|
||||
return repr(e)
|
||||
|
||||
def answer(name, **query):
|
||||
response = asyncio.run(server(name)[name](SimpleNamespace(rel_url=SimpleNamespace(query=query))))
|
||||
return json.loads(response.text)
|
||||
|
||||
def emit(value):
|
||||
print()
|
||||
print(json.dumps(value))
|
||||
'''
|
||||
|
||||
|
||||
def run(body):
|
||||
return _run_child(PRELUDE + body)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('cached', CACHED)
|
||||
@pytest.mark.parametrize('default_url', SPELLINGS)
|
||||
@pytest.mark.parametrize('channel_url', CONFIGS)
|
||||
def test_start_writes_the_lists_every_reader_reads(channel_url, default_url, cached):
|
||||
data = run(f'''
|
||||
configure({channel_url!r}, {default_url!r}, *{cached!r})
|
||||
failed = start()
|
||||
started = len(os.listdir(manager_util.cache_dir))
|
||||
requests.clear()
|
||||
unread = [[channel, filename] for channel in (None, 'default', {COMFY_ORG!r}, {LTDRDATA!r}) for filename in SERVED
|
||||
if asyncio.run(core.get_data_by_mode('cache', filename, channel)) != SERVED[filename]]
|
||||
level = asyncio.run(server('get_risky_level')['get_risky_level']([BAR_URL], []))
|
||||
emit({{'failed': failed, 'cache': [started, len(os.listdir(manager_util.cache_dir))], 'unread': unread,
|
||||
'fetched': requests, 'level': level}})
|
||||
''')
|
||||
|
||||
assert data == {'failed': None, 'cache': [len(FILES), len(FILES)], 'unread': [], 'fetched': [], 'level': 'middle'}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('default_url', SPELLINGS)
|
||||
@pytest.mark.parametrize('channel_url', CONFIGS)
|
||||
def test_custom_nodes_manager_lists_the_registry_nodepacks_on_the_default_channel(channel_url, default_url):
|
||||
data = run(f'''
|
||||
configure({channel_url!r}, {default_url!r})
|
||||
start()
|
||||
listed = answer('fetch_customnode_list', mode='cache')
|
||||
emit({{'channel': listed['channel'], 'node_packs': {{key: row['reference'] for key, row in listed['node_packs'].items()}}}})
|
||||
''')
|
||||
|
||||
assert data == {'channel': 'default', 'node_packs': {
|
||||
'ComfyUI-Bar': 'https://github.com/example/ComfyUI-Bar', 'comfyui-foo': 'https://registry.comfy.org/nodes/comfyui-foo'}}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('default_url', SPELLINGS)
|
||||
@pytest.mark.parametrize('channel_url', CONFIGS)
|
||||
def test_channel_menu_selects_the_default_channel(channel_url, default_url):
|
||||
data = run(f'''
|
||||
configure({channel_url!r}, {default_url!r})
|
||||
emit(answer('get_channel_url_list')['selected'])
|
||||
''')
|
||||
|
||||
assert data == 'default'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('default_url', SPELLINGS)
|
||||
def test_another_channel_keeps_its_own_lists(default_url):
|
||||
data = run(f'''
|
||||
configure({MIRROR!r}, {default_url!r}, 'default_cache_as_channel_url = True')
|
||||
failed = start()
|
||||
cache = sorted(os.listdir(manager_util.cache_dir))
|
||||
listed = answer('fetch_customnode_list', mode='cache')
|
||||
requests.clear()
|
||||
emit({{'failed': failed, 'cache': cache,
|
||||
'read': {{filename: asyncio.run(core.get_data_by_mode('cache', filename)) == SERVED[filename] for filename in SERVED}},
|
||||
'fetched': requests, 'selected': answer('get_channel_url_list')['selected'],
|
||||
'listed': [listed['channel'], list(listed['node_packs'])]}})
|
||||
''')
|
||||
|
||||
simple_hash = load_manager_util().simple_hash
|
||||
assert data == {'failed': None, 'cache': sorted(f'{simple_hash(f"{MIRROR}/{filename}")}_{filename}' for filename in FILES),
|
||||
'read': dict.fromkeys(FILES, True), 'fetched': [], 'selected': 'mirror', 'listed': ['mirror', ['ComfyUI-Bar']]}
|
||||
|
||||
@@ -251,6 +251,132 @@ print(json.dumps({'ok': result.result, 'old_path': installed.exists(),
|
||||
'queries': 0, 'downloads': 0, 'scripts': 0}
|
||||
|
||||
|
||||
def test_unspecified_version_enable_restores_cnr_disabled_pack():
|
||||
data = run('''
|
||||
installed = nodes / '.disabled/fixture@1_0_0'
|
||||
installed.mkdir(parents=True)
|
||||
(installed / '__init__.py').write_text('already installed')
|
||||
manager.cnr_map['fixture'] = {'id': 'fixture'}
|
||||
manager.cnr_inactive_nodes['fixture'] = {'1.0.0': str(installed)}
|
||||
# version_spec=None: the inactive-dict fallback must recognize the disabled
|
||||
# CNR pack (a dict never equals version_spec) and enable must restore it
|
||||
# without re-downloading, instead of routing install_by_id to a fresh install
|
||||
disabled = manager.is_disabled('fixture')
|
||||
result = manager.unified_enable('fixture')
|
||||
print(json.dumps({'disabled': disabled, 'ok': result.result, 'action': result.action,
|
||||
'msg': result.msg,
|
||||
'active_ok': manager.active_nodes.get('fixture') == ('1.0.0', str(nodes / 'fixture')),
|
||||
'old_path': installed.exists(),
|
||||
'downloads': core.manager_downloader.download_url.call_count}))
|
||||
''')
|
||||
assert data == {'disabled': True, 'ok': True, 'action': 'enable', 'msg': None,
|
||||
'active_ok': True, 'old_path': False, 'downloads': 0}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('key', ['1.0.0', '1.0.0-beta'])
|
||||
def test_install_without_version_restores_the_disabled_version(key):
|
||||
data = run(f"""
|
||||
status = 'NodeVersionStatusActive'
|
||||
installed = nodes / '.disabled/fixture@1_0_0'
|
||||
installed.mkdir(parents=True)
|
||||
(installed / '__init__.py').write_text('v1')
|
||||
(installed / '.tracking').write_text('__init__.py')
|
||||
manager.cnr_map['fixture'] = {{'id': 'fixture', 'latest_version': {{'version': '2.0.0'}}}}
|
||||
manager.cnr_inactive_nodes['fixture'] = {{{key!r}: str(installed)}}
|
||||
result = asyncio.run(manager.install_by_id('fixture', instant_execution=True))
|
||||
f = nodes / 'fixture/__init__.py'
|
||||
print(json.dumps({{'ok': result.result, 'action': result.action, 'content': f.read_text() if f.exists() else None,
|
||||
'downloads': core.manager_downloader.download_url.call_count, 'queries': get.call_count}}))
|
||||
""")
|
||||
assert data == {'ok': True, 'action': 'enable', 'content': 'v1', 'downloads': 0, 'queries': 0}
|
||||
|
||||
|
||||
def press_enable(body):
|
||||
return f"BODY = {body!r}" + """
|
||||
import ast
|
||||
from aiohttp import web
|
||||
source = pathlib.Path(core.__file__).with_name('manager_server.py').read_text(encoding='utf-8')
|
||||
handler = [node for node in ast.parse(source).body
|
||||
if isinstance(node, ast.AsyncFunctionDef) and node.name == '_queue_node_install']
|
||||
events = []
|
||||
namespace = {'core': core, 'web': web, 'logging': logging, 'os': os,
|
||||
'_reject_non_json_content_type': lambda request: None, 'is_allowed_security_level': lambda level: True,
|
||||
'PromptServer': SimpleNamespace(instance=SimpleNamespace(send_sync=lambda event, data: events.append(data)))}
|
||||
exec(compile(ast.Module(body=handler, type_ignores=[]), 'manager_server.py', 'exec'), namespace)
|
||||
body = dict(BODY, channel='default', mode='cache', ui_id='row', skip_post_install=True)
|
||||
response = asyncio.run(namespace['_queue_node_install'](SimpleNamespace(json=AsyncMock(return_value=body)), 'install'))
|
||||
reported = [event['nodepack_result'] for event in events if event['status'] == 'done']
|
||||
"""
|
||||
|
||||
|
||||
def test_enable_button_answers_success_for_an_enabled_pack_that_the_registry_data_does_not_list():
|
||||
data = run("""
|
||||
enabled, disabled = nodes / 'fixture', nodes / '.disabled/fixture@0_9_0'
|
||||
for folder, version in ((enabled, '1.0.0'), (disabled, '0.9.0')):
|
||||
folder.mkdir(parents=True)
|
||||
(folder / '__init__.py').write_text(version)
|
||||
manager.active_nodes['fixture'] = ('1.0.0', str(enabled))
|
||||
manager.cnr_inactive_nodes['fixture'] = {'0.9.0': str(disabled)}
|
||||
""" + press_enable({'id': 'fixture', 'version': '1.0.0', 'selected_version': '0.9.0'}) + """
|
||||
print(json.dumps({'status': response.status, 'reported': reported,
|
||||
'enabled': (enabled / '__init__.py').read_text(), 'disabled': (disabled / '__init__.py').read_text()}))
|
||||
""")
|
||||
assert data == {'status': 200, 'reported': [{'row': 'success'}], 'enabled': '1.0.0', 'disabled': '0.9.0'}
|
||||
|
||||
|
||||
def test_enable_button_says_why_for_a_disabled_pack_that_the_registry_data_does_not_list():
|
||||
data = run("""
|
||||
disabled = nodes / '.disabled/fixture@1_0_0'
|
||||
disabled.mkdir(parents=True)
|
||||
(disabled / '__init__.py').write_text('v1')
|
||||
manager.cnr_inactive_nodes['fixture'] = {'1.0.0': str(disabled)}
|
||||
""" + press_enable({'id': 'fixture', 'version': '1.0.0', 'selected_version': '1.0.0'}) + """
|
||||
print(json.dumps({'status': response.status, 'text': response.text, 'reported': reported,
|
||||
'disabled': (disabled / '__init__.py').read_text(), 'enabled': (nodes / 'fixture').exists()}))
|
||||
""")
|
||||
assert data == {'status': 400, 'text': 'Specified inactive node not exists: fixture', 'reported': [],
|
||||
'disabled': 'v1', 'enabled': False}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('disabled, printed, enabled', [
|
||||
(['0.9.0', '1.0.0'], ['1/1 [ ENABLED ] fixture'], '0.9.0'),
|
||||
(['1.0.0'], ["ERROR: An error occurred while installing 'fixture'.",
|
||||
'Specified inactive node path not exists: <folder>'], None),
|
||||
], ids=['an older version is left', 'no version is left'])
|
||||
def test_cli_install_without_version_when_the_newest_disabled_version_was_removed_after_the_scan(disabled, printed, enabled):
|
||||
data = run(f"DISABLED = {disabled!r}" + """
|
||||
import ast, shutil, rich.console
|
||||
status = 'NodeVersionStatusActive'
|
||||
async def get_cnr_data(*args, **kwargs):
|
||||
return [{'id': 'fixture', 'name': 'Fixture', 'repository': 'https://github.com/owner/fixture',
|
||||
'publisher': {'name': 'owner'}, 'latest_version': {'version': '2.0.0'}}]
|
||||
cnr_utils.get_cnr_data = get_cnr_data
|
||||
sys.modules['folder_paths'].get_folder_paths = lambda name: [str(nodes)]
|
||||
for version in DISABLED:
|
||||
folder = nodes / ('.disabled/fixture@' + version.replace('.', '_'))
|
||||
folder.mkdir(parents=True)
|
||||
(folder / '__init__.py').write_text(version)
|
||||
(folder / '.tracking').write_text('__init__.py\\npyproject.toml\\n')
|
||||
(folder / 'pyproject.toml').write_text(f'[project]\\nname = "fixture"\\nversion = "{version}"\\n')
|
||||
asyncio.run(manager.reload('cache', dont_wait=False))
|
||||
gone = nodes / '.disabled/fixture@1_0_0'
|
||||
shutil.rmtree(gone)
|
||||
source = (pathlib.Path(core.__file__).parent.parent / 'cm-cli.py').read_text(encoding='utf-8')
|
||||
found = [node for node in ast.parse(source).body if isinstance(node, ast.FunctionDef) and node.name == 'install_node']
|
||||
out = io.StringIO()
|
||||
scope = {'core': core, 'unified_manager': manager, 'asyncio': asyncio, 'sys': sys,
|
||||
'print': rich.console.Console(file=out, width=1000, color_system=None).print,
|
||||
'cmd_ctx': SimpleNamespace(channel='default', mode='cache', no_deps=False)}
|
||||
exec(compile(ast.Module(found, []), 'cm-cli.py', 'exec'), scope)
|
||||
scope['install_node']('fixture', cnt_msg='1/1')
|
||||
enabled = nodes / 'fixture/__init__.py'
|
||||
print(json.dumps({'printed': [' '.join(line.replace(str(gone), '<folder>').split()) for line in out.getvalue().splitlines()],
|
||||
'enabled': enabled.read_text() if enabled.exists() else None,
|
||||
'downloads': core.manager_downloader.download_url.call_count}))
|
||||
""")
|
||||
assert data == {'printed': printed, 'enabled': enabled, 'downloads': 0}
|
||||
|
||||
|
||||
def test_reinstall_stops_when_the_installed_folder_cannot_be_moved_aside():
|
||||
data = run('''
|
||||
status = 'NodeVersionStatusActive'
|
||||
|
||||
@@ -182,7 +182,7 @@ def test_manager_search_matches_visible_text(page, filename, column, value, quer
|
||||
const element = document.createElement('div');
|
||||
element.innerHTML = '<div id="tested-grid" class="cn-manager-grid cmm-manager-grid" style="width:800px;height:300px"></div>';
|
||||
document.body.append(element);
|
||||
window.manager = {element, keywords: query, showStatus() {}, handleFlyoverHover() {}, createFlyover: () => ({}), hasAlternatives: () => false,
|
||||
window.manager = {element, keywords: query, showStatus() {}, handleFlyoverHover() {}, createFlyover: () => ({}),
|
||||
calculateSortScore: new Function(`return ${score}`)()};
|
||||
initGrid.call(manager);
|
||||
manager.grid.setData({columns: [{id: column, name: column}], rows: [{[column]: value}]});
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
"""execute_install_script() must install from a node pack's requirements.txt
|
||||
that the locale encoding cannot decode, and take from the encoding that
|
||||
chardet guesses only requirements that do not depend on the guess.
|
||||
|
||||
On Windows the locale encoding is the ANSI code page, so a UTF-8
|
||||
requirements.txt with a non-ASCII comment made the module-level installer
|
||||
raise UnicodeDecodeError before any package was installed. The test pins the
|
||||
locale to cp1252 so it reproduces the Windows behavior on any platform.
|
||||
"""
|
||||
import ast
|
||||
import builtins
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
|
||||
import chardet
|
||||
import pytest
|
||||
|
||||
from manager_test_utils import GLOB_DIR, load_manager_util
|
||||
|
||||
NOT_TEXT = bytes(range(128, 256)) * 4 + b"\nnumpy\n"
|
||||
MAC_ROMAN = "# Dependências do nó – instalação\nrich\n".encode("mac_roman")
|
||||
SHIFT_JIS = "numpy\nrich # 画像処理用\n".encode("shift_jis")
|
||||
EBCDIC = "pandas\r".encode("cp500")
|
||||
|
||||
|
||||
def ansi_open(file, mode="r", *args, encoding=None, **kwargs):
|
||||
if "b" not in mode and encoding is None:
|
||||
encoding = "cp1252"
|
||||
return builtins.open(file, mode, *args, encoding=encoding, **kwargs)
|
||||
|
||||
|
||||
def load_execute_install_script(manager_util, calls):
|
||||
source = (GLOB_DIR / "manager_core.py").read_text(encoding="utf-8")
|
||||
functions = [node for node in ast.parse(source).body
|
||||
if isinstance(node, ast.FunctionDef) and node.name == "execute_install_script"]
|
||||
assert len(functions) == 1
|
||||
namespace = {
|
||||
"os": os,
|
||||
"sys": sys,
|
||||
"open": ansi_open,
|
||||
"manager_util": manager_util,
|
||||
"cm_global": types.SimpleNamespace(pip_overrides={}),
|
||||
"try_install_script": lambda url, repo_path, cmd, instant_execution=False: calls.append(cmd),
|
||||
"comfy_path": "",
|
||||
"manager_files_path": "",
|
||||
"manager_migration": types.SimpleNamespace(has_system_user_api=lambda: False),
|
||||
}
|
||||
exec(compile(ast.Module(body=functions, type_ignores=[]), "<install-extract>", "exec"), namespace)
|
||||
return namespace["execute_install_script"]
|
||||
|
||||
|
||||
def load_install_at_startup(manager_util, calls):
|
||||
source = (GLOB_DIR.parent / "prestartup_script.py").read_text(encoding="utf-8")
|
||||
functions = [node for node in ast.parse(source).body
|
||||
if isinstance(node, ast.FunctionDef) and node.name == "execute_lazy_install_script"]
|
||||
assert len(functions) == 1
|
||||
namespace = {
|
||||
"os": os,
|
||||
"manager_util": manager_util,
|
||||
"cm_global": types.SimpleNamespace(pip_overrides={}),
|
||||
"is_installed": lambda name: False,
|
||||
"process_wrap": lambda cmd, cwd, **kwargs: calls.append(cmd),
|
||||
"processed_install": set(),
|
||||
"comfy_path": "",
|
||||
}
|
||||
exec(compile(ast.Module(body=functions, type_ignores=[]), "<startup-extract>", "exec"), namespace)
|
||||
return namespace["execute_lazy_install_script"]
|
||||
|
||||
|
||||
class FakePIPFixer:
|
||||
def __init__(self, *args):
|
||||
pass
|
||||
|
||||
def fix_broken(self):
|
||||
pass
|
||||
|
||||
|
||||
def ansi_manager_util(monkeypatch):
|
||||
real_util = load_manager_util()
|
||||
monkeypatch.setattr(real_util, "open", ansi_open, raising=False)
|
||||
monkeypatch.setattr(real_util, "PIPFixer", FakePIPFixer)
|
||||
monkeypatch.setattr(real_util, "get_installed_packages", lambda: {})
|
||||
monkeypatch.setattr(real_util, "make_pip_cmd", lambda args: ["pip"] + args)
|
||||
return real_util
|
||||
|
||||
|
||||
def chardet_names(monkeypatch, encoding):
|
||||
monkeypatch.setattr(chardet, "detect", lambda data: {"encoding": encoding, "confidence": 0.06, "language": None})
|
||||
|
||||
|
||||
def install(manager_util, tmp_path):
|
||||
calls = []
|
||||
execute_install_script = load_execute_install_script(manager_util, calls)
|
||||
assert execute_install_script("https://example.invalid/pack", str(tmp_path)) is True
|
||||
return calls
|
||||
|
||||
|
||||
def test_utf8_requirements_with_non_ascii_comment_install(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
(tmp_path / "requirements.txt").write_text(
|
||||
"# Łukasz ✨ 中文\nnumpy\nrich # Łukasz\n", encoding="utf-8")
|
||||
|
||||
assert install(manager_util, tmp_path) == [["pip", "install", "numpy"], ["pip", "install", "rich"]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("content, named, installed", [
|
||||
(MAC_ROMAN, "ISO-8859-5", ["rich"]),
|
||||
(SHIFT_JIS, "cp1006", ["numpy", "rich"]),
|
||||
], ids=["mac-roman-chardet-7.1.0", "shift-jis-chardet-7.1.0"])
|
||||
def test_requirements_whose_comment_chardet_misreads_install(tmp_path, monkeypatch, content, named, installed):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, named)
|
||||
(tmp_path / "requirements.txt").write_bytes(content)
|
||||
|
||||
assert install(manager_util, tmp_path) == [["pip", "install", name] for name in installed]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, installed", [
|
||||
("\u3000# 依存関係\nnumpy\n", ["numpy"]),
|
||||
("# 依存関係\nnumpy\n\u00a0\u00a0\nrich\n", ["numpy", "rich"]),
|
||||
], ids=["comment-indented-with-an-ideographic-space", "line-of-no-break-spaces"])
|
||||
def test_utf8_requirements_with_non_ascii_blanks_install(tmp_path, monkeypatch, text, installed):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "utf-8")
|
||||
(tmp_path / "requirements.txt").write_text(text, encoding="utf-8")
|
||||
|
||||
assert install(manager_util, tmp_path) == [["pip", "install", name] for name in installed]
|
||||
|
||||
|
||||
def test_requirement_line_with_a_no_break_space_fails_the_install(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "utf-8")
|
||||
(tmp_path / "requirements.txt").write_text("numpy\u00a0 # 依存関係\nrich\n", encoding="utf-8")
|
||||
|
||||
calls = []
|
||||
execute_install_script = load_execute_install_script(manager_util, calls)
|
||||
|
||||
with pytest.raises(UnicodeDecodeError) as error:
|
||||
execute_install_script("https://example.invalid/pack", str(tmp_path))
|
||||
assert str(error.value) == "'charmap' codec can't decode byte 0x9d in position 12: character maps to <undefined>"
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_requirement_with_a_non_ascii_url_fragment_fails_the_install(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "utf-8")
|
||||
(tmp_path / "requirements.txt").write_text("git+https://host/repo#egg=依存\nrich\n", encoding="utf-8")
|
||||
|
||||
calls = []
|
||||
execute_install_script = load_execute_install_script(manager_util, calls)
|
||||
|
||||
with pytest.raises(UnicodeDecodeError):
|
||||
execute_install_script("https://example.invalid/pack", str(tmp_path))
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_utf16_requirements_with_byte_order_mark_install_only_their_requirements(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "utf-16-le")
|
||||
(tmp_path / "requirements.txt").write_bytes("# 依赖列表\nrich\n".encode("utf-16"))
|
||||
|
||||
assert install(manager_util, tmp_path) == [["pip", "install", "rich"]]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("named", ["ISO-8859-5", "MacCyrillic", None],
|
||||
ids=["chardet-7.7.0", "chardet-7.1.0", "no-encoding"])
|
||||
def test_requirements_that_are_not_text_fail_the_install(tmp_path, monkeypatch, named):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, named)
|
||||
(tmp_path / "requirements.txt").write_bytes(NOT_TEXT)
|
||||
|
||||
calls = []
|
||||
execute_install_script = load_execute_install_script(manager_util, calls)
|
||||
|
||||
with pytest.raises(UnicodeDecodeError) as error:
|
||||
execute_install_script("https://example.invalid/pack", str(tmp_path))
|
||||
assert str(error.value) == "'charmap' codec can't decode byte 0x81 in position 1: character maps to <undefined>"
|
||||
assert calls == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("named", ["cp500", "cp1140"])
|
||||
def test_requirements_that_an_ebcdic_guess_reads_as_ascii_fail_the_install(tmp_path, monkeypatch, named):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, named)
|
||||
(tmp_path / "requirements.txt").write_bytes(EBCDIC)
|
||||
|
||||
calls = []
|
||||
execute_install_script = load_execute_install_script(manager_util, calls)
|
||||
|
||||
with pytest.raises(UnicodeDecodeError) as error:
|
||||
execute_install_script("https://example.invalid/pack", str(tmp_path))
|
||||
assert str(error.value) == "'charmap' codec can't decode byte 0x81 in position 1: character maps to <undefined>"
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_requirements_with_carriage_return_line_ends_install(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "utf-8")
|
||||
(tmp_path / "requirements.txt").write_bytes("pandas\r# 依存関係\r".encode("utf-8"))
|
||||
|
||||
assert install(manager_util, tmp_path) == [["pip", "install", "pandas"]]
|
||||
|
||||
|
||||
def test_the_install_at_startup_takes_the_requirements_chardet_reads(tmp_path, monkeypatch):
|
||||
manager_util = ansi_manager_util(monkeypatch)
|
||||
chardet_names(monkeypatch, "ISO-8859-5")
|
||||
(tmp_path / "requirements.txt").write_bytes(MAC_ROMAN)
|
||||
|
||||
calls = []
|
||||
load_install_at_startup(manager_util, calls)(str(tmp_path), sys.executable)
|
||||
|
||||
assert calls == [["pip", "install", "rich"]]
|
||||
@@ -0,0 +1,12 @@
|
||||
from test_invalid_installation import run
|
||||
|
||||
|
||||
def test_a_registry_nodepack_is_listed_with_its_id_as_its_pyproject_spells_it():
|
||||
data = run('''
|
||||
pack('ComfyUI_SigmoidOffsetScheduler', 'ComfyUI_SigmoidOffsetScheduler', version='1.1.1', tracking=True)
|
||||
emit(core.get_installed_node_packs())
|
||||
''')
|
||||
|
||||
assert data == {
|
||||
'ComfyUI_SigmoidOffsetScheduler': {'ver': '1.1.1', 'cnr_id': 'ComfyUI_SigmoidOffsetScheduler', 'aux_id': None,
|
||||
'enabled': True}}
|
||||
@@ -109,6 +109,23 @@ def registry_api(status='NodeVersionStatusActive', download=archive_of_foo):
|
||||
core.manager_funcs.is_flagged_install_allowed = lambda *args: False
|
||||
core.manager_downloader.download_url = Mock(side_effect=download)
|
||||
|
||||
def registry_with_every_version():
|
||||
def version(url, **kwargs):
|
||||
asked = url.split('version=')[1]
|
||||
return SimpleNamespace(status_code=200, json=lambda: {
|
||||
'id': 'version-id', 'node_id': 'comfyui-foo', 'version': asked, 'status': 'NodeVersionStatusActive',
|
||||
'downloadUrl': f'https://example.invalid/comfyui-foo-{asked}.zip'})
|
||||
|
||||
def archive(url, directory, name):
|
||||
asked = url.rsplit('-', 1)[1][:-len('.zip')]
|
||||
with zipfile.ZipFile(pathlib.Path(directory) / name, 'w') as archive:
|
||||
archive.writestr('__init__.py', 'NODE_CLASS_MAPPINGS = {}\\n')
|
||||
archive.writestr('pyproject.toml', f'[project]\\nname = "comfyui-foo"\\nversion = "{asked}"\\n')
|
||||
|
||||
cnr_utils.requests.get = version
|
||||
core.manager_funcs.is_flagged_install_allowed = lambda *args: False
|
||||
core.manager_downloader.download_url = archive
|
||||
|
||||
def files(path):
|
||||
return {x.relative_to(path).as_posix(): x.read_text() for x in sorted(pathlib.Path(path).rglob('*')) if x.is_file()}
|
||||
|
||||
@@ -182,11 +199,12 @@ def cm_cli_function(name, namespace, class_name=None):
|
||||
return namespace[name]
|
||||
|
||||
def cm_cli_reinstall_node(out=None):
|
||||
import io, rich.console, rich.markup
|
||||
console = rich.console.Console(file=out if out is not None else io.StringIO(), width=1000, color_system=None)
|
||||
import io
|
||||
out = out if out is not None else io.StringIO()
|
||||
return cm_cli_function('reinstall_node', {
|
||||
'asyncio': asyncio, 'os': os, 'core': core, 'unified_manager': manager, 'print': console.print,
|
||||
'escape': rich.markup.escape, 'cmd_ctx': SimpleNamespace(channel='default', mode='cache', no_deps=False)})
|
||||
'asyncio': asyncio, 'os': os, 'core': core, 'unified_manager': manager,
|
||||
'print': lambda *objects, **kwargs: core.print(*objects, file=out, **kwargs),
|
||||
'cmd_ctx': SimpleNamespace(channel='default', mode='cache', no_deps=False)})
|
||||
|
||||
def notice():
|
||||
import contextlib, io
|
||||
@@ -1393,6 +1411,119 @@ emit({{'out': [x.strip() for x in out.getvalue().splitlines()], 'left': left, 'i
|
||||
assert data['installed'] == {'comfyui-foo': {'ver': '1.0.1', 'cnr_id': 'comfyui-foo', 'aux_id': None, 'enabled': True}}
|
||||
|
||||
|
||||
INSTALLED_BEFORE_A_REINSTALL = {
|
||||
'a_version': "pack('comfyui-foo', 'comfyui-foo', version='1.0.0', tracking=True)",
|
||||
'the_nightly_clone': "pack('comfyui-foo', git_url=FOO_URL)",
|
||||
'a_disabled_version': "pack('.disabled/comfyui-foo@1_0_0', 'comfyui-foo', version='1.0.0', tracking=True)",
|
||||
'a_disabled_nightly_clone': "pack('.disabled/comfyui-foo@nightly', git_url=FOO_URL)",
|
||||
'a_version_and_a_disabled_nightly_clone': "pack('comfyui-foo', 'comfyui-foo', version='1.0.0', tracking=True)\n"
|
||||
"pack('.disabled/comfyui-foo@nightly', git_url=FOO_URL)",
|
||||
'nothing': '',
|
||||
}
|
||||
|
||||
|
||||
def cm_cli_reinstall(installed, spec):
|
||||
data = run(f'''
|
||||
import io
|
||||
{INSTALLED_BEFORE_A_REINSTALL[installed]}
|
||||
registry_with_every_version()
|
||||
clone_stand_in()
|
||||
reload()
|
||||
out = io.StringIO()
|
||||
cm_cli_reinstall_node(out)({spec!r})
|
||||
emit({{'out': out.getvalue().split(), 'left': listing(), 'files': files(nodes / 'comfyui-foo')}})
|
||||
''')
|
||||
assert data['left'] == ['comfyui-foo']
|
||||
assert data['out'][:2] == ['[REINSTALLED]', 'comfyui-foo']
|
||||
project = data['files'].get('pyproject.toml', '')
|
||||
return data['out'][2], 'the clone' if '.git/config' in data['files'] else project.split('version = ')[1].strip().strip('"')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installed', ['a_version', 'a_disabled_version', 'a_version_and_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_installs_the_version_that_is_installed(spec, installed):
|
||||
assert cm_cli_reinstall(installed, spec) == ('[1.0.0]', '1.0.0')
|
||||
|
||||
|
||||
@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_clones_the_nightly_that_is_installed(spec, installed):
|
||||
assert cm_cli_reinstall(installed, spec) == ('[NIGHTLY]', 'the clone')
|
||||
|
||||
|
||||
@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_keeps_a_version_that_the_registry_no_longer_has():
|
||||
data = run('''
|
||||
import io
|
||||
pack('comfyui-foo', 'comfyui-foo', version='1.0.0', tracking=True)
|
||||
before = files(nodes)
|
||||
registry_with_every_version()
|
||||
every_version = cnr_utils.requests.get
|
||||
cnr_utils.requests.get = lambda url, **kwargs: SimpleNamespace(status_code=404) if url.endswith('version=1.0.0') else every_version(url, **kwargs)
|
||||
reload()
|
||||
out = io.StringIO()
|
||||
cm_cli_reinstall_node(out)('comfyui-foo')
|
||||
emit({'out': out.getvalue(), 'same': before == files(nodes)})
|
||||
''')
|
||||
assert 'not available node: comfyui-foo@1.0.0' in data['out']
|
||||
assert data['same']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installed, spec, version', [
|
||||
('nothing', 'comfyui-foo', '1.0.1'),
|
||||
('a_version', 'comfyui-foo@latest', '1.0.1'),
|
||||
('the_nightly_clone', 'comfyui-foo@latest', '1.0.1'),
|
||||
('a_version', 'comfyui-foo@1.0.1', '1.0.1'),
|
||||
('the_nightly_clone', 'comfyui-foo@1.0.0', '1.0.0'),
|
||||
('the_nightly_clone', 'https://github.com/example/ComfyUI-Foo@1.0.0', '1.0.0'),
|
||||
], ids=['not-installed', 'latest-over-a-version', 'latest-over-the-nightly-clone', 'another-version', 'a-version-over-the-nightly-clone',
|
||||
'a-version-by-url-over-the-nightly-clone'])
|
||||
def test_cm_cli_reinstall_installs_the_version_it_is_given_and_the_latest_of_a_nodepack_that_is_not_installed(installed, spec, version):
|
||||
assert cm_cli_reinstall(installed, spec) == (f'[{version}]', version)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('spec', ['comfyui-foo@nightly', 'https://github.com/example/ComfyUI-Foo@nightly'], ids=['by-id', 'by-url'])
|
||||
def test_cm_cli_reinstall_at_nightly_clones_over_an_installed_version(spec):
|
||||
assert cm_cli_reinstall('a_version', spec) == ('[NIGHTLY]', 'the clone')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('folder', ['foo-fork', '.disabled/foo-fork'])
|
||||
def test_cm_cli_reinstall_without_a_version_archives_a_clone_of_a_fork_and_installs_the_latest(folder):
|
||||
data = run(f'''
|
||||
import io
|
||||
fork = pack({folder!r}, git_url='https://github.com/someone/comfyui-foo')
|
||||
before = files(fork)
|
||||
registry_with_every_version()
|
||||
clone_stand_in()
|
||||
reload()
|
||||
out = io.StringIO()
|
||||
cm_cli_reinstall_node(out)('comfyui-foo')
|
||||
archived = list((nodes / '.disabled/.archived').glob('*/foo-fork'))
|
||||
emit({{'out': out.getvalue().split(), 'files': files(nodes / 'comfyui-foo'), 'kept': [before == files(x) for x in archived]}})
|
||||
''')
|
||||
assert data['out'][:3] == ['[REINSTALLED]', 'comfyui-foo', '[1.0.1]']
|
||||
assert data['files']['pyproject.toml'] == '[project]\nname = "comfyui-foo"\nversion = "1.0.1"\n'
|
||||
assert data['kept'] == [True]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('url', ['https://github.com/example/ComfyUI.Dot', 'https://github.com/example/ComfyUI.Dot.git'])
|
||||
def test_cm_cli_reinstall_by_an_unregistered_url_replaces_the_clone_the_scan_names_by_it(url):
|
||||
data = run(f'''
|
||||
|
||||
@@ -87,10 +87,11 @@ def assigned(name):
|
||||
if isinstance(n, ast.Assign) and [t.id for t in n.targets if isinstance(t, ast.Name)] == [name])
|
||||
|
||||
|
||||
def writing_loggers(stdout, stderr, log_file):
|
||||
def writing_loggers(stdout, stderr, log_file, strip=True):
|
||||
return loggers(stdout, stderr, log_file=log_file, log_lock=threading.Lock(), std_log_lock=threading.Lock(),
|
||||
current_timestamp=lambda: "12:00:00", write_stdout=stdout.write, write_stderr=stderr.write,
|
||||
re=re, pat_tqdm=assigned("pat_tqdm"), message_collapses=[], is_start_mode=False)
|
||||
re=re, pat_tqdm=assigned("pat_tqdm"), pat_ansi=assigned("pat_ansi"),
|
||||
strip_ansi_file_logging=strip, message_collapses=[], is_start_mode=False)
|
||||
|
||||
|
||||
def recording_stream():
|
||||
@@ -98,10 +99,10 @@ def recording_stream():
|
||||
return SimpleNamespace(write=written.append, flush=lambda: None), written
|
||||
|
||||
|
||||
def writing_logger(log_file):
|
||||
def writing_logger(log_file, strip=True):
|
||||
"""The stderr logger with what its writes need, and the list of what reached the console."""
|
||||
stream, console = recording_stream()
|
||||
_, err = writing_loggers(stream, stream, log_file)
|
||||
_, err = writing_loggers(stream, stream, log_file, strip)
|
||||
return err, console
|
||||
|
||||
|
||||
@@ -270,6 +271,20 @@ def test_open_log_file_gets_what_is_written():
|
||||
assert console == ["first\n"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("strip, file_text", [
|
||||
(True, "colored\n"),
|
||||
(False, "\x1b[32mcolored\x1b[0m\n"),
|
||||
])
|
||||
def test_file_logging_strips_ansi_codes_and_the_console_keeps_them(strip, file_text):
|
||||
log_file = LogFile()
|
||||
logger, console = writing_logger(log_file, strip)
|
||||
|
||||
logger.sync_write("\x1b[32mcolored\x1b[0m\n")
|
||||
|
||||
assert log_file.written == [file_text]
|
||||
assert console == ["\x1b[32mcolored\x1b[0m\n"]
|
||||
|
||||
|
||||
def test_closed_log_file_is_left_alone():
|
||||
log_file = LogFile(closed=True)
|
||||
logger, console = writing_logger(log_file)
|
||||
|
||||
@@ -111,9 +111,6 @@ REGISTRY = {
|
||||
("custom-nodes-manager.js", "showStatus",
|
||||
"`Loading missing nodes (${mode}) ...`);"):
|
||||
(NO_DATA, "UI-chosen mode"),
|
||||
("custom-nodes-manager.js", "showStatus",
|
||||
"`Loading alternatives (${mode}) ...`);"):
|
||||
(NO_DATA, "UI-chosen mode"),
|
||||
("custom-nodes-manager.js", "showStatus",
|
||||
"`Loading workflow usage analysis ...`);"):
|
||||
(NO_DATA, "hardcoded"),
|
||||
@@ -376,7 +373,6 @@ class HtmlByDesignSinkTest(unittest.TestCase):
|
||||
escaped = {
|
||||
"custom-nodes-manager.js": {
|
||||
'`Failed to get custom node mappings: ${sanitizeHTML(String(res.error))}`);',
|
||||
'`Failed to get alternatives: ${sanitizeHTML(String(res.error))}`);',
|
||||
'`Failed to get workflow data: ${sanitizeHTML(String(result.error))}`);',
|
||||
},
|
||||
"node-usage-analyzer.js": {'sanitizeHTML(String(result.error)));'},
|
||||
@@ -419,7 +415,8 @@ class HtmlByDesignSinkTest(unittest.TestCase):
|
||||
"node-usage-analyzer.js": common | {
|
||||
"errorMsg = `'${sanitizeHTML(String(item.name))}': `;", queue_error,
|
||||
},
|
||||
"common.js": common | {"errorMsg = `'${displayTitle}': `;"},
|
||||
"common.js": common | {"errorMsg = `'${displayTitle}': `;",
|
||||
"errorMsg = `Couldn't start the uninstall queue (HTTP ${startRes.status}). Nothing was uninstalled.\\n`;"},
|
||||
}
|
||||
mutations = re.compile(r"(?<![\w$.])errorMsg\s*(?:[+*/%&|^?-]*=(?!=)|\+\+|--)[^;]*;")
|
||||
for name, statements in expected.items():
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import ast
|
||||
import concurrent.futures
|
||||
import os
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from manager_test_utils import GLOB_DIR
|
||||
|
||||
KEYS = ("checkpoints", "controlnet")
|
||||
|
||||
|
||||
def installed(tmp_path, save_path, file):
|
||||
folders = {key: [str(tmp_path / "models" / key), str(tmp_path / "extra" / key)] for key in KEYS}
|
||||
path = tmp_path / file
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_bytes(b"")
|
||||
|
||||
def get_full_path(key, name):
|
||||
return next((os.path.join(folder, name) for folder in folders.get(key, [])
|
||||
if os.path.isfile(os.path.join(folder, name))), None)
|
||||
|
||||
def get_filename_list(key):
|
||||
return [os.path.relpath(os.path.join(root, name), folder)
|
||||
for folder in folders.get(key, []) for root, _, names in os.walk(folder) for name in names]
|
||||
|
||||
folder_paths = SimpleNamespace(models_dir=str(tmp_path / "models"),
|
||||
folder_names_and_paths={key: (paths, set()) for key, paths in folders.items()},
|
||||
get_folder_paths=lambda key: folders[key],
|
||||
get_filename_list=get_filename_list, get_full_path=get_full_path)
|
||||
source = (GLOB_DIR / "manager_server.py").read_text(encoding="utf-8")
|
||||
nodes = [node for node in ast.parse(source).body
|
||||
if isinstance(node, ast.FunctionDef) and node.name == "check_model_installed"]
|
||||
assert len(nodes) == 1
|
||||
namespace = {"os": os, "concurrent": concurrent, "folder_paths": folder_paths, "model_dir_name_map": {}}
|
||||
exec(compile(ast.Module(nodes, []), "<check_model_installed>", "exec"), namespace)
|
||||
|
||||
row = {"name": "m", "type": "checkpoint", "base": "SD1.5", "save_path": save_path,
|
||||
"filename": "model.safetensors", "url": "https://example.invalid/model.safetensors"}
|
||||
namespace["check_model_installed"]({"models": [row]})
|
||||
return row.get("installed")
|
||||
|
||||
|
||||
def test_model_in_a_subfolder_of_an_extra_model_path_is_installed(tmp_path):
|
||||
assert installed(tmp_path, "checkpoints/SD1.5", "extra/checkpoints/SD1.5/model.safetensors") == "True"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("save_path, file, expected", [
|
||||
("checkpoints/SD1.5", "models/checkpoints/SD1.5/model.safetensors", "True"),
|
||||
("checkpoints/SD1.5", "extra/checkpoints/model.safetensors", "True"),
|
||||
("RGT/RGT", "models/RGT/RGT/model.safetensors", "True"),
|
||||
("checkpoints/SD1.5", "extra/checkpoints/SDXL/model.safetensors", "False"),
|
||||
("checkpoints/SD1.5", "extra/controlnet/SD1.5/model.safetensors", "False"),
|
||||
("RGT/RGT", "extra/RGT/RGT/model.safetensors", "False"),
|
||||
], ids=["install folder", "top of an extra folder", "folder of no key", "other subfolder", "folder of another key",
|
||||
"extra folder of no key"])
|
||||
def test_other_layouts_keep_their_state(tmp_path, save_path, file, expected):
|
||||
assert installed(tmp_path, save_path, file) == expected
|
||||
@@ -0,0 +1,100 @@
|
||||
import pytest
|
||||
|
||||
from test_workflow_nodepack_lookup import EXTENSION, browser, page # noqa: F401 -- fixture
|
||||
|
||||
|
||||
def model(name, model_type, base, save_path, filename, installed):
|
||||
return {"name": name, "type": model_type, "base": base, "save_path": save_path, "description": name,
|
||||
"reference": "https://example.invalid/" + filename, "filename": filename,
|
||||
"url": "https://example.invalid/" + filename, "size": "4.71MB", "installed": installed}
|
||||
|
||||
|
||||
MODELS = [
|
||||
model("FLUX.1 VAE model", "VAE", "FLUX.1", "vae/FLUX1", "ae.safetensors", "False"),
|
||||
model("TAEF1 Decoder", "TAESD", "FLUX.1", "vae_approx", "taef1_decoder.pth", "True"),
|
||||
model("TAESD Decoder", "TAESD", "SD1.x", "vae_approx", "taesd_decoder.pth", "False"),
|
||||
model("RealESRGAN x2", "upscale", "upscale", "default", "RealESRGAN_x2.pth", "False"),
|
||||
model("FLUX.1 dev Q4_0", "unet", "FLUX.1", "diffusion_models/FLUX1", "flux1-dev-Q4_0.gguf", "False"),
|
||||
model("v1-5-pruned-emaonly", "checkpoint", "SD1.5", "checkpoints/SD1.5", "v1-5-pruned-emaonly.safetensors", "True"),
|
||||
]
|
||||
|
||||
|
||||
def node(node_type, *values):
|
||||
return {"type": node_type, "widgets_values": list(values)}
|
||||
|
||||
|
||||
def workflow(*loaders):
|
||||
return [*loaders,
|
||||
node("UNETLoader", "z_image_turbo_bf16.safetensors", "default"),
|
||||
node("KSampler", 42, "fixed", 8, 1, "res_multistep", "simple", 1),
|
||||
node("CLIPTextEncode", "a cute anime girl with gigantic fennec ears and a big fluffy fox tail"),
|
||||
{"type": "VHS_VideoCombine", "widgets_values": {"frame_rate": 8, "filename_prefix": "AnimateDiff"}},
|
||||
{"type": "Reroute"}]
|
||||
|
||||
|
||||
def choose(page, change): # noqa: F811
|
||||
page.evaluate("() => { window.updated = false; manager.grid.onNextUpdated(() => { window.updated = true; }); }")
|
||||
change()
|
||||
page.wait_for_function("window.updated")
|
||||
|
||||
|
||||
def open_models(page, nodes, keywords="", **choices): # noqa: F811
|
||||
page.evaluate("""async ({module, server, nodes}) => {
|
||||
window.server = server;
|
||||
const {app} = await import('/scripts/app.js');
|
||||
app.graph._nodes = nodes;
|
||||
const {setManagerInstance} = await import(new URL('common.js', module).href);
|
||||
setManagerInstance({datasrc_combo: {value: 'cache'}});
|
||||
const {ModelManager} = await import(module);
|
||||
window.manager = new ModelManager(app, null);
|
||||
manager.show();
|
||||
}""", {"module": EXTENSION + "model-manager.js", "server": {"/externalmodel/getlist": {"models": MODELS}},
|
||||
"nodes": nodes})
|
||||
page.wait_for_function("/^[\\d,]+ external models$/.test(document.querySelector('.cmm-manager-status').textContent)")
|
||||
if keywords:
|
||||
choose(page, lambda: page.fill(".cmm-manager-keywords", keywords))
|
||||
for name, value in choices.items():
|
||||
choose(page, lambda: page.select_option(".cmm-manager-" + name, value))
|
||||
return page.evaluate("""() => ({
|
||||
rows: [...document.querySelectorAll('.cmm-manager-grid .tg-body .cmm-node-name')].map(cell => cell.innerText.trim()),
|
||||
status: document.querySelector('.cmm-manager-status').textContent,
|
||||
})""")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value, rows", [
|
||||
("ae.safetensors", ["FLUX.1 VAE model"]),
|
||||
("FLUX1/ae.safetensors", ["FLUX.1 VAE model"]),
|
||||
("FLUX1\\ae.safetensors", ["FLUX.1 VAE model"]),
|
||||
("flux1-dev-Q4_0.gguf", ["FLUX.1 dev Q4_0"]),
|
||||
("qwen_3_4b.safetensors", []),
|
||||
], ids=["file", "file in a folder", "file in a Windows folder", "gguf file", "file not in the list"])
|
||||
def test_in_workflow_lists_the_models_whose_file_the_workflow_loads(page, value, rows): # noqa: F811
|
||||
shown = open_models(page, workflow(node("VAELoader", value)), filter="in_workflow")
|
||||
|
||||
assert shown == {"rows": rows, "status": f"{len(rows)} external models"}
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
def test_in_workflow_keeps_the_marks_of_a_search(page): # noqa: F811
|
||||
shown = open_models(page, workflow(node("VAELoader", "ae.safetensors")), keywords="flux", filter="in_workflow")
|
||||
|
||||
assert shown == {"rows": ["FLUX.1 VAE model"], "status": "1 external models"}
|
||||
page.wait_for_function("document.querySelector('.cmm-manager-grid .tg-body .cmm-node-name mark')")
|
||||
assert page.locator(".cmm-manager-grid .tg-body .cmm-node-name mark").all_text_contents() == ["FLUX"]
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("keywords, choices, rows", [
|
||||
("", {"type": "TAESD", "base": "FLUX.1"}, ["TAEF1 Decoder"]),
|
||||
("", {"filter": "installed", "base": "FLUX.1"}, ["TAEF1 Decoder"]),
|
||||
("", {"filter": "not_installed", "type": "TAESD"}, ["TAESD Decoder"]),
|
||||
("", {"filter": "in_workflow", "type": "checkpoint"}, ["v1-5-pruned-emaonly"]),
|
||||
("flux", {"filter": "not_installed", "type": "unet"}, ["FLUX.1 dev Q4_0"]),
|
||||
], ids=["All", "Installed", "Not Installed", "In Workflow", "Not Installed and a search"])
|
||||
def test_a_filter_choice_narrows_the_list_together_with_type_base_and_search(page, keywords, choices, rows): # noqa: F811
|
||||
nodes = workflow(node("VAELoader", "ae.safetensors"), node("CheckpointLoaderSimple", "SD1.5/v1-5-pruned-emaonly.safetensors"))
|
||||
|
||||
shown = open_models(page, nodes, keywords, **choices)
|
||||
|
||||
assert shown == {"rows": rows, "status": f"{len(rows)} external models"}
|
||||
assert page.errors == []
|
||||
@@ -0,0 +1,101 @@
|
||||
// Run with: node --test tests/test_node_conflicts.cjs
|
||||
// Exercise the actual UI method without importing ComfyUI or starting a server.
|
||||
const { readFileSync } = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const vm = require('node:vm');
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
|
||||
const source = readFileSync(path.join(__dirname, '../js/custom-nodes-manager.js'), 'utf8');
|
||||
const start = source.indexOf('\tasync loadNodes(node_packs) {');
|
||||
const end = source.indexOf('\n\trenderSelected()', start);
|
||||
assert.ok(start >= 0 && end > start, 'loadNodes method boundaries must exist');
|
||||
const method = source.slice(start, end);
|
||||
|
||||
async function load(packs, data = { A: [['Shared'], {}], B: [['Shared'], {}] }) {
|
||||
const manager = vm.runInNewContext(`({ showStatus() {}, ${method} })`, {
|
||||
manager_instance: { datasrc_combo: { value: 'cache' } },
|
||||
fetchData: async () => ({ data }),
|
||||
console,
|
||||
});
|
||||
await manager.loadNodes(packs);
|
||||
}
|
||||
|
||||
function pack(key, state) {
|
||||
return { key, state, title: key, hash: key };
|
||||
}
|
||||
|
||||
for (const inactive of ['not-installed', 'disabled']) {
|
||||
test(`enabled pack ignores ${inactive} peer; inactive pack retains preview`, async () => {
|
||||
const packs = { A: pack('A', 'enabled'), B: pack('B', inactive) };
|
||||
await load(packs);
|
||||
assert.equal(packs.A.conflicts, 0);
|
||||
assert.equal(packs.A.potentialConflicts, 0);
|
||||
assert.equal(packs.B.conflicts, 0);
|
||||
assert.equal(packs.B.potentialConflicts, 1);
|
||||
assert.equal(packs.B.nodesMap.Shared.potentialConflicts[0].key, 'A');
|
||||
assert.equal(packs.B.nodes, 1);
|
||||
});
|
||||
}
|
||||
|
||||
test('two enabled packs have symmetric conflicts, not potential conflicts', async () => {
|
||||
const packs = { A: pack('A', 'enabled'), B: pack('B', 'enabled') };
|
||||
await load(packs);
|
||||
for (const key of ['A', 'B']) {
|
||||
assert.equal(packs[key].conflicts, 1);
|
||||
assert.equal(packs[key].potentialConflicts, 0);
|
||||
assert.equal(packs[key].nodesMap.Shared.conflicts.length, 1);
|
||||
assert.notEqual(packs[key].nodesMap.Shared.conflicts[0].key, key);
|
||||
}
|
||||
});
|
||||
|
||||
test('inactive catalog packs do not conflict with each other', async () => {
|
||||
const packs = { A: pack('A', 'disabled'), B: pack('B', 'not-installed') };
|
||||
await load(packs);
|
||||
for (const p of Object.values(packs)) {
|
||||
assert.equal(p.conflicts, 0);
|
||||
assert.equal(p.potentialConflicts, 0);
|
||||
assert.equal(p.nodesList.length, 1);
|
||||
}
|
||||
});
|
||||
|
||||
test('mixed catalog only lists enabled peers and deduplicates node names', async () => {
|
||||
const packs = { A: pack('A', 'enabled'), B: pack('B', 'enabled'), C: pack('C', 'disabled') };
|
||||
await load(packs, { A: [['Shared', 'Shared', 'Unique'], {}], B: [['Shared'], {}], C: [['Shared'], {}] });
|
||||
assert.equal(packs.A.nodes, 2);
|
||||
assert.equal(packs.A.conflicts, 1);
|
||||
assert.equal(packs.A.nodesMap.Shared.conflicts.length, 1);
|
||||
assert.equal(packs.A.nodesMap.Shared.conflicts[0].key, 'B');
|
||||
assert.equal(packs.C.conflicts, 0);
|
||||
assert.equal(packs.C.potentialConflicts, 1);
|
||||
assert.equal(packs.C.nodesMap.Shared.potentialConflicts.length, 2);
|
||||
});
|
||||
|
||||
test('reload after disabling a peer clears previous active conflicts', async () => {
|
||||
const packs = { A: pack('A', 'enabled'), B: pack('B', 'enabled') };
|
||||
await load(packs);
|
||||
packs.B.state = 'disabled';
|
||||
await load(packs);
|
||||
assert.equal(packs.A.conflicts, 0);
|
||||
assert.equal(packs.A.nodesMap.Shared.conflicts, undefined);
|
||||
assert.equal(packs.B.conflicts, 0);
|
||||
assert.equal(packs.B.potentialConflicts, 1);
|
||||
packs.B.state = 'enabled';
|
||||
await load(packs);
|
||||
assert.equal(packs.B.conflicts, 1);
|
||||
assert.equal(packs.B.potentialConflicts, 0);
|
||||
});
|
||||
|
||||
test('a single enabled pack and unrelated catalog mapping have no conflicts', async () => {
|
||||
const packs = { A: pack('A', 'enabled') };
|
||||
await load(packs);
|
||||
assert.equal(packs.A.conflicts, 0);
|
||||
assert.equal(packs.A.potentialConflicts, 0);
|
||||
});
|
||||
|
||||
test('URL basename and title fallback still resolve pack mappings', async () => {
|
||||
const packs = { A: pack('A', 'enabled'), B: pack('B', 'disabled') };
|
||||
await load(packs, { 'https://example.invalid/A': [['Shared'], {}], other: [['Shared'], { title_aux: 'B' }] });
|
||||
assert.equal(packs.A.conflicts, 0);
|
||||
assert.equal(packs.B.potentialConflicts, 1);
|
||||
});
|
||||
@@ -0,0 +1,230 @@
|
||||
import pytest
|
||||
|
||||
from test_install_flags_config import _run_child
|
||||
from test_invalid_installation import PRELUDE
|
||||
|
||||
TAKEN = PRELUDE + '''
|
||||
import io, shutil, traceback, zipfile
|
||||
|
||||
def folders():
|
||||
return sorted(path.relative_to(nodes).as_posix() for path in nodes.rglob('*')
|
||||
if (path.is_dir() or path.is_symlink()) and path.name != '.git')
|
||||
|
||||
def broken_link(folder):
|
||||
(nodes / '.disabled').mkdir(exist_ok=True)
|
||||
os.symlink(nodes / 'gone', nodes / folder)
|
||||
|
||||
def download(url, directory, name):
|
||||
with zipfile.ZipFile(pathlib.Path(directory) / name, 'w') as archive:
|
||||
archive.writestr('__init__.py', '')
|
||||
archive.writestr('pyproject.toml', '[project]\\nname = "comfyui-foo"\\nversion = "1.0.1"\\n')
|
||||
|
||||
cnr_utils.install_node = lambda name, version: SimpleNamespace(version=version, download_url='https://registry.invalid/' + name,
|
||||
status='NodeVersionStatusActive')
|
||||
core.manager_downloader.download_url = core.manager_downloader.basic_download_url = Mock(side_effect=download)
|
||||
|
||||
def clone(url, path, **options):
|
||||
pathlib.Path(path).mkdir()
|
||||
return core.ManagedResult('install-git')
|
||||
|
||||
manager.repo_install = Mock(side_effect=clone)
|
||||
|
||||
def install(version):
|
||||
installed = asyncio.run(manager.install_by_id('comfyui-foo', version, core.DEFAULT_CHANNEL, 'cache', instant_execution=True))
|
||||
return [installed.result, core.manager_downloader.download_url.call_count + manager.repo_install.call_count, folders()]
|
||||
'''
|
||||
|
||||
UNKNOWN, VERSION, NIGHTLY = 'git_url=BAR_URL', "'comfyui-foo', tracking=True", "'comfyui-foo', git_url=FOO_URL"
|
||||
KINDS = pytest.mark.parametrize('name, made_with, disabled, version', [
|
||||
('ComfyUI-Bar', UNKNOWN, '.disabled/ComfyUI-Bar', 'unknown'),
|
||||
('comfyui-foo', VERSION, '.disabled/comfyui-foo@1_0_1', '1.0.1'),
|
||||
('comfyui-foo', NIGHTLY, '.disabled/comfyui-foo@nightly', 'nightly'),
|
||||
], ids=['git_clone_that_no_list_knows', 'registry_version', 'nightly_clone'])
|
||||
|
||||
|
||||
def run(body):
|
||||
return _run_child(TAKEN + body + '\nprint(json.dumps(result))\n')
|
||||
|
||||
|
||||
@KINDS
|
||||
@pytest.mark.parametrize('taken_by', ['pack({disabled!r}, {made_with})', 'broken_link({disabled!r})'], ids=['a_disabled_copy', 'a_broken_link'])
|
||||
def test_disable_fails_when_its_destination_is_taken(taken_by, name, made_with, disabled, version):
|
||||
assert run(f'''
|
||||
pack({name!r}, {made_with})
|
||||
{taken_by.format(disabled=disabled, made_with=made_with)}
|
||||
reload()
|
||||
result = [manager.unified_disable({name!r}, {version == 'unknown'}).result, folders()]
|
||||
''') == [False, ['.disabled', disabled, name]]
|
||||
|
||||
|
||||
@KINDS
|
||||
@pytest.mark.parametrize('taken_by', ['(nodes / {name!r}).mkdir()', 'broken_link({name!r})'],
|
||||
ids=['a_folder_made_since_the_last_scan', 'a_broken_link'])
|
||||
def test_enable_fails_when_its_destination_is_taken(taken_by, name, made_with, disabled, version):
|
||||
assert run(f'''
|
||||
pack({disabled!r}, {made_with})
|
||||
reload()
|
||||
{taken_by.format(name=name)}
|
||||
result = [manager.unified_enable({name!r}, {version!r}).result, folders()]
|
||||
''') == [False, ['.disabled', disabled, name]]
|
||||
|
||||
|
||||
def test_git_clone_that_no_list_knows_is_not_enabled_over_the_enabled_version_of_its_name():
|
||||
assert run(f'''
|
||||
pack('comfyui-foo', {VERSION})
|
||||
pack('.disabled/comfyui-foo', git_url='https://github.com/someone/comfyui-foo')
|
||||
reload()
|
||||
result = [manager.unified_enable('comfyui-foo', 'unknown').result, folders()]
|
||||
''') == [False, ['.disabled', '.disabled/comfyui-foo', 'comfyui-foo']]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('enabled, taken', [
|
||||
(f"pack('foo', {NIGHTLY})", "(nodes / 'comfyui-foo').mkdir()"),
|
||||
(f"pack('foo', {NIGHTLY})", "os.symlink(nodes / 'foo', nodes / 'comfyui-foo')"),
|
||||
(f"pack('../checkout', {NIGHTLY}); os.symlink(nodes.parent / 'checkout', nodes / 'foo')",
|
||||
"os.symlink(nodes.parent / 'checkout', nodes / 'comfyui-foo')"),
|
||||
], ids=['by_another_folder', 'by_a_link_to_the_enabled_folder', 'by_a_second_link_to_the_folder_of_the_enabled_link'])
|
||||
def test_enable_whose_folder_is_taken_leaves_the_enabled_version_enabled(enabled, taken):
|
||||
assert run(f'''
|
||||
{enabled}
|
||||
pack('.disabled/comfyui-foo@1_0_1', {VERSION})
|
||||
reload()
|
||||
{taken}
|
||||
result = [manager.unified_enable('comfyui-foo', '1.0.1').result, folders()]
|
||||
''') == [False, ['.disabled', '.disabled/comfyui-foo@1_0_1', 'comfyui-foo', 'foo']]
|
||||
|
||||
|
||||
def test_enable_whose_folder_is_taken_fails_when_the_folder_of_the_enabled_version_is_gone():
|
||||
assert run(f'''
|
||||
pack('foo', {NIGHTLY})
|
||||
pack('.disabled/comfyui-foo@1_0_1', {VERSION})
|
||||
reload()
|
||||
shutil.rmtree(nodes / 'foo')
|
||||
(nodes / 'comfyui-foo').mkdir()
|
||||
result = [manager.unified_enable('comfyui-foo', '1.0.1').result, folders()]
|
||||
''') == [False, ['.disabled', '.disabled/comfyui-foo@1_0_1', 'comfyui-foo']]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('folder', ['comfyui-foo', 'ComfyUI-Foo'], ids=['in_the_folder_of_its_id', 'in_a_folder_of_another_spelling'])
|
||||
def test_version_takes_the_folder_of_the_enabled_nightly_clone(folder):
|
||||
assert run(f'''
|
||||
pack({folder!r}, {NIGHTLY})
|
||||
pack('.disabled/comfyui-foo@1_0_1', {VERSION})
|
||||
reload()
|
||||
result = [manager.unified_enable('comfyui-foo', '1.0.1').result, folders()]
|
||||
''') == [True, ['.disabled', '.disabled/comfyui-foo@nightly', 'comfyui-foo']]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('enabled, taken, disabled, act, refused', [
|
||||
(NIGHTLY, '.disabled/comfyui-foo@nightly', f"'.disabled/comfyui-foo@1_0_1', {VERSION}", "manager.unified_enable('comfyui-foo', '1.0.1').result", False),
|
||||
(VERSION, '.disabled/comfyui-foo@1_0_1', f"'.disabled/comfyui-foo@nightly', {NIGHTLY}", "manager.unified_enable('comfyui-foo', 'nightly').result", False),
|
||||
(NIGHTLY, '.disabled/comfyui-foo@nightly', None, "install('1.0.1')[:2]", [False, 0]),
|
||||
(VERSION, '.disabled/comfyui-foo@1_0_1', None, "install('nightly')[:2]", [False, 0]),
|
||||
], ids=['enable_of_a_version', 'enable_of_the_nightly_clone', 'install_of_a_version', 'install_of_the_nightly_clone'])
|
||||
def test_nodepack_does_not_take_the_place_of_an_enabled_one_that_cannot_be_disabled(enabled, taken, disabled, act, refused):
|
||||
done, before, after = run(f'''
|
||||
for folder in ('ComfyUI-Foo', {taken!r}):
|
||||
pack(folder, {enabled})
|
||||
if {disabled is not None}:
|
||||
pack({disabled})
|
||||
reload()
|
||||
before = folders()
|
||||
result = [{act}, before, folders()]
|
||||
''')
|
||||
assert [done, after] == [refused, before]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('enabled, disabled, act, done', [
|
||||
(NIGHTLY, f"'.disabled/comfyui-foo@1_0_1', {VERSION}", "manager.unified_enable('comfyui-foo', '1.0.1').result", [True, ['.disabled', 'comfyui-foo']]),
|
||||
(VERSION, f"'.disabled/comfyui-foo@nightly', {NIGHTLY}", "manager.unified_enable('comfyui-foo', 'nightly').result", [True, ['.disabled', 'comfyui-foo']]),
|
||||
(NIGHTLY, None, "install('1.0.1')[:2]", [[True, 1], ['comfyui-foo']]),
|
||||
(VERSION, None, "install('nightly')[:2]", [[True, 1], ['comfyui-foo']]),
|
||||
], ids=['enable_of_a_version', 'enable_of_the_nightly_clone', 'install_of_a_version', 'install_of_the_nightly_clone'])
|
||||
def test_nodepack_takes_the_place_of_an_enabled_one_whose_folder_is_gone(enabled, disabled, act, done):
|
||||
assert run(f'''
|
||||
pack('ComfyUI-Foo', {enabled})
|
||||
if {disabled is not None}:
|
||||
pack({disabled})
|
||||
reload()
|
||||
shutil.rmtree(nodes / 'ComfyUI-Foo')
|
||||
result = [{act}, folders()]
|
||||
''') == done
|
||||
|
||||
|
||||
@pytest.mark.parametrize('enabled, disabled, version', [
|
||||
(NIGHTLY, "pack('.disabled/comfyui-foo@1_0_0', 'comfyui-foo', version='1.0.0', tracking=True)", '1.0.1'),
|
||||
(NIGHTLY, '', '1.0.1'),
|
||||
(VERSION, '', 'nightly'),
|
||||
], ids=['of_a_version_that_enables_a_disabled_one', 'of_a_version_that_is_downloaded', 'of_the_nightly_clone'])
|
||||
def test_install_whose_folder_is_taken_leaves_the_enabled_one_enabled(enabled, disabled, version):
|
||||
done, before = run(f'''
|
||||
pack('foo', {enabled})
|
||||
{disabled}
|
||||
reload()
|
||||
(nodes / 'comfyui-foo').mkdir()
|
||||
before = folders()
|
||||
result = [install({version!r}), before]
|
||||
''')
|
||||
assert done == [False, 0, before]
|
||||
|
||||
|
||||
def test_version_is_not_switched_when_the_disabled_one_cannot_be_enabled():
|
||||
assert run('''
|
||||
pack('comfyui-foo', git_url='https://github.com/someone/comfyui-foo')
|
||||
pack('.disabled/comfyui-foo@1_0_0', 'comfyui-foo', version='1.0.0', tracking=True)
|
||||
reload()
|
||||
result = install('1.0.1')
|
||||
''') == [False, 0, ['.disabled', '.disabled/comfyui-foo@1_0_0', 'comfyui-foo']]
|
||||
|
||||
|
||||
def test_page_is_told_that_a_disable_failed_and_the_terminal_why():
|
||||
assert run(f'''
|
||||
for folder in ('ComfyUI-Bar', '.disabled/ComfyUI-Bar'):
|
||||
pack(folder, {UNKNOWN})
|
||||
reload()
|
||||
logged = []
|
||||
handler = logging.Handler()
|
||||
handler.emit = lambda record: logged.append(record.getMessage())
|
||||
logging.getLogger().addHandler(handler)
|
||||
disable = server_function('do_disable', core=core, logging=logging, traceback=traceback)
|
||||
result = [asyncio.run(disable(('the row', 'ComfyUI-Bar', True))), any(str(nodes / '.disabled' / 'ComfyUI-Bar') in line for line in logged), folders()]
|
||||
''') == ["Failed to disable: 'ComfyUI-Bar'", True, ['.disabled', '.disabled/ComfyUI-Bar', 'ComfyUI-Bar']]
|
||||
|
||||
|
||||
def test_page_is_told_why_an_enable_failed_and_the_terminal_too():
|
||||
assert run(f'''
|
||||
pack('.disabled/comfyui-foo@1_0_1', {VERSION})
|
||||
reload()
|
||||
(nodes / 'comfyui-foo').mkdir()
|
||||
sent, logged = [], []
|
||||
handler = logging.Handler()
|
||||
handler.emit = lambda record: logged.append(record.getMessage())
|
||||
logging.getLogger().addHandler(handler)
|
||||
enable = server_function(
|
||||
'_queue_node_install', core=core, logging=logging, _reject_non_json_content_type=lambda request: None,
|
||||
is_allowed_security_level=lambda level: True, web=SimpleNamespace(Response=lambda status=200, text=None: [status, text]),
|
||||
PromptServer=SimpleNamespace(instance=SimpleNamespace(send_sync=lambda name, data: sent.append(data.get('nodepack_result')))))
|
||||
|
||||
async def row():
|
||||
return {{'id': 'comfyui-foo', 'version': '1.0.1', 'selected_version': '1.0.1', 'skip_post_install': True, 'ui_id': 'the row'}}
|
||||
|
||||
reason = 'Destination already exists: ' + str(nodes / 'comfyui-foo')
|
||||
result = [asyncio.run(enable(SimpleNamespace(json=row), 'install')) == [400, reason], any(reason in line for line in logged), sent, folders()]
|
||||
''') == [True, True, [], ['.disabled', '.disabled/comfyui-foo@1_0_1', 'comfyui-foo']]
|
||||
|
||||
|
||||
def test_cm_cli_install_reports_an_enable_that_failed():
|
||||
assert run(f'''
|
||||
pack('.disabled/ComfyUI-Bar', {UNKNOWN})
|
||||
reload()
|
||||
(nodes / 'ComfyUI-Bar').mkdir()
|
||||
out = io.StringIO()
|
||||
install_node = cm_cli_function('install_node', {{
|
||||
'asyncio': asyncio, 'sys': sys, 'core': core, 'unified_manager': manager, 'print': lambda *objects, **kwargs: print(*objects, file=out),
|
||||
'cmd_ctx': SimpleNamespace(channel=core.DEFAULT_CHANNEL, mode='cache', no_deps=False)}})
|
||||
try:
|
||||
ended = install_node('ComfyUI-Bar@unknown', cnt_msg='1/1', exit_on_fail=True)
|
||||
except SystemExit as exit:
|
||||
ended = exit.code
|
||||
result = [ended, '[ ENABLED ]' in out.getvalue(), folders()]
|
||||
''') == [1, False, ['.disabled', '.disabled/ComfyUI-Bar', 'ComfyUI-Bar']]
|
||||
@@ -0,0 +1,111 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from html.parser import HTMLParser
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from js_lift import NODE, JsSource, run_node, slice_braced, slice_object_entry
|
||||
|
||||
JS = JsSource(Path(os.environ.get("MANAGER_JS_DIR") or (Path(__file__).resolve().parent.parent / "js")))
|
||||
MANAGER = "custom-nodes-manager.js"
|
||||
|
||||
pytestmark = pytest.mark.skipif(NODE is None, reason="node is required to execute the lifted production JS")
|
||||
|
||||
|
||||
class NodesFlyover(HTMLParser):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.nodes = {}
|
||||
self.open = []
|
||||
self.row = None
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == "div":
|
||||
self.open.append((dict(attrs).get("class") or "").split())
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
if tag == "div":
|
||||
self.open.pop()
|
||||
|
||||
def handle_data(self, data):
|
||||
if self.open and "cn-nodes-name" in self.open[-1]:
|
||||
self.row = data
|
||||
self.nodes[data] = []
|
||||
elif self.open and "cn-nodes-pack" in self.open[-1] and self.row is not None:
|
||||
self.nodes[self.row].append(data)
|
||||
|
||||
|
||||
def shown(packs, mappings):
|
||||
source = JS.text(MANAGER)
|
||||
column = slice_object_entry(source, 'id: "nodes",')
|
||||
script = """
|
||||
%s
|
||||
%s
|
||||
const formatter = %s;
|
||||
const manager_instance = {datasrc_combo: {value: 'cache'}};
|
||||
const fetchData = async () => ({data: %s});
|
||||
const manager = {
|
||||
showStatus() {},
|
||||
flyover: {show(title, body) { manager.body = body; }},
|
||||
%s,
|
||||
%s
|
||||
};
|
||||
const packs = %s;
|
||||
await manager.loadNodes(packs);
|
||||
const rows = {};
|
||||
for (const [key, rowItem] of Object.entries(packs)) {
|
||||
manager.body = '';
|
||||
manager.showNodes({rowItem});
|
||||
rows[key] = {column: String(formatter(null, rowItem, {})), flyover: manager.body};
|
||||
}
|
||||
console.log(JSON.stringify(rows));
|
||||
""" % (JS.lift_declaration("common.js", "export function sanitizeHTML("),
|
||||
JS.lift_declaration("common.js", "export const icons = "),
|
||||
column[column.index("formatter:") + len("formatter:"):].strip(),
|
||||
json.dumps(mappings),
|
||||
slice_braced(source, "\tasync loadNodes(node_packs) "),
|
||||
JS.lift_span(MANAGER, "\tshowNodes(d) {", "\t\tthis.flyover.show(titleHtml, bodyHtml);\n\t}"),
|
||||
json.dumps({key: {"key": key, "title": key, "hash": key, "state": "enabled"} for key in packs}))
|
||||
view = {}
|
||||
for key, row in run_node(script).items():
|
||||
flyover = NodesFlyover()
|
||||
flyover.feed(row["flyover"])
|
||||
view[key] = {"column": " ".join(re.sub(r"<[^>]+>", " ", row["column"]).split()), "nodes": flyover.nodes}
|
||||
return view
|
||||
|
||||
|
||||
def test_the_nodes_of_both_mappings_are_shown_and_each_conflict_names_its_peer():
|
||||
view = shown(["A", "B"], {
|
||||
"https://example.invalid/A": [["Shared"], {}],
|
||||
"other": [["Own"], {"title_aux": "A"}],
|
||||
"B": [["Shared"], {}],
|
||||
})
|
||||
|
||||
assert view == {
|
||||
"A": {"column": "2 nodes 1 conflict", "nodes": {"Shared": ["B"], "Own": []}},
|
||||
"B": {"column": "1 node 1 conflict", "nodes": {"Shared": ["A"]}},
|
||||
}
|
||||
|
||||
|
||||
def test_a_node_in_both_mappings_of_a_pack_is_no_conflict_with_itself():
|
||||
view = shown(["A"], {
|
||||
"https://example.invalid/A": [["Shared"], {}],
|
||||
"other": [["Shared"], {"title_aux": "A"}],
|
||||
})
|
||||
|
||||
assert view == {"A": {"column": "1 node", "nodes": {"Shared": []}}}
|
||||
|
||||
|
||||
def test_a_node_in_both_mappings_of_a_pack_names_another_pack_once():
|
||||
view = shown(["A", "B"], {
|
||||
"https://example.invalid/A": [["Shared"], {}],
|
||||
"other": [["Shared"], {"title_aux": "A"}],
|
||||
"B": [["Shared"], {}],
|
||||
})
|
||||
|
||||
assert view == {
|
||||
"A": {"column": "1 node 1 conflict", "nodes": {"Shared": ["B"]}},
|
||||
"B": {"column": "1 node 1 conflict", "nodes": {"Shared": ["A"]}},
|
||||
}
|
||||
@@ -48,7 +48,7 @@ xformers 0.0.30+cu126
|
||||
@pytest.fixture
|
||||
def set_lists(monkeypatch):
|
||||
"""Replace the `pip list` output and return a setter for the two lists."""
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'make_pip_cmd', lambda cmd: ['python', '-m', 'pip', *cmd])
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'get_pip_cmd', lambda force_uv=False: ['python', '-m', 'pip'])
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'subprocess', SimpleNamespace(
|
||||
check_output=lambda *args, **kwargs: PIP_LIST, CalledProcessError=subprocess.CalledProcessError))
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'pip_map', None)
|
||||
@@ -77,7 +77,7 @@ def load_prestartup(**module_globals):
|
||||
pytest.skip('MANAGER_GLOB_DIR points at a glob directory without prestartup_script.py beside it')
|
||||
return load_functions(
|
||||
PRESTARTUP_SCRIPT,
|
||||
{'is_installed', 'remap_pip_package', 'execute_lazy_install_script', 'execute_startup_script'},
|
||||
{'is_installed', 'execute_lazy_install_script', 'execute_startup_script'},
|
||||
**module_globals)
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ from types import SimpleNamespace
|
||||
import cm_global, manager_util
|
||||
|
||||
PIP_LIST = {PIP_LIST!r}
|
||||
manager_util.make_pip_cmd = lambda cmd: ['python', '-m', 'pip', *cmd]
|
||||
manager_util.get_pip_cmd = lambda force_uv=False: ['python', '-m', 'pip']
|
||||
manager_util.subprocess = SimpleNamespace(
|
||||
check_output=lambda *args, **kwargs: PIP_LIST, CalledProcessError=subprocess.CalledProcessError)
|
||||
manager_util.pip_map = None
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"""The Update button of a nodepack that is only in the registry, through the real get_unified_total_nodes."""
|
||||
|
||||
from test_flagged_nodepack_policy import run
|
||||
|
||||
|
||||
def test_registry_only_rows_offer_update_only_for_an_older_version():
|
||||
data = run('''
|
||||
manager.reload = AsyncMock()
|
||||
manager.get_custom_nodes = AsyncMock(return_value={})
|
||||
core.flag_invalid_installation = lambda *a, **k: None
|
||||
packs = ('active-1.0.0', 'active-nightly', 'active-2.0.0', 'disabled-1.0.0', 'not-installed')
|
||||
for pack in packs:
|
||||
manager.cnr_map[pack] = {'id': pack, 'name': pack, 'publisher': {'name': 'p'},
|
||||
'latest_version': {'version': '2.0.0'}}
|
||||
manager.active_nodes['active-1.0.0'] = ('1.0.0', str(nodes / 'active-1.0.0'))
|
||||
manager.active_nodes['active-nightly'] = ('nightly', str(nodes / 'active-nightly'))
|
||||
manager.active_nodes['active-2.0.0'] = ('2.0.0', str(nodes / 'active-2.0.0'))
|
||||
manager.cnr_inactive_nodes['disabled-1.0.0'] = {'1.0.0': str(nodes / '.disabled/disabled-1.0.0')}
|
||||
rows = asyncio.run(core.get_unified_total_nodes(core.DEFAULT_CHANNEL, 'cache'))
|
||||
print(json.dumps({pack: rows[pack].get('update-state') for pack in packs}))
|
||||
''')
|
||||
assert data == {'active-1.0.0': 'true', 'active-nightly': 'false', 'active-2.0.0': 'false',
|
||||
'disabled-1.0.0': 'false', 'not-installed': 'false'}
|
||||
@@ -0,0 +1,219 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from test_install_flags_config import _run_child
|
||||
from test_pip_blacklist_matching import CM_GLOBAL, MANAGER_UTIL, load_prestartup, set_lists # noqa: F401 -- fixture
|
||||
|
||||
INDEX = 'https://example.invalid/whl/cu121'
|
||||
MIRROR = 'https://example.invalid/simple'
|
||||
REPO = 'git+https://example.invalid/packs/proto'
|
||||
OVERRIDES = {'opencv-python': 'opencv-contrib-python-headless'}
|
||||
FORCED = ['--force-reinstall', '--no-deps', '--no-cache-dir']
|
||||
|
||||
LINES = {
|
||||
'demo-pkg': [['demo-pkg']],
|
||||
'demo-pkg==1.2': [['demo-pkg==1.2']],
|
||||
'demo-pkg>=1,<2': [['demo-pkg>=1,<2']],
|
||||
'demo-pkg; python_version < "3.12"': [['demo-pkg; python_version < "3.12"']],
|
||||
'opencv-python': [['opencv-contrib-python-headless']],
|
||||
'pygit2>=1.18 # clone_repository(proxy=...) requires 1.18.0+': [['pygit2>=1.18']],
|
||||
'demo-pkg; python_version < "3.12" # older pythons': [['demo-pkg; python_version < "3.12"']],
|
||||
'opencv-python # headless on servers': [['opencv-contrib-python-headless']],
|
||||
f'torch --index-url {INDEX}': [['torch', '--index-url', INDEX]],
|
||||
f'torch==2.1.1 --index-url {INDEX} # the CUDA build': [['torch==2.1.1', '--index-url', INDEX]],
|
||||
f'torch --extra-index-url {INDEX} # the CUDA build': [['torch', '--extra-index-url', INDEX]],
|
||||
f'torch --index-url {MIRROR} --extra-index-url {INDEX}': [['torch', '--index-url', MIRROR, '--extra-index-url', INDEX]],
|
||||
'# a comment': [],
|
||||
' ': [],
|
||||
}
|
||||
URL_LINES = {
|
||||
f'{REPO}#subdirectory=sub': [f'{REPO}#subdirectory=sub'],
|
||||
f'proto-dist @ {REPO}#egg=proto-dist # pinned': [f'proto-dist @ {REPO}#egg=proto-dist'],
|
||||
}
|
||||
BLACKLISTED = ['xformers', 'xformers # attention', f'xformers --index-url {INDEX}', f'XFormers>=0.0.30 --extra-index-url {INDEX} # attention']
|
||||
OPTION_ROWS = {
|
||||
f'--extra-index-url {INDEX}': f'--extra-index-url {INDEX}',
|
||||
f'--index-url {INDEX} # the CUDA build': f'--index-url {INDEX}',
|
||||
'-r other.txt': '-r other.txt',
|
||||
'-c constraints.txt': '-c constraints.txt',
|
||||
'-f https://example.invalid/wheels': '-f https://example.invalid/wheels',
|
||||
'--trusted-host example.invalid': '--trusted-host example.invalid',
|
||||
'--only-binary :all:': '--only-binary :all:',
|
||||
' --hash=sha256:4bc89822243270757f4c272934e2521ad4b41f0cdcdce82672eeacf01ca3d5f1': '--hash=sha256:4bc89822243270757f4c272934e2521ad4b41f0cdcdce82672eeacf01ca3d5f1',
|
||||
}
|
||||
EDITABLE_ROWS = {
|
||||
'-e ./local': ['-e', './local'],
|
||||
'-e .': ['-e', '.'],
|
||||
'--editable ./local': ['-e', './local'],
|
||||
'--editable=./local': ['-e', './local'],
|
||||
'-e./local': ['-e', './local'],
|
||||
f'-e {REPO}#egg=proto-dist # pinned': ['-e', f'{REPO}#egg=proto-dist'],
|
||||
'-e requests': ['-e', 'requests'],
|
||||
f'-e ./local --extra-index-url {INDEX}': ['-e', './local', '--extra-index-url', INDEX],
|
||||
}
|
||||
WITH_A_ROW_AFTER = {row: f'{row}\ndemo-pkg' for row in [*OPTION_ROWS, *EDITABLE_ROWS]}
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def core_runs():
|
||||
return _run_child(f"""
|
||||
import contextlib, io, pathlib, subprocess
|
||||
from types import SimpleNamespace
|
||||
import cm_global, manager_util
|
||||
|
||||
manager_util.get_pip_cmd = lambda force_uv=False: ['python', '-m', 'pip']
|
||||
manager_util.subprocess = SimpleNamespace(
|
||||
check_output=lambda *args, **kwargs: 'Package Version\\n------- -------\\n', CalledProcessError=subprocess.CalledProcessError)
|
||||
manager_util.pip_map = None
|
||||
manager_util.PIPFixer = lambda *args: SimpleNamespace(fix_broken=lambda: None)
|
||||
cm_global.pip_blacklist, cm_global.pip_downgrade_blacklist, cm_global.pip_overrides = {{'xformers'}}, [], {OVERRIDES!r}
|
||||
executed = []
|
||||
manager_core.manager_funcs.run_script = lambda cmd, cwd='.': executed.append(cmd[4:]) or int(cmd[4].startswith('-') and cmd[4] != '-e')
|
||||
manager = manager_core.unified_manager
|
||||
runs = {{}}
|
||||
for number, line in enumerate({[*LINES, *URL_LINES, *BLACKLISTED, *WITH_A_ROW_AFTER.values()]!r}):
|
||||
pack = pathlib.Path(tmp) / f'pack{{number}}'
|
||||
pack.mkdir()
|
||||
(pack / 'requirements.txt').write_text(line + '\\n', encoding='utf-8')
|
||||
manager.unknown_active_nodes = {{'pack': ('https://example.invalid/pack', str(pack))}}
|
||||
runs[line] = {{}}
|
||||
for path, action in [('install', lambda: manager.execute_install_script(None, str(pack), instant_execution=True)),
|
||||
('fix', lambda: manager.unified_fix('pack', 'unknown', instant_execution=True).result),
|
||||
('install from a git url', lambda: manager_core.execute_install_script(None, str(pack), instant_execution=True))]:
|
||||
manager.processed_install = set()
|
||||
del executed[:]
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out):
|
||||
ok = action()
|
||||
runs[line][path] = {{'commands': list(executed), 'ok': bool(ok), 'said': [said for said in out.getvalue().splitlines() if 'one row at a time' in said]}}
|
||||
print(json.dumps(runs))
|
||||
""")
|
||||
|
||||
|
||||
@pytest.fixture(params=['install', 'fix', 'install from a git url', 'start'])
|
||||
def installs(request, core_runs, set_lists, monkeypatch, tmp_path, capsys): # noqa: F811
|
||||
monkeypatch.setattr(CM_GLOBAL, 'pip_overrides', OVERRIDES)
|
||||
set_lists(blacklist={'xformers'})
|
||||
|
||||
def start(line):
|
||||
(tmp_path / 'requirements.txt').write_text(line + '\n', encoding='utf-8')
|
||||
executed = []
|
||||
startup = load_prestartup(processed_install=set(), comfy_path=str(tmp_path),
|
||||
process_wrap=lambda cmd, cwd=None, **kwargs: executed.append(cmd[4:]) or int(cmd[4].startswith('-') and cmd[4] != '-e'))
|
||||
capsys.readouterr()
|
||||
startup['execute_lazy_install_script'](str(tmp_path), 'python')
|
||||
said = [said for said in capsys.readouterr().out.splitlines() if 'one row at a time' in said]
|
||||
return SimpleNamespace(commands=executed, ok=True, said=said)
|
||||
|
||||
installs = start if request.param == 'start' else lambda line: SimpleNamespace(**core_runs[line][request.param])
|
||||
installs.path = request.param
|
||||
return installs
|
||||
|
||||
|
||||
@pytest.mark.parametrize('line', LINES)
|
||||
def test_each_path_gives_the_installer_the_line_as_pip_reads_it(installs, line):
|
||||
assert installs(line).commands == LINES[line]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('line', URL_LINES)
|
||||
def test_a_url_keeps_its_fragment_on_each_path(installs, line):
|
||||
forced = [[*URL_LINES[line], *FORCED]] if installs.path == 'fix' else []
|
||||
assert installs(line).commands == [URL_LINES[line], *forced]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('line', BLACKLISTED)
|
||||
def test_a_blacklisted_package_is_skipped_however_its_line_is_written(installs, line):
|
||||
assert installs(line).commands == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row', OPTION_ROWS)
|
||||
def test_a_row_with_only_an_option_is_left_out_with_one_line_and_the_rows_after_it_are_installed(installs, row):
|
||||
run = installs(WITH_A_ROW_AFTER[row])
|
||||
|
||||
assert (run.commands, run.ok) == ([['demo-pkg']], True)
|
||||
assert len(run.said) == 1 and f"'{OPTION_ROWS[row]}'" in run.said[0]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('row', EDITABLE_ROWS)
|
||||
def test_an_editable_row_goes_to_the_installer_as_its_option_and_its_target(installs, row):
|
||||
run = installs(WITH_A_ROW_AFTER[row])
|
||||
|
||||
assert (run.commands, run.ok, run.said) == ([EDITABLE_ROWS[row], ['demo-pkg']], True, [])
|
||||
|
||||
|
||||
@pytest.mark.parametrize('line', ['# a comment', ' ', 'demo-pkg'])
|
||||
def test_a_row_that_is_not_an_option_row_is_left_out_or_installed_without_that_line(installs, line):
|
||||
assert installs(line).said == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installer, row, installed, said', [
|
||||
(['python', '-m', 'pip'], f'-e {REPO}#egg=proto-dist # pinned', ['-e', f'{REPO}#egg=proto-dist'], False),
|
||||
(['python', '-m', 'uv', 'pip'], f'-e {REPO}#egg=proto-dist # pinned', [f'{REPO}#egg=proto-dist'], True),
|
||||
(['uv', 'pip'], f'--editable={REPO}#egg=proto-dist --extra-index-url {INDEX}', [f'{REPO}#egg=proto-dist', '--extra-index-url', INDEX], True),
|
||||
(['uv', 'pip'], f'-e {REPO}#egg=proto-dist --no-build-isolation', [f'-e {REPO}#egg=proto-dist --no-build-isolation'], False),
|
||||
(['python', '-m', 'pip'], '-e ./local', ['-e', './local'], False),
|
||||
(['uv', 'pip'], '-e ./local', ['-e', './local'], False),
|
||||
(['uv', 'pip'], f'{REPO}#egg=proto-dist', [f'{REPO}#egg=proto-dist'], False),
|
||||
])
|
||||
def test_uv_installs_an_editable_git_requirement_without_e_and_pip_installs_it_as_it_is_written(installer, row, installed, said, monkeypatch, capsys):
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'get_pip_cmd', lambda force_uv=False: installer)
|
||||
|
||||
assert MANAGER_UTIL.pip_install_args(row, {}) == installed
|
||||
assert ('without -e' in capsys.readouterr().out) == said
|
||||
|
||||
|
||||
SAME_ROW_OF_TWO_NODEPACKS = {
|
||||
'-e .': ['pack-a', 'pack-b'],
|
||||
'-e ./local': ['pack-a', 'pack-b'],
|
||||
'./wheels/demo_pkg-1.0-py3-none-any.whl': ['pack-a', 'pack-b'],
|
||||
'-e .[extra]': ['pack-a', 'pack-b'],
|
||||
'./wheels/demo_pkg-1.0-py3-none-any.whl; python_version >= "3"': ['pack-a', 'pack-b'],
|
||||
'demo-pkg': ['pack-a'],
|
||||
'demo-pkg[extra]>=1; python_version >= "3"': ['pack-a'],
|
||||
f'-e {REPO}#egg=proto-dist': ['pack-a'],
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def session_runs():
|
||||
return _run_child(f"""
|
||||
import pathlib, subprocess
|
||||
from types import SimpleNamespace
|
||||
import cm_global, manager_util
|
||||
|
||||
manager_util.get_pip_cmd = lambda force_uv=False: ['python', '-m', 'pip']
|
||||
manager_util.subprocess = SimpleNamespace(
|
||||
check_output=lambda *args, **kwargs: 'Package Version\\n------- -------\\n', CalledProcessError=subprocess.CalledProcessError)
|
||||
manager_util.pip_map = None
|
||||
manager_util.PIPFixer = lambda *args: SimpleNamespace(fix_broken=lambda: None)
|
||||
cm_global.pip_blacklist, cm_global.pip_downgrade_blacklist, cm_global.pip_overrides = set(), [], {{}}
|
||||
installed_in = []
|
||||
manager_core.manager_funcs.run_script = lambda cmd, cwd='.': installed_in.append(pathlib.Path(cwd).name) or 0
|
||||
manager = manager_core.unified_manager
|
||||
runs = {{}}
|
||||
for number, row in enumerate({[*SAME_ROW_OF_TWO_NODEPACKS]!r}):
|
||||
packs = [pathlib.Path(tmp) / f'row{{number}}' / name for name in ('pack-a', 'pack-b')]
|
||||
for pack in packs:
|
||||
(pack / 'local').mkdir(parents=True)
|
||||
(pack / 'wheels').mkdir()
|
||||
(pack / 'wheels' / 'demo_pkg-1.0-py3-none-any.whl').write_bytes(b'')
|
||||
(pack / 'requirements.txt').write_text(row + '\\n', encoding='utf-8')
|
||||
manager.unknown_active_nodes = {{pack.name: ('https://example.invalid/' + pack.name, str(pack)) for pack in packs}}
|
||||
runs[row] = {{}}
|
||||
fixed = set()
|
||||
for path, action in [('install', lambda pack: manager.execute_install_script(None, str(pack), instant_execution=True)),
|
||||
('fix', lambda pack: manager.unified_fix(pack.name, 'unknown', instant_execution=True, fixed=fixed))]:
|
||||
manager.processed_install = set()
|
||||
del installed_in[:]
|
||||
for pack in packs:
|
||||
action(pack)
|
||||
runs[row][path] = list(installed_in)
|
||||
print(json.dumps(runs))
|
||||
""")
|
||||
|
||||
|
||||
@pytest.mark.parametrize('path', ['install', 'fix'])
|
||||
@pytest.mark.parametrize('row', SAME_ROW_OF_TWO_NODEPACKS)
|
||||
def test_a_row_that_names_a_path_of_the_nodepack_is_installed_for_each_nodepack_of_a_session(session_runs, row, path):
|
||||
assert session_runs[row][path] == SAME_ROW_OF_TWO_NODEPACKS[row]
|
||||
@@ -25,17 +25,27 @@ PIPS = {
|
||||
'torch==2.5.1': '',
|
||||
}
|
||||
|
||||
GIT_URL = 'git+https://example.com/vcs-pack.git@0123abcd#egg=vcs-pack'
|
||||
EDITABLE = {
|
||||
'alpha==1.0': '',
|
||||
'# Editable install with no version control (local-pack==0.1)': '',
|
||||
'-e /work/local-pack': '',
|
||||
'-e file:///work/uv-pack': '',
|
||||
f'-e {GIT_URL}': '',
|
||||
}
|
||||
UV = ['uv', 'pip']
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def restore(monkeypatch, capsys):
|
||||
"""Run restore_pip_snapshot() with pip replaced; return the pip commands and the reported failures."""
|
||||
manager_util = MANAGER_UTIL
|
||||
|
||||
def run(options, failing=()):
|
||||
def run(options, failing=(), pips=PIPS, installer=('python', '-m', 'pip')):
|
||||
commands = []
|
||||
|
||||
def check_call(cmd, **_):
|
||||
commands.append(cmd[3:])
|
||||
commands.append(cmd[len(installer):])
|
||||
if any(name in arg for arg in cmd for name in failing):
|
||||
raise subprocess.CalledProcessError(1, cmd)
|
||||
return 0
|
||||
@@ -44,13 +54,13 @@ def restore(monkeypatch, capsys):
|
||||
# pip's output, as the real check_output returns it: never an exit status.
|
||||
return check_call(cmd) or b'Successfully installed\n'
|
||||
|
||||
monkeypatch.setattr(manager_util, 'make_pip_cmd', lambda cmd: ['python', '-m', 'pip', *cmd])
|
||||
monkeypatch.setattr(manager_util, 'get_pip_cmd', lambda force_uv=False: list(installer))
|
||||
monkeypatch.setattr(manager_util, 'subprocess', SimpleNamespace(
|
||||
check_call=check_call, check_output=check_output,
|
||||
CalledProcessError=subprocess.CalledProcessError))
|
||||
|
||||
run.not_installed = manager_util.restore_pip_snapshot(PIPS, options)
|
||||
report = capsys.readouterr().out.strip().splitlines()[-1]
|
||||
run.not_installed = manager_util.restore_pip_snapshot(pips, options)
|
||||
*run.said, report = capsys.readouterr().out.strip().splitlines()
|
||||
return commands, report
|
||||
|
||||
return run
|
||||
@@ -119,3 +129,47 @@ def test_group_without_its_option_is_left_alone(restore):
|
||||
|
||||
assert commands == []
|
||||
assert report == 'Installation failed for pip packages: []'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('option, installed', [
|
||||
('--pip-non-url', [['install', 'alpha==1.0']]),
|
||||
('--pip-local-url', [['install', '--no-deps', '-e', '/work/local-pack'],
|
||||
['install', '--no-deps', '-e', 'file:///work/uv-pack']]),
|
||||
('--pip-non-local-url', [['install', '--no-deps', '-e', GIT_URL]]),
|
||||
])
|
||||
def test_editable_install_is_restored_as_editable_with_the_option_of_its_url(restore, option, installed):
|
||||
commands, report = restore([option], pips=EDITABLE)
|
||||
|
||||
assert commands == installed
|
||||
assert restore.said == []
|
||||
assert report == 'Installation failed for pip packages: []'
|
||||
|
||||
|
||||
def test_uv_restores_an_editable_install_of_a_git_url_without_e(restore):
|
||||
commands, report = restore(['--pip-non-local-url', '--pip-local-url'], pips=EDITABLE, installer=UV)
|
||||
|
||||
assert commands == [['install', '--no-deps', GIT_URL],
|
||||
['install', '--no-deps', '-e', '/work/local-pack'],
|
||||
['install', '--no-deps', '-e', 'file:///work/uv-pack']]
|
||||
assert restore.said == [f"[ComfyUI-Manager] uv installs an editable from a local folder only: '{GIT_URL}' is installed without -e"]
|
||||
assert report == 'Installation failed for pip packages: []'
|
||||
|
||||
|
||||
def test_uv_says_nothing_of_an_editable_install_that_its_option_leaves_alone(restore):
|
||||
commands, _ = restore(['--pip-local-url'], pips=EDITABLE, installer=UV)
|
||||
|
||||
assert commands == [['install', '--no-deps', '-e', '/work/local-pack'], ['install', '--no-deps', '-e', 'file:///work/uv-pack']]
|
||||
assert restore.said == []
|
||||
|
||||
|
||||
def test_an_editable_git_url_that_uv_does_not_install_is_reported_as_the_snapshot_has_it(restore):
|
||||
_, report = restore(['--pip-non-local-url'], failing=['vcs-pack'], pips=EDITABLE, installer=UV)
|
||||
|
||||
assert report == f"Installation failed for pip packages: ['-e {GIT_URL}']"
|
||||
|
||||
|
||||
def test_editable_install_whose_path_is_gone_is_reported(restore):
|
||||
_, report = restore(['--pip-non-url', '--pip-local-url'], failing=['/work/local-pack'], pips=EDITABLE)
|
||||
|
||||
assert report == "Installation failed for pip packages: ['-e /work/local-pack']"
|
||||
assert restore.not_installed == ['-e /work/local-pack']
|
||||
|
||||
@@ -130,6 +130,7 @@ def test_enabled_version_of_the_registry_is_disabled_before_the_clone_of_a_snaps
|
||||
assert lines(f'''
|
||||
manager.repo_cnr_map['{URL}'] = {{'id': 'fixture'}}
|
||||
manager.get_custom_nodes.return_value = {{'fixture': {{'repository': '{URL}'}}}} if {in_node_list} else {{}}
|
||||
(nodes / 'fixture').mkdir()
|
||||
manager.active_nodes['fixture'] = ('1.0.0', str(nodes / 'fixture'))
|
||||
done = steps()
|
||||
result = summary(cnr_custom_nodes=None, **pinned('{URL}')) + [done]
|
||||
@@ -166,6 +167,7 @@ result = summary(cnr_custom_nodes=saved['cnr_custom_nodes'], git_custom_nodes=sa
|
||||
def test_clone_that_is_enabled_is_left_to_the_install_of_the_version_that_the_snapshot_names():
|
||||
assert lines('''
|
||||
manager.repo_cnr_map[URL] = {'id': 'fixture'}
|
||||
(nodes / 'fixture').mkdir()
|
||||
manager.active_nodes['fixture'] = ('nightly', str(nodes / 'fixture'))
|
||||
done = steps()
|
||||
result = summary(cnr_custom_nodes={'fixture': '1.0.0'}, git_custom_nodes={URL: {'hash': HASH, 'disabled': True}}) + [done]
|
||||
@@ -178,11 +180,12 @@ result = summary(cnr_custom_nodes={'fixture': '1.0.0'}, git_custom_nodes={URL: {
|
||||
[f'[ CHECKOUT ] fixture@{HASH}', '[ FAILED ] fixture@1.0.0', ['disable fixture', 'enable fixture@nightly']]),
|
||||
("manager.cnr_inactive_nodes['fixture'] = {'2.0.0': str(nodes / '.disabled/fixture@2_0_0')}; "
|
||||
"manager._cnr_switch_version = lambda name, version, *args: core.ManagedResult('switch-cnr').fail('the download failed')",
|
||||
[f'[ CHECKOUT ] fixture@{HASH}', '[ FAILED ] fixture@1.0.0', ['disable fixture', 'enable fixture@cnr', 'enable fixture@nightly']]),
|
||||
[f'[ CHECKOUT ] fixture@{HASH}', '[ FAILED ] fixture@1.0.0', ['enable fixture@cnr', 'disable fixture', 'enable fixture@nightly']]),
|
||||
], ids=['the registry does not have it', 'its download fails', 'its download fails after another version was enabled'])
|
||||
def test_clone_of_the_snapshot_is_restored_when_the_version_that_the_snapshot_names_cannot_be_installed(failure, state):
|
||||
assert lines(f'''
|
||||
manager.repo_cnr_map[URL] = {{'id': 'fixture'}}
|
||||
(nodes / 'fixture').mkdir()
|
||||
manager.active_nodes['fixture'] = ('nightly', str(nodes / 'fixture'))
|
||||
done = steps()
|
||||
def disable(name, is_unknown):
|
||||
@@ -192,6 +195,7 @@ def disable(name, is_unknown):
|
||||
def enable(name, version):
|
||||
done.append('enable %s@%s' % (name, version))
|
||||
if version == 'cnr':
|
||||
disable(name, False)
|
||||
manager.active_nodes[name] = ('2.0.0', manager.cnr_inactive_nodes[name].pop('2.0.0'))
|
||||
return core.ManagedResult('enable').with_target(str(nodes / name))
|
||||
manager.unified_disable, manager.unified_enable = disable, enable
|
||||
@@ -308,6 +312,44 @@ result = summary(**pinned('{URL}')) + [[x.args for x in core.repo_switch_commit.
|
||||
''') == [line, True]
|
||||
|
||||
|
||||
LISTED_AS_DISABLED = {
|
||||
'registry_git_pack': ("manager.active_nodes[name] = ('nightly', str(nodes / name)); manager.repo_cnr_map[url] = {'id': name}",
|
||||
['[ DISABLED ] fixture', ['disable fixture']]),
|
||||
'unknown_git_pack': ("manager.unknown_active_nodes[name] = git_pack(name, url)", ['[ DISABLED ] fixture', ['disable fixture']]),
|
||||
'disabled_registry_git_pack': ("manager.nightly_inactive_nodes[name] = git_pack('.disabled/' + name, url)[1]; manager.repo_cnr_map[url] = {'id': name}", [[]]),
|
||||
'disabled_unknown_git_pack': ("manager.unknown_inactive_nodes[name] = git_pack('.disabled/' + name, url)", [[]]),
|
||||
'registry_git_pack_that_is_not_installed': ("manager.repo_cnr_map[url] = {'id': name}", [[]]),
|
||||
'unknown_git_pack_that_is_not_installed': ("", [[]]),
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('installed', LISTED_AS_DISABLED)
|
||||
def test_git_pack_that_the_snapshot_lists_as_disabled_is_restored_as_disabled(installed):
|
||||
"""Enabled, it is disabled; disabled, it is left as it is; not installed, it is not cloned."""
|
||||
assert lines(f'''
|
||||
name, url = 'fixture', URL
|
||||
{LISTED_AS_DISABLED[installed][0]}
|
||||
done = steps()
|
||||
result = summary(git_custom_nodes={{URL: {{'hash': HASH, 'disabled': True}}}}) + [done]
|
||||
''') == LISTED_AS_DISABLED[installed][1]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('folders', ['nodes, more', 'more, nodes'], ids=['enabled_clone_read_first', 'disabled_clone_read_first'])
|
||||
def test_snapshot_lists_a_repository_as_enabled_when_one_of_its_two_clones_is_enabled(folders):
|
||||
"""Both clones have the URL that names the entry: the enabled one is what a restore brings back."""
|
||||
assert lines(f'''
|
||||
more = nodes.parent / 'more_nodes'
|
||||
enabled, disabled = nodes / 'fixture', more / '.disabled/fixture'
|
||||
repository(enabled)
|
||||
subprocess.run(['git', 'checkout', '-q', repository(disabled)[0]], cwd=disabled, check=True)
|
||||
for clone in (enabled, disabled):
|
||||
subprocess.run(['git', 'remote', 'add', 'origin', URL], cwd=clone, check=True)
|
||||
core.get_custom_nodes_paths = lambda: [str(folder) for folder in ({folders})]
|
||||
saved = asyncio.run(core.get_current_snapshot(custom_nodes_only=True))['git_custom_nodes']
|
||||
result = [list(saved), saved[URL]['disabled'], saved[URL]['hash'] == head(enabled)]
|
||||
''') == [[URL], False, True]
|
||||
|
||||
|
||||
def test_installed_git_pack_the_registry_does_not_know_is_checked_out_at_the_pinned_commit():
|
||||
assert lines(f'''
|
||||
commits = repository(nodes / 'fixture')
|
||||
@@ -511,7 +553,7 @@ def installs(*answers):
|
||||
return answers.pop(0)
|
||||
|
||||
core.try_install_script = try_install_script
|
||||
core.remap_pip_package = lambda package: package
|
||||
core.cm_global.pip_overrides = {}
|
||||
manager_util.PIPFixer = Mock()
|
||||
manager_util.get_installed_packages = Mock(return_value={})
|
||||
return ran
|
||||
|
||||
@@ -24,7 +24,6 @@ OPEN_GRID = """async (rows) => {
|
||||
keywords: '',
|
||||
filter: '',
|
||||
grid: new ManagerGrid(document.getElementById('grid')),
|
||||
hasAlternatives() { return false; },
|
||||
setDisabled() {},
|
||||
%(show_loading)s,
|
||||
%(hide_loading)s,
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from test_grid_highlight_escaping import browser # noqa: F401 -- fixture
|
||||
|
||||
JS = Path(os.environ.get("MANAGER_JS_DIR") or (Path(__file__).resolve().parent.parent / "js"))
|
||||
EXTENSION = "http://manager.test/extensions/comfyui-manager/"
|
||||
|
||||
ANSWERS = {
|
||||
"/manager/db_mode": "cache",
|
||||
"/manager/channel_url_list": {"list": ["default::https://example.invalid/channel"], "selected": "default"},
|
||||
}
|
||||
|
||||
MENUS = {
|
||||
"top bar": '<header id="topbar"></header><div class="comfy-menu" style="display: none"></div>',
|
||||
"old menu": '<div class="comfy-menu"></div>',
|
||||
}
|
||||
|
||||
STAND_INS = {
|
||||
"scripts/api.js": """
|
||||
class Api extends EventTarget {
|
||||
async fetchApi(path, options) {
|
||||
const answer = window.answers[path.split('?')[0]] ?? '';
|
||||
if(options?.method == 'POST' && path == '/manager/share_option') {
|
||||
window.saved = JSON.parse(options.body).value;
|
||||
}
|
||||
return {status: 200, json: async () => answer, text: async () => typeof answer == 'string' ? answer : JSON.stringify(answer)};
|
||||
}
|
||||
}
|
||||
export const api = new Api();
|
||||
""",
|
||||
"scripts/app.js": """
|
||||
import { ComfyDialog } from './ui.js';
|
||||
const settingsGroup = {element: document.createElement('div')};
|
||||
export const app = {
|
||||
ui: {dialog: new ComfyDialog()},
|
||||
graph: new (class { clear() {} })(),
|
||||
menu: {element: document.createElement('div'), settingsGroup},
|
||||
graphToPrompt: async () => ({}),
|
||||
registerExtension(extension) { window.extension = extension; },
|
||||
};
|
||||
app.graph._nodes = [];
|
||||
app.menu.element.append(settingsGroup.element);
|
||||
""",
|
||||
"scripts/ui.js": """
|
||||
const style = document.createElement('style');
|
||||
style.textContent = '.comfy-modal { display: none; position: fixed; z-index: 100; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 20px; background: #353535; color: #ddd; }';
|
||||
document.head.append(style);
|
||||
|
||||
export function $el(tag, propsOrChildren, children) {
|
||||
const [name, ...classes] = tag.split('.');
|
||||
const element = document.createElement(name);
|
||||
element.classList.add(...classes);
|
||||
if(typeof propsOrChildren == 'string') {
|
||||
propsOrChildren = {textContent: propsOrChildren};
|
||||
}
|
||||
else if(Array.isArray(propsOrChildren) || propsOrChildren instanceof Element) {
|
||||
children = propsOrChildren;
|
||||
propsOrChildren = {};
|
||||
}
|
||||
const {parent, $: callback, dataset, style, ...props} = propsOrChildren ?? {};
|
||||
Object.assign(element.style, style);
|
||||
Object.assign(element.dataset, dataset);
|
||||
Object.assign(element, props);
|
||||
if(children) {
|
||||
element.append(...[children].flat());
|
||||
}
|
||||
parent?.append(element);
|
||||
callback?.(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
export class ComfyDialog {
|
||||
constructor() {
|
||||
this.element = $el('div.comfy-modal', {parent: document.body}, [
|
||||
$el('div.comfy-modal-content', [
|
||||
$el('p', {$: (p) => (this.textElement = p)}),
|
||||
$el('button', {type: 'button', textContent: 'Close', onclick: () => this.close()}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.element.style.display = 'none';
|
||||
}
|
||||
|
||||
show(html) {
|
||||
this.textElement.innerHTML = html;
|
||||
this.element.style.display = 'flex';
|
||||
}
|
||||
}
|
||||
""",
|
||||
"scripts/ui/components/button.js": """
|
||||
const style = document.createElement('style');
|
||||
style.textContent = '.comfyui-button { display: flex; }';
|
||||
document.head.append(style);
|
||||
|
||||
export class ComfyButton {
|
||||
constructor({icon, tooltip, content, action, classList = 'comfyui-button'}) {
|
||||
this.element = document.createElement('button');
|
||||
this.element.className = classList;
|
||||
this.element.title = tooltip;
|
||||
this.element.setAttribute('aria-label', tooltip);
|
||||
this.element.textContent = content ?? icon;
|
||||
this.element.addEventListener('click', (event) => action(event, this));
|
||||
}
|
||||
}
|
||||
""",
|
||||
"scripts/ui/components/buttonGroup.js": """
|
||||
export class ComfyButtonGroup {
|
||||
constructor(...buttons) {
|
||||
this.element = document.createElement('div');
|
||||
this.element.className = 'comfyui-button-group';
|
||||
this.element.append(...buttons);
|
||||
}
|
||||
}
|
||||
""",
|
||||
"extensions/core/groupNode.js": """
|
||||
export class GroupNodeConfig {}
|
||||
export class GroupNodeHandler {}
|
||||
""",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser): # noqa: F811
|
||||
page = browser.new_page()
|
||||
|
||||
def route(request):
|
||||
url = request.request.url
|
||||
name = url.rsplit("/", 1)[-1]
|
||||
stand_in = url.removeprefix("http://manager.test/")
|
||||
if url == "http://manager.test/":
|
||||
request.fulfill(body="<body></body>", content_type="text/html")
|
||||
elif url.startswith(EXTENSION) and (JS / name).is_file():
|
||||
request.fulfill(path=str(JS / name), content_type="text/css" if name.endswith(".css") else "text/javascript")
|
||||
elif stand_in in STAND_INS:
|
||||
request.fulfill(body=STAND_INS[stand_in], content_type="text/javascript")
|
||||
else:
|
||||
request.abort()
|
||||
|
||||
page.route("**/*", route)
|
||||
page.add_init_script("""
|
||||
window.errors = [];
|
||||
addEventListener('error', (event) => errors.push(String(event.error ?? event.message)));
|
||||
addEventListener('unhandledrejection', (event) => errors.push(String(event.reason)));
|
||||
""")
|
||||
page.goto("http://manager.test/")
|
||||
yield page
|
||||
page.close()
|
||||
|
||||
|
||||
def load(page, menu, share_option):
|
||||
page.evaluate("""async ({module, body, answers, share_option}) => {
|
||||
document.body.innerHTML = body;
|
||||
window.answers = {...answers, '/manager/share_option': share_option};
|
||||
await import(module);
|
||||
window.extension.init();
|
||||
await window.extension.setup();
|
||||
const { app } = await import('/scripts/app.js');
|
||||
document.getElementById('topbar')?.append(app.menu.element);
|
||||
}""", {"module": EXTENSION + "comfyui-manager.js", "body": MENUS[menu], "answers": ANSWERS, "share_option": share_option})
|
||||
|
||||
|
||||
def share_buttons(page):
|
||||
return page.get_by_role("button", name="Share", exact=True)
|
||||
|
||||
|
||||
def choose_share(page, value):
|
||||
page.evaluate("window.extension.commands.find((command) => command.id == 'Comfy.Manager.Menu.ToggleVisibility').function()")
|
||||
page.locator(".setting-item", has=page.get_by_text("Share", exact=True)).locator("select").select_option(value)
|
||||
page.wait_for_function("window.saved == '%s'" % value)
|
||||
page.get_by_role("button", name="Close", exact=True).first.click()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("menu", MENUS)
|
||||
@pytest.mark.parametrize("share_option", ["all", "youml", "matrix", "none"])
|
||||
def test_the_share_button_of_the_menu_follows_the_saved_share_setting(page, menu, share_option):
|
||||
load(page, menu, share_option)
|
||||
|
||||
assert share_buttons(page).count() == (0 if share_option == "none" else 1)
|
||||
assert page.evaluate("errors") == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("menu", MENUS)
|
||||
def test_choosing_none_in_the_manager_menu_hides_the_share_button_and_all_shows_it(page, menu):
|
||||
load(page, menu, "all")
|
||||
|
||||
choose_share(page, "none")
|
||||
assert share_buttons(page).count() == 0
|
||||
|
||||
choose_share(page, "all")
|
||||
assert share_buttons(page).count() == 1
|
||||
assert page.evaluate("errors") == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("menu", MENUS)
|
||||
@pytest.mark.parametrize("share_option, opened", [
|
||||
("all", "Choose a platform to share your workflow"),
|
||||
("youml", "Share your workflow to YouML.com"),
|
||||
("matrix", "No supported output node found"),
|
||||
], ids=["all", "youml", "matrix"])
|
||||
def test_a_click_on_the_share_button_opens_what_the_share_setting_says(page, menu, share_option, opened):
|
||||
page.evaluate("window.alert = (message) => { window.alerted = message; }")
|
||||
load(page, menu, share_option)
|
||||
|
||||
share_buttons(page).click()
|
||||
|
||||
page.wait_for_function("""(opened) => window.alerted?.includes(opened)
|
||||
|| [...document.querySelectorAll('.comfy-modal')].some((box) => box.checkVisibility() && box.innerText.includes(opened))""", arg=opened)
|
||||
assert page.evaluate("errors") == []
|
||||
@@ -0,0 +1,49 @@
|
||||
from test_snapshot_restore_pins import run
|
||||
|
||||
PACKS = '''
|
||||
import ast, io
|
||||
from typing_extensions import Annotated
|
||||
import typer
|
||||
from rich.console import Console
|
||||
|
||||
def show(name, kind):
|
||||
found = [node for node in ast.parse(pathlib.Path('cm-cli.py').read_text(encoding='utf-8')).body
|
||||
if isinstance(node, ast.FunctionDef) and node.name in (name, 'show_list')]
|
||||
for node in found:
|
||||
node.decorator_list = []
|
||||
out = io.StringIO()
|
||||
scope = {'typer': typer, 'Annotated': Annotated, 'asyncio': asyncio, 'os': os,
|
||||
'print': Console(file=out, width=1000, color_system=None).print, 'cmd_ctx': Mock(), 'unified_manager': manager}
|
||||
exec(compile(ast.Module(body=found, type_ignores=[]), 'cm-cli.py', 'exec'), scope)
|
||||
scope[name](kind, None, None, None)
|
||||
return [' '.join(line.split()) for line in out.getvalue().splitlines()]
|
||||
|
||||
manager.get_custom_nodes = AsyncMock(return_value={
|
||||
'listed-pack': {'title': 'Listed Pack', 'author': 'someone', 'files': ['https://github.com/someone/listed-pack']},
|
||||
})
|
||||
manager.cnr_map['registry-pack'] = {'id': 'registry-pack', 'name': 'Registry Pack', 'publisher': {'name': 'someone'},
|
||||
'latest_version': {'version': '1.0.0'}}
|
||||
manager.active_nodes['registry-pack'] = ('1.0.0', str(nodes / 'registry-pack'))
|
||||
manager.unknown_active_nodes['listed-pack'] = ('https://github.com/someone/listed-pack', str(nodes / 'listed-pack'))
|
||||
manager.unknown_active_nodes['git-pack'] = ('https://example.invalid/git-pack', str(nodes / 'git-pack'))
|
||||
manager.unknown_inactive_nodes['old-git-pack'] = ('https://example.invalid/old-git-pack', str(nodes / '.disabled/old-git-pack'))
|
||||
'''
|
||||
|
||||
|
||||
def shown(*commands):
|
||||
return run(PACKS + f'print(json.dumps([show(name, kind) for name, kind in {list(commands)!r}]))')
|
||||
|
||||
|
||||
def test_simple_show_lists_every_installed_nodepack():
|
||||
assert shown(('simple_show', 'enabled'), ('simple_show', 'disabled'), ('simple_show', 'installed')) == [
|
||||
['Registry Pack@1.0.0', 'Listed Pack@unknown', 'git-pack@unknown'],
|
||||
['old-git-pack@unknown'],
|
||||
['Registry Pack@1.0.0', 'Listed Pack@unknown', 'git-pack@unknown', 'old-git-pack@unknown'],
|
||||
]
|
||||
|
||||
|
||||
def test_show_names_a_git_nodepack_that_the_lists_do_not_know_by_its_id():
|
||||
assert shown(('show', 'installed'))[0][2:] == [
|
||||
'[ ENABLED ] git-pack git-pack (author: N/A ) [UNKNOWN]',
|
||||
'[ DISABLED ] old-git-pack old-git-pack (author: N/A ) [UNKNOWN]',
|
||||
]
|
||||
@@ -0,0 +1,55 @@
|
||||
import ast
|
||||
import asyncio
|
||||
import json
|
||||
import pathlib
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import Mock
|
||||
|
||||
import typer
|
||||
from rich import print
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from test_core_print import core_print
|
||||
|
||||
CM_CLI = pathlib.Path(__file__).resolve().parent.parent / 'cm-cli.py'
|
||||
|
||||
COMFYUI = 'f0123456789abcdef0123456789abcdef0123456'
|
||||
PACK = 'abcdef0123456789abcdef0123456789abcdef01'
|
||||
URL = 'https://gitlab.com/group/' + 'subgroup/' * 30 + 'pack'
|
||||
SNAPSHOT = {
|
||||
'comfyui': COMFYUI,
|
||||
'git_custom_nodes': {URL: {'hash': PACK, 'disabled': False}},
|
||||
'cnr_custom_nodes': {'registry-pack': '1.0.0'},
|
||||
'file_custom_nodes': [{'filename': 'single.py', 'disabled': False}],
|
||||
'pips': {'torch': '2.0.0'},
|
||||
}
|
||||
|
||||
|
||||
def command(name):
|
||||
async def get_current_snapshot():
|
||||
return SNAPSHOT
|
||||
|
||||
found = [node for node in ast.parse(CM_CLI.read_text(encoding='utf-8')).body
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name in (name, 'show_snapshot')]
|
||||
for node in found:
|
||||
node.decorator_list = []
|
||||
scope = {'typer': typer, 'Annotated': Annotated, 'asyncio': asyncio, 'json': json, 'print': print,
|
||||
'core': SimpleNamespace(get_current_snapshot=get_current_snapshot, print=core_print()), 'cmd_ctx': Mock()}
|
||||
exec(compile(ast.Module(body=found, type_ignores=[]), str(CM_CLI), 'exec'), scope)
|
||||
return scope[name]
|
||||
|
||||
|
||||
def test_show_snapshot_prints_the_current_snapshot(capsys):
|
||||
command('show')('snapshot', None, None, None)
|
||||
|
||||
assert json.loads(capsys.readouterr().out) == SNAPSHOT
|
||||
|
||||
|
||||
def test_simple_show_snapshot_prints_a_line_per_nodepack(capsys):
|
||||
command('simple_show')('snapshot', None, None, None)
|
||||
|
||||
assert capsys.readouterr().out.splitlines() == [
|
||||
f'[{COMFYUI}] comfyui',
|
||||
f'[{PACK}] {URL}',
|
||||
'[ N/A ] single.py',
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
"""Uninstall Selected of the Node Usage Analyzer queues the selected nodepacks and starts the queue.
|
||||
|
||||
The cases run the shipped `uninstallNodes` of common.js in node, on the rows that the shipped code of
|
||||
node-usage-analyzer.js makes from two installed nodepacks as `/customnode/getlist` gives them: one that only the
|
||||
registry lists, which comes without an `id`, and one of custom-node-list.json. A stand-in for the API records each
|
||||
request that changes the queue and answers the start of the queue as the case says.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from js_lift import NODE, JsSource, run_node, slice_braced
|
||||
from test_workflow_node_scan import in_any_order
|
||||
|
||||
JS = JsSource(Path(os.environ.get("MANAGER_JS_DIR") or (Path(__file__).resolve().parent.parent / "js")))
|
||||
|
||||
pytestmark = pytest.mark.skipif(NODE is None, reason="node is required to execute the lifted production JS")
|
||||
|
||||
NODEPACKS = {"comfyui-registry-only": {"title": "Registry only", "state": "enabled", "version": "1.0.0"},
|
||||
"comfyui-listed": {"id": "comfyui-listed", "title": "Listed", "state": "enabled", "version": "nightly"}}
|
||||
JSON_POST = {"method": "POST", "content_type": "application/json"}
|
||||
|
||||
|
||||
def uninstall_selected(start_status):
|
||||
"""Select both rows and confirm Uninstall Selected; return the requests, the result and the messages."""
|
||||
script = """
|
||||
const requests = [], messages = [];
|
||||
const api = {fetchApi: async (route, options = {}) => {
|
||||
if(route === '/manager/queue/status') {
|
||||
return {status: 200, json: async () => ({is_processing: false})};
|
||||
}
|
||||
const request = {route, method: (options.method || 'GET').toUpperCase(),
|
||||
content_type: new Headers(options.headers).get('Content-Type')};
|
||||
if(options.body) {
|
||||
request.id = JSON.parse(options.body).id ?? null;
|
||||
}
|
||||
requests.push(request);
|
||||
return {status: route === '/manager/queue/start' ? %s : 200, text: async () => ''};
|
||||
}};
|
||||
const customConfirm = async () => true;
|
||||
const show_message = (text) => messages.push(text);
|
||||
const showTerminal = () => {};
|
||||
const md5 = (text) => 'md5 of ' + text;
|
||||
%s
|
||||
%s
|
||||
const node_packs = %s;
|
||||
const result = {};
|
||||
const models = [];
|
||||
%s);
|
||||
const answer = await uninstallNodes(models);
|
||||
console.log(JSON.stringify({requests, success: answer.success, messages}));
|
||||
""" % (
|
||||
json.dumps(start_status),
|
||||
JS.lift_declaration("common.js", "export function sanitizeHTML("),
|
||||
JS.lift_declaration("common.js", "export async function uninstallNodes(nodeList, options = {})"),
|
||||
json.dumps(NODEPACKS),
|
||||
slice_braced(JS.text("node-usage-analyzer.js"), "Object.keys(node_packs).forEach((packKey, index) => "),
|
||||
)
|
||||
return run_node(script)
|
||||
|
||||
|
||||
def test_the_selected_nodepacks_are_queued_by_their_names_and_the_queue_is_started():
|
||||
seen = uninstall_selected(start_status=200)
|
||||
first, *queued, last = seen["requests"]
|
||||
|
||||
assert first == {"route": "/manager/queue/reset", **JSON_POST}
|
||||
assert in_any_order(queued) == in_any_order([
|
||||
{"route": "/manager/queue/uninstall", **JSON_POST, "id": "comfyui-registry-only"},
|
||||
{"route": "/manager/queue/uninstall", **JSON_POST, "id": "comfyui-listed"}])
|
||||
assert last == {"route": "/manager/queue/start", **JSON_POST}
|
||||
assert seen["success"] is True
|
||||
assert seen["messages"] == []
|
||||
|
||||
|
||||
def test_a_queue_that_is_already_running_counts_as_started():
|
||||
assert uninstall_selected(start_status=201)["success"] is True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("status", [400, 502])
|
||||
def test_a_queue_that_does_not_start_is_reported(status):
|
||||
seen = uninstall_selected(start_status=status)
|
||||
|
||||
assert seen["success"] is False
|
||||
assert [("HTTP %d" % status) in message for message in seen["messages"]] == [True]
|
||||
@@ -0,0 +1,215 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from test_grid_highlight_escaping import browser # noqa: F401 -- fixture
|
||||
|
||||
JS = Path(os.environ.get("MANAGER_JS_DIR") or (Path(__file__).resolve().parent.parent / "js"))
|
||||
EXTENSION = "http://manager.test/extensions/comfyui-manager/"
|
||||
|
||||
UPDATE_COMFYUI = "/manager/queue/update_comfyui"
|
||||
UPDATE_ALL = "/manager/queue/update_all"
|
||||
START = "/manager/queue/start"
|
||||
REBOOT = "/manager/reboot"
|
||||
ANSWERS = {
|
||||
"/manager/db_mode": "cache",
|
||||
"/manager/channel_url_list": {"list": ["default::https://example.invalid/channel"], "selected": "default"},
|
||||
}
|
||||
|
||||
STAND_INS = {
|
||||
"scripts/api.js": """
|
||||
class Api extends EventTarget {
|
||||
async fetchApi(path, options) {
|
||||
const answer = window.answers[path.split('?')[0]] ?? '';
|
||||
window.requested.push({path, method: options?.method ?? 'GET', body: options?.body ? JSON.parse(options.body) : null});
|
||||
return {status: 200, json: async () => answer, text: async () => typeof answer == 'string' ? answer : JSON.stringify(answer)};
|
||||
}
|
||||
}
|
||||
export const api = new Api();
|
||||
""",
|
||||
"scripts/app.js": """
|
||||
import { ComfyDialog } from './ui.js';
|
||||
export const app = {
|
||||
ui: {dialog: new ComfyDialog()},
|
||||
registerExtension(extension) { window.extension = extension; },
|
||||
};
|
||||
""",
|
||||
"scripts/ui.js": """
|
||||
const style = document.createElement('style');
|
||||
style.textContent = '.comfy-modal { display: none; position: fixed; z-index: 100; top: 50%; left: 50%; transform: translate(-50%, -50%); padding: 20px; background: #353535; color: #ddd; }';
|
||||
document.head.append(style);
|
||||
|
||||
export function $el(tag, propsOrChildren, children) {
|
||||
const [name, ...classes] = tag.split('.');
|
||||
const element = document.createElement(name);
|
||||
element.classList.add(...classes);
|
||||
if(typeof propsOrChildren == 'string') {
|
||||
propsOrChildren = {textContent: propsOrChildren};
|
||||
}
|
||||
else if(Array.isArray(propsOrChildren) || propsOrChildren instanceof Element) {
|
||||
children = propsOrChildren;
|
||||
propsOrChildren = {};
|
||||
}
|
||||
const {parent, $: callback, dataset, style, ...props} = propsOrChildren ?? {};
|
||||
Object.assign(element.style, style);
|
||||
Object.assign(element.dataset, dataset);
|
||||
Object.assign(element, props);
|
||||
if(children) {
|
||||
element.append(...[children].flat());
|
||||
}
|
||||
parent?.append(element);
|
||||
callback?.(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
export class ComfyDialog {
|
||||
constructor() {
|
||||
this.element = $el('div.comfy-modal', {parent: document.body}, [
|
||||
$el('div.comfy-modal-content', [
|
||||
$el('p', {$: (p) => (this.textElement = p)}),
|
||||
$el('button', {type: 'button', textContent: 'Close', onclick: () => this.close()}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.element.style.display = 'none';
|
||||
}
|
||||
|
||||
show(html) {
|
||||
this.textElement.innerHTML = html;
|
||||
this.element.style.display = 'flex';
|
||||
}
|
||||
}
|
||||
""",
|
||||
"extensions/core/groupNode.js": """
|
||||
export class GroupNodeConfig {}
|
||||
export class GroupNodeHandler {}
|
||||
""",
|
||||
}
|
||||
|
||||
UPDATED = {"msg": "success", "title": "ComfyUI-TechsToolz", "url": "https://verify.invalid/packs/ComfyUI-TechsToolz"}
|
||||
UP_TO_DATE = {"msg": "skip", "title": "ComfyUI-CyberUtils", "url": "https://verify.invalid/packs/ComfyUI-CyberUtils"}
|
||||
FAILED = {"msg": "An error occurred while updating 'comfyui-glitchkit'.", "title": "ComfyUI-GlitchKit",
|
||||
"url": "https://verify.invalid/packs/ComfyUI-GlitchKit"}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser): # noqa: F811
|
||||
page = browser.new_page()
|
||||
|
||||
def route(request):
|
||||
url = request.request.url
|
||||
name = url.rsplit("/", 1)[-1]
|
||||
stand_in = url.removeprefix("http://manager.test/")
|
||||
if url == "http://manager.test/":
|
||||
request.fulfill(body="<body></body>", content_type="text/html")
|
||||
elif url.startswith(EXTENSION) and (JS / name).is_file():
|
||||
request.fulfill(path=str(JS / name), content_type="text/css" if name.endswith(".css") else "text/javascript")
|
||||
elif stand_in in STAND_INS:
|
||||
request.fulfill(body=STAND_INS[stand_in], content_type="text/javascript")
|
||||
else:
|
||||
request.abort()
|
||||
|
||||
page.route("**/*", route)
|
||||
page.add_init_script("""
|
||||
window.errors = [];
|
||||
addEventListener('error', (event) => errors.push(String(event.error ?? event.message)));
|
||||
addEventListener('unhandledrejection', (event) => errors.push(String(event.reason)));
|
||||
""")
|
||||
page.goto("http://manager.test/")
|
||||
yield page
|
||||
page.close()
|
||||
|
||||
|
||||
def open_menu(page, electron=False):
|
||||
page.evaluate("""async ({module, answers, electron}) => {
|
||||
if(electron) {
|
||||
window.restarts = 0;
|
||||
window.electronAPI = {restartApp() { window.restarts++; }};
|
||||
}
|
||||
window.requested = [];
|
||||
window.answers = answers;
|
||||
await import(module);
|
||||
window.extension.commands.find((command) => command.id == 'Comfy.Manager.Menu.ToggleVisibility').function();
|
||||
}""", {"module": EXTENSION + "comfyui-manager.js", "answers": ANSWERS, "electron": electron})
|
||||
|
||||
|
||||
def queue_requests(page):
|
||||
page.wait_for_function("requested.some((request) => request.path == '%s')" % START)
|
||||
return page.evaluate("requested.filter((request) => request.path.startsWith('/manager/queue/'))"
|
||||
".map((request) => [request.method, request.path, request.body])")
|
||||
|
||||
|
||||
def report(page, detail):
|
||||
page.evaluate("""async (detail) => {
|
||||
const { api } = await import('/scripts/api.js');
|
||||
api.dispatchEvent(new CustomEvent('cm-queue-status', {detail}));
|
||||
}""", detail)
|
||||
|
||||
|
||||
def finish(page, nodepack_result):
|
||||
total = len(nodepack_result)
|
||||
for done, target in enumerate(nodepack_result):
|
||||
report(page, {"status": "in_progress", "target": target, "ui_target": "main",
|
||||
"total_count": total, "done_count": done})
|
||||
report(page, {"status": "done", "nodepack_result": nodepack_result, "model_result": {},
|
||||
"total_count": total, "done_count": total})
|
||||
|
||||
|
||||
def result(page):
|
||||
page.wait_for_function("errors.length > 0 || [...document.querySelectorAll('.comfy-modal')].some((box) => box.checkVisibility())",
|
||||
timeout=5000)
|
||||
assert page.evaluate("errors") == []
|
||||
box = page.locator(".comfy-modal:visible .comfy-modal-content > p")
|
||||
return box.inner_text(), box.locator("li").all_inner_texts()
|
||||
|
||||
|
||||
def test_update_all_shows_what_was_updated_with_comfyui(page):
|
||||
open_menu(page)
|
||||
page.get_by_role("button", name="Update All", exact=True).click()
|
||||
|
||||
assert queue_requests(page) == [["POST", UPDATE_COMFYUI, None], ["POST", UPDATE_ALL, {"mode": "cache"}], ["POST", START, None]]
|
||||
|
||||
finish(page, {"comfyui": "success-stable-v0.3.60", "comfyui-techstoolz": UPDATED, "comfyui-cyberutils": UP_TO_DATE,
|
||||
"comfyui-glitchkit": FAILED})
|
||||
text, items = result(page)
|
||||
assert "To apply the updates, you need to RESTART ComfyUI." in text
|
||||
assert "ComfyUI has been updated to v0.3.60." in text
|
||||
assert "The following custom nodes have been updated:" in text
|
||||
assert "The update for the following custom nodes has failed:" in text
|
||||
assert items == ["ComfyUI-TechsToolz", "ComfyUI-GlitchKit"]
|
||||
|
||||
page.get_by_role("button", name="RESTART", exact=True).click()
|
||||
page.get_by_text("Are you sure you'd like to reboot the server?").wait_for()
|
||||
page.get_by_role("button", name="Confirm").click()
|
||||
page.wait_for_function("requested.some((request) => request.method == 'POST' && request.path == '%s')" % REBOOT)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("nodepack_result, shown, items, restart", [
|
||||
({"comfyui-techstoolz": UPDATED, "comfyui-cyberutils": UP_TO_DATE},
|
||||
"To apply the updates, you need to RESTART ComfyUI.", ["ComfyUI-TechsToolz"], True),
|
||||
({"comfyui-cyberutils": UP_TO_DATE}, "You are already up to date.", [], False),
|
||||
({"comfyui-glitchkit": FAILED, "comfyui-cyberutils": UP_TO_DATE},
|
||||
"The update for the following custom nodes has failed:", ["ComfyUI-GlitchKit"], False),
|
||||
], ids=["updated", "up-to-date", "failed"])
|
||||
def test_the_electron_button_shows_a_result_without_comfyui(page, nodepack_result, shown, items, restart):
|
||||
open_menu(page, electron=True)
|
||||
page.get_by_role("button", name="Update All Custom Nodes", exact=True).click()
|
||||
|
||||
assert queue_requests(page) == [["POST", UPDATE_ALL, {"mode": "cache"}], ["POST", START, None]]
|
||||
|
||||
finish(page, nodepack_result)
|
||||
text, listed = result(page)
|
||||
assert shown in text
|
||||
assert "ComfyUI has been updated" not in text
|
||||
assert "ComfyUI is already up to date" not in text
|
||||
assert "Failed to update ComfyUI" not in text
|
||||
assert listed == items
|
||||
assert page.get_by_role("button", name="RESTART", exact=True).count() == (1 if restart else 0)
|
||||
|
||||
if restart:
|
||||
page.get_by_role("button", name="RESTART", exact=True).click()
|
||||
page.wait_for_function("window.restarts == 1")
|
||||
assert page.evaluate("errors") == []
|
||||
@@ -398,10 +398,10 @@ def recorder(result=lambda cmd: 0):
|
||||
|
||||
|
||||
def test_fix_installs_a_url_requirement_by_force_and_other_requirements_as_ever(installer):
|
||||
assert MANAGER_UTIL.fix_cmd(f'git+{REPO}') == [*installer.base, 'install', f'git+{REPO}', *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd(f'Proto-Dist @ git+{REPO}') == [*installer.base, 'install', f'Proto-Dist @ git+{REPO}', *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd(WHEEL) == [*installer.base, 'install', WHEEL, *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd('numpy>=1.20') == [*installer.base, 'install', 'numpy>=1.20']
|
||||
assert MANAGER_UTIL.fix_cmd([f'git+{REPO}']) == [*installer.base, 'install', f'git+{REPO}', *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd([f'Proto-Dist @ git+{REPO}']) == [*installer.base, 'install', f'Proto-Dist @ git+{REPO}', *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd([WHEEL]) == [*installer.base, 'install', WHEEL, *installer.forced]
|
||||
assert MANAGER_UTIL.fix_cmd(['numpy>=1.20']) == [*installer.base, 'install', 'numpy>=1.20']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('cmd,forced', [
|
||||
@@ -420,7 +420,7 @@ def test_forced_install_is_known_by_its_url_requirement_and_its_option(cmd, forc
|
||||
def test_fix_installs_the_requirement_as_an_install_does_and_then_the_package_by_force(installer, capsys):
|
||||
"""The first resolves what the package needs and changes nothing when it cannot; the second puts a clean copy there."""
|
||||
run, commands = recorder()
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
|
||||
assert MANAGER_UTIL.reinstall(forced, run) == 0
|
||||
assert commands == [[*installer.base, 'install', f'git+{REPO}'], forced]
|
||||
@@ -429,13 +429,13 @@ def test_fix_installs_the_requirement_as_an_install_does_and_then_the_package_by
|
||||
|
||||
def test_fix_forces_also_what_the_install_has_just_put_there(installer):
|
||||
"""uv takes a commit it has built before from its cache while the remote answers: only the forced install is a clean copy."""
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
run, commands = recorder(lambda cmd: installer.install('Proto-Dist', installer.records['no revision'].replace(COMMIT, LATER)) or 0)
|
||||
|
||||
assert MANAGER_UTIL.reinstall(forced, run) == 0
|
||||
assert commands == [[*installer.base, 'install', f'git+{REPO}'], forced]
|
||||
|
||||
other = MANAGER_UTIL.fix_cmd(OTHER)
|
||||
other = MANAGER_UTIL.fix_cmd([OTHER])
|
||||
run, commands = recorder(lambda cmd: installer.install('Other', installer.records['no revision'].replace(REPO, OTHER[4:])) or 0)
|
||||
|
||||
assert MANAGER_UTIL.reinstall(other, run) == 0
|
||||
@@ -444,7 +444,7 @@ def test_fix_forces_also_what_the_install_has_just_put_there(installer):
|
||||
|
||||
def test_fix_keeps_what_is_installed_when_the_requirement_cannot_be_installed(installer):
|
||||
"""What the new commit needs may not be there to install: the forced install would leave the package without it."""
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
run, commands = recorder(lambda cmd: 1)
|
||||
|
||||
assert MANAGER_UTIL.reinstall(forced, run) == 1
|
||||
@@ -456,7 +456,7 @@ def test_fix_goes_on_when_only_the_forced_install_fails(installer, capsys):
|
||||
|
||||
Nothing is installed in place of the clean copy: that it failed does not say that the remote is out of reach.
|
||||
"""
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
run, commands = recorder(lambda cmd: int(cmd == forced))
|
||||
|
||||
assert MANAGER_UTIL.reinstall(forced, run) == 0
|
||||
@@ -476,7 +476,7 @@ def test_fix_uses_the_cache_of_uv_only_when_the_remote_is_out_of_reach(installer
|
||||
installer.install('Proto-Dist', installer.records[record])
|
||||
asked = []
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'is_git_remote_usable', lambda url: asked.append(url) or remote == 'answers')
|
||||
forced = MANAGER_UTIL.fix_cmd(requirement)
|
||||
forced = MANAGER_UTIL.fix_cmd([requirement])
|
||||
plain = [*installer.base, 'install', requirement]
|
||||
cached = [*installer.base, 'install', from_the_cache, '--force-reinstall', '--no-deps', '--offline']
|
||||
run, commands = recorder(lambda cmd: int(cmd == plain))
|
||||
@@ -492,7 +492,7 @@ def test_fix_uses_the_cache_of_uv_only_when_the_remote_is_out_of_reach(installer
|
||||
def test_fix_does_not_take_a_package_of_another_name_from_the_cache(installer, monkeypatch):
|
||||
"""A requirement that gives a name is met by a distribution of that name only."""
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'is_git_remote_usable', lambda url: False)
|
||||
forced = MANAGER_UTIL.fix_cmd(f'Other-Name @ git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'Other-Name @ git+{REPO}'])
|
||||
run, commands = recorder(lambda cmd: 1)
|
||||
|
||||
assert MANAGER_UTIL.reinstall(forced, run) == 1
|
||||
@@ -502,7 +502,7 @@ def test_fix_does_not_take_a_package_of_another_name_from_the_cache(installer, m
|
||||
def test_fix_with_a_run_that_raises_as_in_cm_cli(installer, monkeypatch):
|
||||
"""What `run` raised for the install is raised again, unless the cache made the fix good."""
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'is_git_remote_usable', lambda url: False)
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
plain = [*installer.base, 'install', f'git+{REPO}']
|
||||
commands = []
|
||||
|
||||
@@ -534,7 +534,7 @@ def startup_runs(tmp_path, lines):
|
||||
|
||||
def test_startup_runs_the_forced_install_a_fix_reserved(installer, tmp_path):
|
||||
"""The plain command for the same requirement is skipped: the package is installed."""
|
||||
forced = MANAGER_UTIL.fix_cmd(f'git+{REPO}')
|
||||
forced = MANAGER_UTIL.fix_cmd([f'git+{REPO}'])
|
||||
plain = [*installer.base, 'install', f'git+{REPO}']
|
||||
|
||||
assert startup_runs(tmp_path, [[str(tmp_path), *plain], [str(tmp_path), *forced]]) == [plain, forced]
|
||||
@@ -550,7 +550,7 @@ def test_command_the_user_forced_is_run_as_it_is(installer, tmp_path):
|
||||
def test_blacklisted_requirement_is_not_installed_by_a_reserved_forced_install(installer, set_lists, tmp_path): # noqa: F811
|
||||
set_lists(blacklist={f'git+{REPO}'})
|
||||
|
||||
assert startup_runs(tmp_path, [[str(tmp_path), *MANAGER_UTIL.fix_cmd(f'git+{REPO}')]]) == []
|
||||
assert startup_runs(tmp_path, [[str(tmp_path), *MANAGER_UTIL.fix_cmd([f'git+{REPO}'])]]) == []
|
||||
|
||||
|
||||
CM_CLI_FIX = """
|
||||
@@ -672,7 +672,7 @@ manager_core.subprocess = SimpleNamespace(check_call=lambda cmd, **options: said
|
||||
console = sys.stdout
|
||||
sys.stdout = SimpleNamespace(write=written.append, flush=lambda: (out.extend(written), written.clear()))
|
||||
try:
|
||||
result = manager_core.try_install_script(None, '.', manager_util.fix_cmd('git+{REPO}'), instant_execution=True)
|
||||
result = manager_core.try_install_script(None, '.', manager_util.fix_cmd(['git+{REPO}']), instant_execution=True)
|
||||
finally:
|
||||
sys.stdout = console
|
||||
print(json.dumps([result, [text.count('EXECUTE =>') for text in said]]))
|
||||
@@ -713,7 +713,7 @@ def test_fix_with_the_real_pip(set_lists, monkeypatch, pip_environment): # noqa
|
||||
monkeypatch.setattr(MANAGER_UTIL, 'pip_map', None)
|
||||
|
||||
def fix():
|
||||
code = MANAGER_UTIL.reinstall(MANAGER_UTIL.fix_cmd(f'git+{REMOTE}'), lambda cmd: subprocess.run(cmd, capture_output=True, env=env).returncode)
|
||||
code = MANAGER_UTIL.reinstall(MANAGER_UTIL.fix_cmd([f'git+{REMOTE}']), lambda cmd: subprocess.run(cmd, capture_output=True, env=env).returncode)
|
||||
MANAGER_UTIL.clear_pip_cache()
|
||||
return code, MANAGER_UTIL.installed_from(f'git+{REMOTE}')['vcs_info']['commit_id']
|
||||
|
||||
@@ -777,7 +777,7 @@ def test_fix_with_the_real_uv(set_lists, monkeypatch, uv_environment): # noqa:
|
||||
|
||||
def fix(clean_copy=True):
|
||||
"""`clean_copy=False`: the install without the cache fails, as with a temporary folder that is full."""
|
||||
code = MANAGER_UTIL.reinstall(MANAGER_UTIL.fix_cmd(f'git+{REMOTE}'), lambda cmd: (
|
||||
code = MANAGER_UTIL.reinstall(MANAGER_UTIL.fix_cmd([f'git+{REMOTE}']), lambda cmd: (
|
||||
subprocess.run(cmd, capture_output=True).returncode if clean_copy or '--no-cache' not in cmd else 1))
|
||||
MANAGER_UTIL.clear_pip_cache()
|
||||
return code, MANAGER_UTIL.installed_from(f'git+{REMOTE}')['vcs_info']['commit_id']
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import ast
|
||||
import importlib.util
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
@@ -417,6 +418,27 @@ def test_reserved_switch_that_fails_leaves_no_archive(switch, tmp_path):
|
||||
assert archives(custom_nodes) == []
|
||||
|
||||
|
||||
def test_reserved_switch_whose_download_fails_leaves_no_archive(monkeypatch, tmp_path):
|
||||
custom_nodes = tmp_path / 'custom_nodes'
|
||||
old, new = old_version(custom_nodes, 'fixture@1_0_0'), custom_nodes / 'fixture@2_0_0'
|
||||
|
||||
def download(url, directory, name):
|
||||
for part in (name, name + '.aria2'):
|
||||
(custom_nodes / part).write_text('a part of the archive')
|
||||
raise Exception('the download failed')
|
||||
|
||||
spec = importlib.util.spec_from_file_location('_manager_downloader_under_test', GLOB_DIR / 'manager_downloader.py')
|
||||
downloader = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(downloader)
|
||||
downloader.download_url = download
|
||||
switch = startup_functions(lambda name, module: monkeypatch.setitem(sys.modules, name, module), manager_downloader=downloader)['execute_lazy_cnr_switch']
|
||||
|
||||
with pytest.raises(Exception, match='the download failed'):
|
||||
switch('fixture', 'https://example.invalid/fixture.zip', str(old), str(new), False, str(custom_nodes), 'NodeVersionStatusActive')
|
||||
|
||||
assert sorted(os.listdir(custom_nodes)) == ['fixture@1_0_0', 'removed.py']
|
||||
|
||||
|
||||
def test_switch_at_once_that_fails_leaves_no_archive(tmp_path):
|
||||
custom_nodes = tmp_path / 'custom_nodes'
|
||||
(old_version(custom_nodes, 'fixture') / '.tracking').unlink()
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import pytest
|
||||
|
||||
from test_invalid_installation import run
|
||||
|
||||
CM_CLI = '''
|
||||
import io, typer, rich.console
|
||||
from typing_extensions import Annotated
|
||||
|
||||
async def get_data_by_mode(mode, filename, channel_url=None):
|
||||
if filename == 'extension-node-map.json':
|
||||
return {FOO_URL: [['FooNode'], {}], BAR_URL: [['BarNode'], {}]}
|
||||
return {'custom_nodes': [dict(item) for item in NODE_LIST]}
|
||||
|
||||
async def auto_save_snapshot():
|
||||
pass
|
||||
|
||||
core.get_data_by_mode = get_data_by_mode
|
||||
out = io.StringIO()
|
||||
cm_cli = {'asyncio': asyncio, 'os': os, 'json': json, 'core': core, 'unified_manager': manager, 'typer': typer,
|
||||
'Annotated': Annotated, 'app': SimpleNamespace(command=lambda *args, **kwargs: lambda f: f),
|
||||
'print': rich.console.Console(file=out, width=1000, color_system=None).print,
|
||||
'auto_save_snapshot': auto_save_snapshot, 'comfy_path': tmp,
|
||||
'manager_util': SimpleNamespace(get_installed_packages=dict,
|
||||
PIPFixer=lambda *args: SimpleNamespace(fix_broken=lambda: None)),
|
||||
'cmd_ctx': SimpleNamespace(set_user_directory=lambda path: None, set_channel_mode=lambda channel, mode: reload(),
|
||||
mode='cache', channel='default')}
|
||||
for name in ('enable_node', 'deps_in_workflow', 'install_deps'):
|
||||
cm_cli_function(name, cm_cli)
|
||||
workflow = pathlib.Path(tmp) / 'workflow.json'
|
||||
workflow.write_text(json.dumps({'nodes': [{'id': 1, 'type': 'FooNode'}, {'id': 2, 'type': 'BarNode'}]}))
|
||||
deps = pathlib.Path(tmp) / 'deps.json'
|
||||
'''
|
||||
|
||||
FOO_URL = 'https://github.com/example/ComfyUI-Foo'
|
||||
BAR_URL = 'https://github.com/example/ComfyUI-Bar'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('folder, kwargs, foo, bar', [
|
||||
('comfyui-foo', "'comfyui-foo', tracking=True", 'installed', 'not-installed'),
|
||||
('.disabled/comfyui-foo@1_0_1', "'comfyui-foo', tracking=True", 'disabled', 'not-installed'),
|
||||
('.disabled/comfyui-foo@nightly', 'git_url=FOO_URL', 'disabled', 'not-installed'),
|
||||
('ComfyUI-Bar', 'git_url=BAR_URL', 'not-installed', 'installed'),
|
||||
('.disabled/ComfyUI-Bar', 'git_url=BAR_URL', 'not-installed', 'disabled'),
|
||||
('ComfyUI-Bar.disabled', 'git_url=BAR_URL', 'not-installed', 'disabled'),
|
||||
], ids=['registry', 'registry-disabled', 'nightly-disabled', 'git', 'git-disabled', 'git-disabled-old-style'])
|
||||
def test_deps_in_workflow_writes_the_state_of_each_nodepack(folder, kwargs, foo, bar):
|
||||
data = run(CM_CLI + f'''
|
||||
pack({folder!r}, {kwargs})
|
||||
cm_cli['deps_in_workflow'](workflow=str(workflow), output=str(deps), channel=None, mode=None, user_directory=None)
|
||||
emit(json.loads(deps.read_text()))
|
||||
''')
|
||||
|
||||
assert data == {'custom_nodes': {FOO_URL: {'state': foo, 'hash': '-'}, BAR_URL: {'state': bar, 'hash': '-'}},
|
||||
'unknown_nodes': []}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('folder, kwargs, enabled', [
|
||||
('.disabled/comfyui-foo@1_0_1', "'comfyui-foo', tracking=True", 'comfyui-foo'),
|
||||
('.disabled/ComfyUI-Bar', 'git_url=BAR_URL', 'ComfyUI-Bar'),
|
||||
('ComfyUI-Bar.disabled', 'git_url=BAR_URL', 'ComfyUI-Bar'),
|
||||
], ids=['registry', 'git', 'git-old-style'])
|
||||
def test_install_deps_enables_a_disabled_nodepack(folder, kwargs, enabled):
|
||||
data = run(CM_CLI + f'''
|
||||
pack({folder!r}, {kwargs})
|
||||
url = FOO_URL if {enabled!r} == 'comfyui-foo' else BAR_URL
|
||||
deps.write_text(json.dumps({{'custom_nodes': {{url: {{'state': 'disabled', 'hash': '-'}}}}, 'unknown_nodes': []}}))
|
||||
cm_cli['install_deps'](deps=str(deps), channel=None, mode=None, user_directory=None)
|
||||
emit({{'left': listing(), 'out': out.getvalue().splitlines()}})
|
||||
''')
|
||||
|
||||
assert data['left'] == [enabled]
|
||||
assert data['out'][-1] == 'Dependency installation and activation complete.'
|
||||
@@ -0,0 +1,118 @@
|
||||
"""What `/customnode/get_node_types_in_workflows` answers about the saved workflows.
|
||||
|
||||
Each case runs the real handler of `glob/manager_server.py` on workflow files in a folder of its own.
|
||||
"""
|
||||
import ast
|
||||
import asyncio
|
||||
import builtins
|
||||
import codecs
|
||||
import gc
|
||||
import glob
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import traceback
|
||||
import warnings
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from aiohttp import web
|
||||
|
||||
from test_json_body_content_type import functions
|
||||
|
||||
SUBGRAPH, NESTED_SUBGRAPH = "5eb5cfa6-f140-40b7-0000-000000000001", "5eb5cfa6-f140-40b7-0000-000000000002"
|
||||
|
||||
|
||||
def open_as_on_windows(file, mode="r", *args, encoding=None, **options):
|
||||
if "b" not in mode and encoding is None:
|
||||
encoding = "cp1252"
|
||||
return builtins.open(file, mode, *args, encoding=encoding, **options)
|
||||
|
||||
|
||||
def node(number, kind, nodepack):
|
||||
return {"id": number, "type": kind, "properties": {"cnr_id": nodepack}}
|
||||
|
||||
|
||||
def subgraph_node(number, subgraph):
|
||||
return {"id": number, "type": subgraph, "properties": {}}
|
||||
|
||||
|
||||
def in_any_order(nodes):
|
||||
return sorted(nodes, key=lambda found: json.dumps(found, sort_keys=True))
|
||||
|
||||
|
||||
def scan(folder, workflows):
|
||||
"""The node types that are answered for each workflow file."""
|
||||
saved = folder / "default" / "workflows"
|
||||
saved.mkdir(parents=True)
|
||||
for name, workflow in workflows.items():
|
||||
(saved / name).write_bytes(workflow if isinstance(workflow, bytes) else json.dumps(workflow).encode("utf-8"))
|
||||
routes = web.RouteTableDef()
|
||||
namespace = {
|
||||
"web": web, "os": os, "json": json, "glob": glob, "logging": logging, "traceback": traceback,
|
||||
"open": open_as_on_windows, "routes": routes,
|
||||
"folder_paths": SimpleNamespace(get_user_directory=lambda: str(folder)),
|
||||
"PromptServer": SimpleNamespace(instance=SimpleNamespace(
|
||||
routes=routes, user_manager=SimpleNamespace(get_request_user_id=lambda request: "default")))}
|
||||
defined = list(functions("manager_server.py").values())
|
||||
exec(compile(ast.Module(body=defined, type_ignores=[]), "manager_server.py", "exec"), namespace)
|
||||
response = asyncio.run(namespace["get_node_types_in_workflows"](None))
|
||||
assert response.status == 200
|
||||
return {answer["workflow_file_name"]: in_any_order(answer["node_types"]) for answer in json.loads(response.text)}
|
||||
|
||||
|
||||
def test_the_nodes_inside_a_subgraph_and_inside_a_subgraph_of_it_are_answered(tmp_path):
|
||||
workflow = {
|
||||
"nodes": [node(1, "KSampler", "comfy-core"), subgraph_node(2, SUBGRAPH)],
|
||||
"definitions": {"subgraphs": [
|
||||
{"id": SUBGRAPH, "nodes": [node(10, "UnetLoaderGGUF", "comfyui-gguf"), subgraph_node(11, NESTED_SUBGRAPH)]},
|
||||
{"id": NESTED_SUBGRAPH, "nodes": [node(20, "ImageResizeKJv2", "comfyui-kjnodes")]}]}}
|
||||
|
||||
assert scan(tmp_path, {"subgraph.json": workflow}) == {"subgraph.json": in_any_order([
|
||||
{"type": "KSampler", "cnr_id": "comfy-core"},
|
||||
{"type": "UnetLoaderGGUF", "cnr_id": "comfyui-gguf"},
|
||||
{"type": "ImageResizeKJv2", "cnr_id": "comfyui-kjnodes"}])}
|
||||
|
||||
|
||||
def test_a_subgraph_that_holds_itself_is_answered_once(tmp_path):
|
||||
workflow = {
|
||||
"nodes": [subgraph_node(1, SUBGRAPH)],
|
||||
"definitions": {"subgraphs": [
|
||||
{"id": SUBGRAPH, "nodes": [node(10, "UnetLoaderGGUF", "comfyui-gguf"), subgraph_node(11, SUBGRAPH)]}]}}
|
||||
|
||||
assert scan(tmp_path, {"holds_itself.json": workflow}) == {
|
||||
"holds_itself.json": [{"type": "UnetLoaderGGUF", "cnr_id": "comfyui-gguf"}]}
|
||||
|
||||
|
||||
def test_a_workflow_with_a_node_that_is_not_an_object_is_answered_without_that_node(tmp_path):
|
||||
workflow = {"nodes": [None, node(1, "KSampler", "comfy-core"), node(2, "VHS_VideoCombine", "comfyui-videohelpersuite")]}
|
||||
|
||||
assert scan(tmp_path, {"null_node.json": workflow}) == {"null_node.json": in_any_order([
|
||||
{"type": "KSampler", "cnr_id": "comfy-core"},
|
||||
{"type": "VHS_VideoCombine", "cnr_id": "comfyui-videohelpersuite"}])}
|
||||
|
||||
|
||||
def test_a_type_or_a_cnr_id_that_is_not_text_is_left_out(tmp_path):
|
||||
workflow = {"nodes": [{"id": 1, "type": "Foo", "properties": {"cnr_id": 5}},
|
||||
{"id": 2, "type": ["x"], "properties": {"cnr_id": "comfyui-x"}}]}
|
||||
|
||||
assert scan(tmp_path, {"odd_values.json": workflow}) == {"odd_values.json": [{"type": "Foo"}]}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("byte_order_mark", [b"", codecs.BOM_UTF8])
|
||||
def test_a_workflow_is_read_as_utf8_whatever_the_default_encoding_is(tmp_path, byte_order_mark):
|
||||
workflow = {"extra": {"title": "Łukasz ✨ 中文 “quote”"}, "nodes": [node(1, "WanVideoSampler", "comfyui-wanvideowrapper")]}
|
||||
saved = byte_order_mark + json.dumps(workflow, ensure_ascii=False).encode("utf-8")
|
||||
|
||||
assert scan(tmp_path, {"non_ascii.json": saved}) == {
|
||||
"non_ascii.json": [{"type": "WanVideoSampler", "cnr_id": "comfyui-wanvideowrapper"}]}
|
||||
|
||||
|
||||
def test_no_workflow_file_is_left_for_the_garbage_collector_to_close(tmp_path):
|
||||
with warnings.catch_warnings(record=True) as caught:
|
||||
warnings.simplefilter("always", ResourceWarning)
|
||||
answered = scan(tmp_path, {"read.json": {"nodes": [node(1, "KSampler", "comfy-core")]}, "not_json.json": b"{"})
|
||||
gc.collect()
|
||||
|
||||
assert set(answered) == {"read.json"}
|
||||
assert [str(warning.message) for warning in caught if str(tmp_path) in str(warning.message)] == []
|
||||
@@ -0,0 +1,198 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from test_grid_highlight_escaping import browser # noqa: F401 -- fixture
|
||||
|
||||
JS = Path(os.environ.get("MANAGER_JS_DIR") or (Path(__file__).resolve().parent.parent / "js"))
|
||||
EXTENSION = "http://manager.test/extensions/comfyui-manager/"
|
||||
CONTENT_TYPES = {".js": "text/javascript", ".css": "text/css"}
|
||||
|
||||
REPOSITORY = "https://github.com/silveroxides/ComfyUI_SigmoidOffsetScheduler"
|
||||
TITLE = "ComfyUI Sigmoid Offset Scheduler"
|
||||
NODE = "SigmoidOffsetScheduler"
|
||||
SPELLINGS = ["ComfyUI_SigmoidOffsetScheduler", "comfyui_sigmoidoffsetscheduler"]
|
||||
SPELLING_IDS = ["registry case", "lowercase, saved earlier"]
|
||||
|
||||
SCRIPTS = {
|
||||
"api.js": """
|
||||
export const api = {
|
||||
addEventListener() {},
|
||||
getNodeDefs: async () => ({}),
|
||||
getSystemStats: async () => ({system: {comfyui_version: '0.3.60'}}),
|
||||
async fetchApi(path) {
|
||||
const answer = window.server[path.split('?')[0]];
|
||||
if(answer === undefined) return {status: 404, statusText: 'Not Found'};
|
||||
return {status: 200, json: async () => structuredClone(answer)};
|
||||
}
|
||||
};
|
||||
""",
|
||||
"app.js": """
|
||||
const dialog = document.createElement('div');
|
||||
dialog.className = 'comfy-modal';
|
||||
export const app = {
|
||||
graph: {_nodes: [], extra: {}},
|
||||
extensions: [],
|
||||
registerExtension(extension) { this.extensions.push(extension); },
|
||||
ui: {
|
||||
settings: {settingsValues: {'Comfy.ColorPalette': 'dark'}},
|
||||
dialog: {element: dialog, show(html) { dialog.innerHTML = html; document.body.append(dialog); }},
|
||||
},
|
||||
};
|
||||
""",
|
||||
"ui.js": """
|
||||
export function $el(tag, props, children) {
|
||||
if(Array.isArray(props)) [props, children] = [{}, props];
|
||||
const names = tag.split('.');
|
||||
const element = document.createElement(names.shift());
|
||||
element.classList.add(...names);
|
||||
const {parent, style, ...rest} = props ?? {};
|
||||
Object.assign(element.style, style);
|
||||
Object.assign(element, rest);
|
||||
element.append(...(children ?? []));
|
||||
parent?.append(element);
|
||||
return element;
|
||||
}
|
||||
export class ComfyDialog {}
|
||||
""",
|
||||
}
|
||||
|
||||
|
||||
def pack(key, title, state, repository):
|
||||
return {"id": key, "title": title, "author": "author", "description": "nodes", "repository": repository,
|
||||
"reference": repository, "files": [repository], "install_type": "cnr", "version": "1.1.1",
|
||||
"cnr_latest": "1.1.1", "state": state, "stars": 10, "last_update": "2025-01-01 00:00:00"}
|
||||
|
||||
|
||||
def node_packs(state):
|
||||
return {
|
||||
"ComfyUI_SigmoidOffsetScheduler": pack("ComfyUI_SigmoidOffsetScheduler", TITLE, state, REPOSITORY),
|
||||
"comfyui-other-pack": pack("comfyui-other-pack", "Other Pack", "not-installed",
|
||||
"https://github.com/someone/comfyui-other-pack"),
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def page(browser): # noqa: F811
|
||||
page = browser.new_page(viewport={"width": 1600, "height": 900})
|
||||
|
||||
def route(request):
|
||||
url = request.request.url
|
||||
name = url.rsplit("/", 1)[-1]
|
||||
if url == "http://manager.test/":
|
||||
request.fulfill(body="<body></body>", content_type="text/html")
|
||||
elif url.startswith(EXTENSION) and (JS / name).is_file():
|
||||
request.fulfill(path=str(JS / name), content_type=CONTENT_TYPES.get((JS / name).suffix, "text/plain"))
|
||||
elif url == "http://manager.test/scripts/" + name and name in SCRIPTS:
|
||||
request.fulfill(body=SCRIPTS[name], content_type="text/javascript")
|
||||
else:
|
||||
request.abort()
|
||||
|
||||
page.route("**/*", route)
|
||||
page.errors = []
|
||||
page.on("pageerror", lambda error: page.errors.append(str(error)))
|
||||
page.goto("http://manager.test/")
|
||||
yield page
|
||||
page.close()
|
||||
|
||||
|
||||
def open_list(page, mode, packs, nodes, registered, mapped=True):
|
||||
server = {
|
||||
"/customnode/getlist": {"channel": "default", "node_packs": packs},
|
||||
"/customnode/getmappings": {REPOSITORY: [[NODE], {"title_aux": TITLE}]} if mapped else {},
|
||||
}
|
||||
page.evaluate("""async ({module, mode, server, nodes, registered}) => {
|
||||
window.server = server;
|
||||
window.LiteGraph = {registered_node_types: Object.fromEntries(registered.map(type => [type, {type}]))};
|
||||
const {app} = await import('/scripts/app.js');
|
||||
app.graph._nodes = nodes;
|
||||
const {setManagerInstance} = await import(new URL('common.js', module).href);
|
||||
setManagerInstance({datasrc_combo: {value: 'cache'}});
|
||||
const {CustomNodesManager} = await import(module);
|
||||
window.manager = new CustomNodesManager(app, null);
|
||||
manager.show(CustomNodesManager.ShowMode[mode]);
|
||||
}""", {"module": EXTENSION + "custom-nodes-manager.js", "mode": mode, "server": server, "nodes": nodes,
|
||||
"registered": registered})
|
||||
page.wait_for_function("/^[\\d,]+ custom nodes$/.test(document.querySelector('.cn-manager-status').textContent)")
|
||||
return page.evaluate("""() => ({
|
||||
rows: [...document.querySelectorAll('.cn-manager-grid .tg-body .cn-pack-name')].map(cell => cell.innerText.trim()),
|
||||
status: document.querySelector('.cn-manager-status').textContent,
|
||||
message: document.querySelector('.comfy-modal')?.innerText ?? '',
|
||||
})""")
|
||||
|
||||
|
||||
def workflow_node(cnr_id):
|
||||
return {"type": NODE, "properties": {"cnr_id": cnr_id, "ver": "1.1.1"}}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cnr_id", SPELLINGS, ids=SPELLING_IDS)
|
||||
def test_in_workflow_lists_the_installed_nodepack_of_a_node(page, cnr_id):
|
||||
shown = open_list(page, "IN_WORKFLOW", node_packs("enabled"), [workflow_node(cnr_id)], [NODE])
|
||||
|
||||
assert shown == {"rows": [TITLE], "status": "1 custom nodes", "message": ""}
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("mapped", [True, False], ids=["node in the node map", "node not in the node map"])
|
||||
@pytest.mark.parametrize("cnr_id", SPELLINGS, ids=SPELLING_IDS)
|
||||
def test_missing_lists_the_nodepack_of_an_unknown_node_without_saying_it_is_not_in_the_registry(page, cnr_id, mapped):
|
||||
shown = open_list(page, "MISSING", node_packs("not-installed"), [workflow_node(cnr_id)], [], mapped)
|
||||
|
||||
assert shown == {"rows": [TITLE], "status": "1 custom nodes", "message": ""}
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cnr_id", ["comfyui-nowhere", 123], ids=["text", "number"])
|
||||
def test_missing_says_which_id_of_the_workflow_no_nodepack_has(page, cnr_id):
|
||||
node = {"type": "NowhereNode", "properties": {"cnr_id": cnr_id, "ver": "1.0.0"}}
|
||||
|
||||
shown = open_list(page, "MISSING", node_packs("not-installed"), [node], [])
|
||||
|
||||
assert shown["rows"] == []
|
||||
assert "Failed to find the following ComfyRegistry list." in shown["message"]
|
||||
assert str(cnr_id) in shown["message"]
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
def with_core_lookalike(packs, state):
|
||||
packs["Comfy-Core"] = pack("Comfy-Core", "Core Lookalike", state, "https://github.com/someone/Comfy-Core")
|
||||
return packs
|
||||
|
||||
|
||||
def test_missing_does_not_offer_a_nodepack_named_as_the_core_for_a_built_in_node(page):
|
||||
node = {"type": "NewBuiltInNode", "properties": {"cnr_id": "comfy-core", "ver": "0.3.60"}}
|
||||
|
||||
shown = open_list(page, "MISSING", with_core_lookalike(node_packs("not-installed"), "not-installed"), [node], [])
|
||||
|
||||
assert shown["rows"] == []
|
||||
assert "comfy-core" in shown["message"]
|
||||
assert page.errors == []
|
||||
|
||||
|
||||
def new_node_properties(page, folder, cnr_id):
|
||||
installed = {folder: {"ver": "1.1.1", "cnr_id": cnr_id, "aux_id": None, "enabled": True}}
|
||||
return page.evaluate("""async ({module, server, python_module}) => {
|
||||
window.server = server;
|
||||
const {app} = await import('/scripts/app.js');
|
||||
await import(module);
|
||||
const extension = app.extensions.find(extension => extension.nodeCreated);
|
||||
await extension.init();
|
||||
class Node {}
|
||||
Node.nodeData = {python_module};
|
||||
const node = new Node();
|
||||
extension.nodeCreated(node);
|
||||
return node.properties;
|
||||
}""", {"module": EXTENSION + "workflow-metadata.js", "server": {"/customnode/installed": installed},
|
||||
"python_module": "custom_nodes." + folder})
|
||||
|
||||
|
||||
def test_a_new_node_takes_the_id_of_its_nodepack_as_the_installed_list_spells_it(page):
|
||||
properties = new_node_properties(page, "ComfyUI_SigmoidOffsetScheduler", "ComfyUI_SigmoidOffsetScheduler")
|
||||
|
||||
assert properties == {"cnr_id": "ComfyUI_SigmoidOffsetScheduler", "ver": "1.1.1"}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cnr_id", ["comfy-core", "Comfy-Core"])
|
||||
def test_a_new_node_of_a_nodepack_that_names_itself_as_the_core_takes_no_id(page, cnr_id):
|
||||
assert new_node_properties(page, "core-lookalike", cnr_id) == {}
|
||||
Reference in New Issue
Block a user