Skip to content

Commit

Permalink
improved feedback/UX of manual dependency conflict resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
telamonian committed Aug 9, 2024
1 parent 2efb3a7 commit c92fc85
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions comfy_cli/uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def _reqReClosure(name: str) -> re.Pattern[str]:
return re.compile(rf"({name}\S+)")

def parseUvCompileError(err: str) -> list[str]:
"""takes in stderr from a run of `uv pip compile` that failed due to requirement conflict and spits out
a tuple of (reqiurement_name, requirement_spec_in_conflict_a, requirement_spec_in_conflict_b). Will probably
fail for stderr produced from other kinds of errors
"""
if reqNameMatch := _reqNameRe.search(err):
reqName = reqNameMatch[1]
else:
Expand Down Expand Up @@ -130,27 +134,27 @@ def Compile(
try:
return _run(cmd, cwd)
except subprocess.CalledProcessError as e:
print(e.__class__.__name__)
print(e)
print(f"STDOUT:\n{e.stdout}")
print(f"STDERR:\n{e.stderr}")

if resolve_strategy == "ask":
name, reqs = parseUvCompileError(e.stderr)
vers = [req.split(name)[1].strip(",") for req in reqs]

ver = prompt_select("Please manually select one of the conflicting requirements (or latest):", vers + ["latest"])
ver = prompt_select("Please pick one of the conflicting version specs (or pick latest):", vers + ["latest"])

if ver == "latest":
req = name
else:
req = name + ver

e.req = req
raise e
elif resolve_strategy is not None:
# no other resolve_strategy options implemented yet
raise ValueError

print(e.__class__.__name__)
print(e)
print(f"STDOUT:\n{e.stdout}")
print(f"STDERR:\n{e.stderr}")

raise e

@staticmethod
Expand Down

0 comments on commit c92fc85

Please sign in to comment.