Repository navigation
Conversation
Expose POST /download_model so browser clients fetch models onto the host instead of the user's laptop. Enabled by default via Comfy.ModelDownloadEnabled.
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
server.py (1)
216-218: ⚡ Quick winConsider logging exceptions when reading settings.
The broad
except Exception:silently swallows all errors (JSON decode errors, permission errors, etc.), which could make it difficult for users to diagnose configuration problems. Consider adding a warning log to aid debugging while maintaining the safe default behavior.📋 Suggested improvement
except Exception: - pass + logging.warning(f"Failed to read model download setting from {settings_path}, defaulting to enabled", exc_info=True)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server.py` around lines 216 - 218, The bare `except Exception:` block in the settings reading code silently ignores all errors including JSON decode errors and permission errors without any logging, making it difficult to diagnose configuration issues. Replace the `pass` statement with a warning log call that captures and records the exception details before returning True, so users can see what configuration problems occurred while still maintaining the safe default behavior.app/model_manager.py (1)
9-9: 💤 Low valueUnused import:
tqdmis imported but never used.The
tqdmlibrary is imported but not utilized anywhere in this file. This may be a leftover from development or intended for future progress bar functionality that was removed.🧹 Proposed fix
-from tqdm.auto import tqdm🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/model_manager.py` at line 9, Remove the unused import statement `from tqdm.auto import tqdm` at line 9 in app/model_manager.py since tqdm is never used anywhere in the file and is just cluttering the imports.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server.py`:
- Line 213: The open() call that reads the settings file is missing an explicit
UTF-8 encoding parameter. Since JSON files should use UTF-8 encoding per RFC
8259 and Python's default encoding is platform-dependent, add the
encoding='utf-8' parameter to the open() function call to ensure consistent
UTF-8 decoding across all platforms and prevent issues with non-ASCII characters
in the settings file.
---
Nitpick comments:
In `@app/model_manager.py`:
- Line 9: Remove the unused import statement `from tqdm.auto import tqdm` at
line 9 in app/model_manager.py since tqdm is never used anywhere in the file and
is just cluttering the imports.
In `@server.py`:
- Around line 216-218: The bare `except Exception:` block in the settings
reading code silently ignores all errors including JSON decode errors and
permission errors without any logging, making it difficult to diagnose
configuration issues. Replace the `pass` statement with a warning log call that
captures and records the exception details before returning True, so users can
see what configuration problems occurred while still maintaining the safe
default behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cab4b1b9-ecee-4012-a8f2-75d3fd86ace8
📒 Files selected for processing (2)
app/model_manager.pyserver.py
| settings_path = os.path.join(folder_paths.get_user_directory(), "default", "comfy.settings.json") | ||
| try: | ||
| if os.path.isfile(settings_path): | ||
| with open(settings_path) as f: |
There was a problem hiding this comment.
Specify UTF-8 encoding when opening JSON file.
The file is opened without an explicit encoding parameter. JSON files should use UTF-8 encoding per RFC 8259, and Python's default encoding is platform-dependent (e.g., cp1252 on Windows). This could cause decoding issues if the settings file contains non-ASCII characters.
📝 Proposed fix
- with open(settings_path) as f:
+ with open(settings_path, encoding='utf-8') as f:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| with open(settings_path) as f: | |
| with open(settings_path, encoding='utf-8') as f: |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@server.py` at line 213, The open() call that reads the settings file is
missing an explicit UTF-8 encoding parameter. Since JSON files should use UTF-8
encoding per RFC 8259 and Python's default encoding is platform-dependent, add
the encoding='utf-8' parameter to the open() function call to ensure consistent
UTF-8 decoding across all platforms and prevent issues with non-ASCII characters
in the settings file.
|
Thank you for your contribution @djmango but we have an internal initiative to manage this. The topic is more complex than it looks because we also need to ensure compatibility with our cloud and desktop applications. Thanks again. |
Summary
POST /download_modelso the ComfyUI host fetches missing models (HuggingFace, Civitai, GitHub) into the correctmodels/<folder>/path instead of the client browser downloading them locally.GET /download_model/progresswith byte-level progress for long downloads.Comfy.ModelDownloadEnabled(defaults to enabled).Fixes #13282
Related: #8826 — users hitting missing checkpoint validation when the model never lands on the server (e.g. remote UI sent the download to the laptop).
Test plan
localhost).ComfyUI/models/<save_dir>/on the server and not in the client Downloads folder./download_model/progressreports increasing bytes for multi-GB files.Companion frontend PR: Comfy-Org/ComfyUI_frontend#12844