Skip to content

Commit

Permalink
fixup user input for conflict resolution; fixup test-uv paths
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Aug 9, 2024
1 parent c92fc85 commit 699505e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ share/python-wheels/
*.spec

# temporary files created by tests
tests/temp
tests/temp/

venv/

Expand Down
27 changes: 26 additions & 1 deletion comfy_cli/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,33 @@ def show_progress(iterable, total, description="Downloading..."):

ChoiceType = Union[str, Choice, Dict[str, Any]]

def prompt_autocomplete(
question: str,
choices: List[ChoiceType],
default: ChoiceType = "",
force_prompting: bool = False
) -> Optional[ChoiceType]:
"""
Asks a single select question using questionary and returns the selected response.
Args:
question (str): The question to display to the user.
choices (List[ChoiceType]): A list of choices the user can autocomplete from.
default (ChoiceType): Default choice.
force_prompting (bool): Whether to force prompting even if skip_prompting is set.
Returns:
Optional[ChoiceType]: The selected choice from the user, or None if skipping prompts.
"""
if workspace_manager.skip_prompting and not force_prompting:
return None
return questionary.autocomplete(question, choices=choices, default=default).ask()


def prompt_select(
question: str,
choices: List[ChoiceType],
default: ChoiceType = "",
force_prompting: bool = False
) -> Optional[ChoiceType]:
"""
Expand All @@ -47,14 +71,15 @@ def prompt_select(
Args:
question (str): The question to display to the user.
choices (List[ChoiceType]): A list of choices for the user to select from.
default (ChoiceType): Default choice.
force_prompting (bool): Whether to force prompting even if skip_prompting is set.
Returns:
Optional[ChoiceType]: The selected choice from the user, or None if skipping prompts.
"""
if workspace_manager.skip_prompting and not force_prompting:
return None
return questionary.select(question, choices=choices).ask()
return questionary.select(question, choices=choices, default=default).ask()


E = TypeVar('E', bound=Enum)
Expand Down
8 changes: 6 additions & 2 deletions comfy_cli/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ def Compile(
name, reqs = parseUvCompileError(e.stderr)
vers = [req.split(name)[1].strip(",") for req in reqs]

ver = prompt_select("Please pick one of the conflicting version specs (or pick latest):", vers + ["latest"])
ver = prompt_select(
"Please pick one of the conflicting version specs (or pick latest):",
choices=vers + ["latest"],
default=vers[0],
)

if ver == "latest":
req = name
Expand Down Expand Up @@ -316,7 +320,7 @@ def compileCorePlusExt(self):
with open(self.override, "a") as f:
f.write(e.req + "\n")
else:
raise ValueError
raise AttributeError

def installCorePlusExt(self):
DependencyCompiler.Install(
Expand Down
2 changes: 1 addition & 1 deletion tests/uv/mock_requirements/y_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy<=1.5.0
sympy>=1.13.1
sympy>=1.13.0
tqdm==2.0.0
6 changes: 4 additions & 2 deletions tests/uv/test_uv.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from pathlib import Path
import shutil

from comfy_cli.uv import DependencyCompiler

hereDir = Path(__file__).parent.resolve()
testsDir = hereDir.parent.resolve()
temp = testsDir / "temp"
temp.mkdir(exist_ok=True)
temp = testsDir / "temp" / "test_uv"
shutil.rmtree(temp, ignore_errors=True)
temp.mkdir(exist_ok=True, parents=True)

def test_compile():
depComp = DependencyCompiler(
Expand Down

0 comments on commit 699505e

Please sign in to comment.