Skip to content

Commit

Permalink
Support no prompting
Browse files Browse the repository at this point in the history
  • Loading branch information
yoland68 committed May 14, 2024
1 parent d2d1bf8 commit d2288c4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
12 changes: 9 additions & 3 deletions comfy_cli/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import uuid
import webbrowser
from typing import Optional
from comfy_cli.constants import GPU_OPTION

import questionary
import typer
Expand All @@ -16,13 +15,14 @@
from comfy_cli.command import custom_nodes
from comfy_cli.command import install as install_inner
from comfy_cli.command.models import models as models_command
from comfy_cli.update import check_for_updates
from comfy_cli.config_manager import ConfigManager
from comfy_cli.constants import GPU_OPTION
from comfy_cli.env_checker import EnvChecker, check_comfy_server_running
from comfy_cli.update import check_for_updates
from comfy_cli.workspace_manager import (
WorkspaceManager,
check_comfy_repo,
WorkspaceType,
check_comfy_repo,
)

logging.setup_logging()
Expand Down Expand Up @@ -246,6 +246,10 @@ def install(
"[bold yellow]Feel free to follow this thread to manually install:\nhttps://github.com/comfyanonymous/ComfyUI/discussions/476[/bold yellow]"
)

if gpu is None:
print("[bold red]No GPU selected. Exiting...[/bold red]")
raise typer.Exit(code=1)

install_inner.execute(
url,
manager_url,
Expand Down Expand Up @@ -522,6 +526,7 @@ def feedback():
general_satisfaction_score = ui.prompt_select(
question="On a scale of 1 to 5, how satisfied are you with the Comfy CLI tool? (1 being very dissatisfied and 5 being very satisfied)",
choices=["1", "2", "3", "4", "5"],
force_prompting=True,
)
tracking.track_event(
"feedback_general_satisfaction", {"score": general_satisfaction_score}
Expand All @@ -531,6 +536,7 @@ def feedback():
usability_satisfaction_score = ui.prompt_select(
question="On a scale of 1 to 5, how satisfied are you with the usability and user experience of the Comfy CLI tool? (1 being very dissatisfied and 5 being very satisfied)",
choices=["1", "2", "3", "4", "5"],
force_prompting=True,
)
tracking.track_event(
"feedback_usability_satisfaction", {"score": usability_satisfaction_score}
Expand Down
16 changes: 13 additions & 3 deletions comfy_cli/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def show_progress(iterable, total, description="Downloading..."):
progress.update(task, advance=len(chunk))


def prompt_select(question: str, choices: list) -> str:
def prompt_select(question: str, choices: list, force_prompting: bool = False) -> str:
"""
Asks a single select question using questionary and returns the selected response.
Expand All @@ -44,10 +44,14 @@ def prompt_select(question: str, choices: list) -> str:
Returns:
str: The selected choice from the user.
"""
if workspace_manager.no_prompting and not force_prompting:
return None
return questionary.select(question, choices=choices).ask()


def prompt_select_enum(question: str, choices: list) -> str:
def prompt_select_enum(
question: str, choices: list, force_prompting: bool = False
) -> str:
"""
Asks a single select question using questionary and returns the selected response.
Expand All @@ -58,6 +62,8 @@ def prompt_select_enum(question: str, choices: list) -> str:
Returns:
str: The selected choice from the user.
"""
if workspace_manager.no_prompting and not force_prompting:
return None
choice_map = {choice.value: choice for choice in choices}
display_choices = list(choice_map.keys())

Expand All @@ -66,7 +72,9 @@ def prompt_select_enum(question: str, choices: list) -> str:
return choice_map[selected]


def prompt_input(question: str, default: str = "") -> str:
def prompt_input(
question: str, default: str = None, force_prompting: bool = False
) -> str:
"""
Asks the user for an input using questionary.
Expand All @@ -80,6 +88,8 @@ def prompt_input(question: str, default: str = "") -> str:
Raises:
KeyboardInterrupt: If the user interrupts the input.
"""
if workspace_manager.no_prompting and not force_prompting:
return default
return questionary.text(question, default=default).ask()


Expand Down

0 comments on commit d2288c4

Please sign in to comment.