Skip to content

Commit f96be3a

Browse files
authored
Improve error messages for Publishing nodes. (#72)
1 parent 86a2504 commit f96be3a

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

DEV_README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ This guide provides an overview of how to develop in this repository.
1010

1111
`pip install -e .`
1212

13-
3. Test script running
13+
3. Set ENVIRONMENT variable to DEV.
14+
15+
`export ENVIRONMENT=dev`
16+
17+
4. Test script running
1418

1519
`comfy --help`
1620

17-
4. Use pre commit hook
21+
5. Use pre commit hook
1822

1923
`pre-commit install`
2024

comfy_cli/command/custom_nodes/command.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -668,17 +668,20 @@ def publish(
668668

669669
# Call API to fetch node version with the token in the body
670670
typer.echo("Publishing node version...")
671-
response = registry_api.publish_node_version(config, token)
672-
673-
# Zip up all files in the current directory, respecting .gitignore files.
674-
signed_url = response.signedUrl
675-
zip_filename = "node.tar.gz"
676-
typer.echo("Creating zip file...")
677-
zip_files(zip_filename)
678-
679-
# Upload the zip file to the signed URL
680-
typer.echo("Uploading zip file...")
681-
upload_file_to_signed_url(signed_url, zip_filename)
671+
try:
672+
response = registry_api.publish_node_version(config, token)
673+
# Zip up all files in the current directory, respecting .gitignore files.
674+
signed_url = response.signedUrl
675+
zip_filename = "node.tar.gz"
676+
typer.echo("Creating zip file...")
677+
zip_files(zip_filename)
678+
679+
# Upload the zip file to the signed URL
680+
typer.echo("Uploading zip file...")
681+
upload_file_to_signed_url(signed_url, zip_filename)
682+
except Exception as e:
683+
ui.display_error_message({str(e)})
684+
return
682685

683686

684687
@app.command("init", help="Init scaffolding for custom node")

comfy_cli/registry/api.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import logging
22
import os
3-
3+
from rich.console import Console
44
import requests
55
import json
6+
from typing import Optional
7+
8+
from comfy_cli.registry.types import PyProjectConfig, PublishNodeVersionResponse
69

710
# Reduced global imports from comfy_cli.registry
811
from comfy_cli.registry.types import NodeVersion, Node
@@ -18,7 +21,7 @@ def determine_base_url(self):
1821
else:
1922
return "https://api.comfy.org"
2023

21-
def publish_node_version(self, node_config, token):
24+
def publish_node_version(self, node_config, token) -> PublishNodeVersionResponse:
2225
"""
2326
Publishes a new version of a node.
2427
@@ -30,7 +33,16 @@ def publish_node_version(self, node_config, token):
3033
PublishNodeVersionResponse: The response object from the API server.
3134
"""
3235
# Local import to prevent circular dependency
33-
from comfy_cli.registry.types import PyProjectConfig, PublishNodeVersionResponse
36+
37+
if not node_config.tool_comfy.publisher_id:
38+
raise Exception(
39+
"Publisher ID is required in pyproject.toml to publish a node version"
40+
)
41+
42+
if not node_config.project.name:
43+
raise Exception(
44+
"Project name is required in pyproject.toml to publish a node version"
45+
)
3446

3547
url = f"{self.base_url}/publishers/{node_config.tool_comfy.publisher_id}/nodes/{node_config.project.name}/versions"
3648
headers = {"Content-Type": "application/json"}

0 commit comments

Comments
 (0)