Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Aug 8, 2024

Conversation

dcookspi
Copy link
Collaborator

@dcookspi dcookspi commented Jun 8, 2024

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:

  • Should it use the solver's output setting?
  • Should it use a menu crate, if so do we have a preference? I tryed out console_menu but didn't like it clearing the screen and jumping back and forth between the existing solver output.

Gotchas uncovered:

  • Waiting long enough on the menu (individually or in total) will trip the solver's verbosity timeout and it will increase the verbosity between steps
  • Waiting taking too long on straight-forward solves may mean the background solver (spk runs 2 solvers in parallel by default) fiinishes with a solution so your next "step" actually skips to the end with the solution. The can be disconcerting when you thought you were stepping through resolve one, then resolve two, and it jumps to "all done" even though you know you had 50+ packages still to resolve.

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 dcookspi self-assigned this Jun 8, 2024
@dcookspi dcookspi requested review from jrray and rydrman and removed request for jrray June 8, 2024 01:04
@dcookspi dcookspi changed the title Adds basic iteractive menu for inspecting current state of solver when stepping Draft: Adds basic iteractive menu for inspecting current state of solver when stepping Jun 8, 2024
@dcookspi dcookspi added SPI AOI Area of interest for SPI SPI-0.41 enhancement New feature or request labels Jun 8, 2024
Base automatically changed from add-step-on-decision to main June 10, 2024 19:21
@dcookspi dcookspi force-pushed the add-show-current-state-when-stepping branch from b2d3211 to e4e706b Compare June 10, 2024 19:42
@dcookspi dcookspi changed the title Draft: Adds basic iteractive menu for inspecting current state of solver when stepping Adds basic iteractive menu for inspecting current state of solver when stepping Jun 10, 2024
@dcookspi dcookspi requested review from jrray and removed request for rydrman June 10, 2024 19:57
@dcookspi
Copy link
Collaborator Author

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

@dcookspi dcookspi added agenda item Items to be brought up at the next dev meeting and removed agenda item Items to be brought up at the next dev meeting labels Jun 11, 2024
@dcookspi
Copy link
Collaborator Author

dcookspi commented Jun 12, 2024

From today's meeting:

  • Broadly liked
  • Could turn into more (grphs, solver breakpoints, continue, pause when solving this request, conditionals, saving checkpoints, rewinding solve in time, selecting choice at next point, launching an env from the current state) but doesn't need to now
  • But should use less vertical space (sse git interactive and ? output being like this for an example)

Todo:

  • Reduce the amount of vertical space the menu takes up (one line it with ? to show full)

@dcookspi
Copy link
Collaborator Author

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.

@dcookspi dcookspi force-pushed the add-show-current-state-when-stepping branch from e4295f8 to f88b7f1 Compare August 6, 2024 17:32
@dcookspi dcookspi requested a review from rydrman August 7, 2024 16:46
crates/spk-solve/src/io.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@jrray jrray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but have some suggested fixups.

crates/spk-solve/src/io.rs Outdated Show resolved Hide resolved
@dcookspi dcookspi force-pushed the add-show-current-state-when-stepping branch from 073dacf to 3645025 Compare August 8, 2024 00:31
…ed on a block or decision.

Adds showing resolved packages, unresolved requests, variable
requests, options, and showing all of the those when stepping or
stopping during a solve.

Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
@dcookspi dcookspi force-pushed the add-show-current-state-when-stepping branch from 3645025 to 710d372 Compare August 8, 2024 00:42
@dcookspi dcookspi merged commit 74b008b into main Aug 8, 2024
6 checks passed
@dcookspi dcookspi deleted the add-show-current-state-when-stepping branch August 8, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SPI AOI Area of interest for SPI SPI-0.41
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants