Skip to content

Commit

Permalink
Fix some minor errors
Browse files Browse the repository at this point in the history
  • Loading branch information
james03160927 committed May 11, 2024
1 parent 515bde7 commit 3ab2846
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions comfy_cli/command/custom_nodes/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def display_all_nodes():

@app.command("registry-install", help="Install a node from the registry", hidden=True)
@tracking.track_command("node")
def install(node_id: str, version: Optional[str]):
def install(node_id: str, version: Optional[str] = None):
"""
Install a node from the registry.
Args:
Expand All @@ -637,15 +637,20 @@ def install(node_id: str, version: Optional[str]):
return

# Download the node archive
local_filename = pathlib.Path(
f"./downloads/{node_id}-{node_version.version}.tar.gz"
)
custom_nodes_path = pathlib.Path(workspace_manager.workspace_path) / "custom_nodes"
node_specific_path = custom_nodes_path / node_id # Subdirectory for the node
node_specific_path.mkdir(parents=True, exist_ok=True) # Create the directory if it doesn't exist

local_filename = node_specific_path / f"{node_id}-{node_version.version}.zip"
logging.debug(f'Start downloading the node {node_id} version {node_version.version} to {local_filename}')
download_file(node_version.download_url, local_filename)

# Extract the downloaded archive to the custom_node directory on the workspace.
custom_nodes_path = pathlib.Path(workspace_manager.workspace_path) / "custom_nodes"
logging.debug(f'Start extracting the node {node_id} version {node_version.version} to {custom_nodes_path}')
extract_package_as_zip(local_filename, custom_nodes_path)
extract_package_as_zip(local_filename, node_specific_path)

# Delete the downloaded archive
logging.debug(f'Deleting the downloaded archive {local_filename}')
os.remove(local_filename)

logging.info(f'Node {node_id} version {node_version.version} has been successfully installed.')

0 comments on commit 3ab2846

Please sign in to comment.