Skip to content

Add keyboard interrupts for subgraph.find_subgraph#275

Merged
boothby merged 2 commits intodwavesystems:mainfrom
boothby:glasgow-cancel
Oct 29, 2025
Merged

Add keyboard interrupts for subgraph.find_subgraph#275
boothby merged 2 commits intodwavesystems:mainfrom
boothby:glasgow-cancel

Conversation

@boothby
Copy link
Copy Markdown
Collaborator

@boothby boothby commented Sep 16, 2025

I've finally figured out a (hopefully) good-enough means to halt on ctrl-c within find_subgraph. Sadly, testing this capability in CI has proven flaky in the past (as seen in tests/test_lib.py:841 ). I'll try and scrounge some folks on windows and osx to do some tests.

@boothby
Copy link
Copy Markdown
Collaborator Author

boothby commented Sep 16, 2025

Test procedure:

  1. run the following code, once in a repl (python, ipython, or your favorite IDE) and once as a script (from the commandline: python test.py where test.py has the code below)
from minorminer import subgraph, find_embedding
from time import sleep
import dwave_networkx as dnx
source = dnx.chimera_graph(8)
target = dnx.chimera_graph(15, coordinates=True)
target.remove_node((7,7,0,0))

emb = subgraph.find_subgraph(source, target)
print("caught an interrupt in find_subgraph")

emb = find_embedding(source, target, chainlength_patience = 1000000, interactive=True, tries=1)
print("caught an interrupt in find_embedding")

emb = subgraph.find_subgraph(source, target)
print("caught an interrupt in find_subgraph")

try:
    sleep(1000)
except KeyboardInterrupt:
    print("caught an interrupt in sleep")
  1. hit ctrl-c four times, waiting until you see some output before pressing it again
  2. the output should look something like
^Ccaught an interrupt in find_subgraph
^Ccaught an interrupt in find_embedding
^Ccaught an interrupt in find_subgraph
^Ccaught an interrupt in sleep

@boothby boothby merged commit 80d6964 into dwavesystems:main Oct 29, 2025
34 checks passed
@thisac thisac mentioned this pull request Oct 29, 2025
mahdiehmalekian pushed a commit to mahdiehmalekian/minorminer that referenced this pull request Nov 14, 2025
* added ability to interrupt find_subgraph via ctrl-c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant