spkenv / spk

A Package Manager for high velocity software environments, built on spfs.
https://spkenv.dev
Apache License 2.0
40 stars 6 forks source link

Adds basic iteractive menu for inspecting current state of solver when stepping #1039

Closed dcookspi closed 3 months ago

dcookspi commented 5 months ago

This adds a very basic interactive menu for inspecting current state the solver has reached, when using --step/stop-on-block or --step-on-decision.

It adds methods for showing the current state's resolved packages, unresolved requests, variable requests, options, and showing all of the those when stepping or stopping. I imagine more could be added later, e.g. we have a request to launch an environment of the currently resolved packages. I have a plan to add showing graphs of the current dependencies to this menu (PR: TBD).

The menu doesn't use any other crates and appears among the normal solver output, but doesn't use the output setting the solver has. This was partly for initial implementation ease, partly to keep the existing output intact, and partly because its interactive.

Questions:

Gotchas uncovered:

Example output (updated with single line menu):

> spk explain python-pytest --step-on-decision --solver-to-run cli
> RESOLVE python-pytest/8.1.1/OK7CBJKZ  (requested by command line)
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> ?
Pausing after decision. Enter a letter for an action:
 ? - Print help (these details)
 r - Show resolved packages
 u - Show unresolved requests
 v - Show var requests
 o - Show options
 s, a - Show state [all of the above]
 c - Run solver to completion, removes step/stop
 Ctrl-c - Interrupt this program
 any other - Continue solving
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> r
 INFO Nothing Installed
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> u
 INFO Unresolved Requests:
  python-pytest:all/*
Number of Unresolved Requests: 1
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]>  (just hit enter)
>> RESOLVE python/3.9.7+r.1/QOEDONJ7  (requested by python-pytest/8.1.1/OK7CBJKZ)
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> r
 INFO Installed Packages:
  origin/python-pytest:{build,run}/=8.1.1/OK7CBJKZ (required by command line) 
 Number of Packages: 1
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> u
 INFO Unresolved Requests:
  python-packaging:all/*
  python-pluggy:all/<2.0.0,>=1.4.0
  python-iniconfig:all/*
  python-tomli:all/>=1.0.0
  python-exceptiongroup:all/>=1.0.0-rc.8
  python:all/3.9.0
Number of Unresolved Requests: 6
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> v
 INFO Var Requests:
  arch: x86_64
  centos: 7
  distro: centos
  os: linux
  python.abi: cp39
Number of Var Requests: 5
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> o
 INFO Options:
  {arch=x86_64
  centos=7
  distro=centos
  os=linux
  python-pytest=~8.1.1
  python-pytest.arch=x86_64
  python-pytest.centos=7
  python-pytest.distro=centos
  python-pytest.os=linux
  python-pytest.python=~3.9.7
  python-pytest.python-pip=~22.0.4
  python.abi=cp39}
Number of Options: 12
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]> s
 INFO Installed Packages:
  origin/python-pytest:{build,run}/=8.1.1/OK7CBJKZ (required by command line) 
 Number of Packages: 1
 INFO Unresolved Requests:
  python-packaging:all/*
  python-pluggy:all/<2.0.0,>=1.4.0
  python-iniconfig:all/*
  python-tomli:all/>=1.0.0
  python-exceptiongroup:all/>=1.0.0-rc.8
  python:all/3.9.0
Number of Unresolved Requests: 6
 INFO Var Requests:
  arch: x86_64
  centos: 7
  distro: centos
  os: linux
  python.abi: cp39
Number of Var Requests: 5
 INFO Options:
  {arch=x86_64
  centos=7
  distro=centos
  os=linux
  python-pytest=~8.1.1
  python-pytest.arch=x86_64
  python-pytest.centos=7
  python-pytest.distro=centos
  python-pytest.os=linux
  python-pytest.python=~3.9.7
  python-pytest.python-pip=~22.0.4
  python.abi=cp39}
Number of Options: 12
Pausing after decision. Select one of [r,u,v,o,s,a,c,?,C-c]>  ^C
Solve is taking too long, > 30 secs. Increasing verbosity level to 2
Solver interrupted by user ...
...
dcookspi commented 5 months ago

I can't seen to add 2 reviewers to this PR.

dcookspi commented 5 months ago

From today's meeting:

Todo:

dcookspi commented 5 months ago

Mentioning @rydrman and @jrray for visibility, because I can't seem to add two reviewers. I've compressed the menu to a single line, adding ? to show the details, c to continue instead of stepping, and put Ctrl-C on the list to make it clear that you can still interrupt the solver here.

I made some TODO notes for things that could be done in future, but I'm not planning on doing any of them in this PR. Let me know if you'd rather I make tickets for them.