Skip to content

Run Button for Circuit Files - Standalone and Project #2455

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ScottCarda-MS
Copy link
Contributor

Adds the VS Code Run button to circuit files so that the Q# project they are a part of can be run or debugged while looking at a circuit file. Also adds a command that the Run button can use for running just the circuit file and producing a dump machine for the circuit. This new functionality is available even if the circuit is not part of a Q# project.

@ScottCarda-MS ScottCarda-MS marked this pull request as ready for review May 23, 2025 19:22
Copy link
Member

@billti billti left a comment

Choose a reason for hiding this comment

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

Let's discuss design before proceeding with this. In general, I'm not sure the Run / Debug drop-down is the right place to add this functionality. compared to just a "Run" button in the editor or something. I'm not sure putting it in there is that discoverable or convenient (I'm guessing/hoping F5 still runs the project and not the circuit?)

Does it integrate with actual debugging (i.e. can you step through the circuit and see quantum state evolve)?

@@ -146,24 +146,33 @@
"menus": {
"editor/title/run": [
{
"command": "qsharp-vscode.runEditorContents",
"when": "resourceLangId == qsharp || resourceLangId == openqasm",
"command": "qsharp-vscode.runQsharp",
Copy link
Member

Choose a reason for hiding this comment

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

Why did all these get changed to *Qsharp from *Editor though? These apply to OpenQASM files also now, not just qsharp.

@@ -43,13 +43,11 @@ suite("OpenQASM Debugger Tests", function suite() {
vscode.debug.removeBreakpoints(vscode.debug.breakpoints);
});

test("Launch with debugEditorContents command", async () => {
test("Launch with debugQsharp command", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I don't get why the command name changed, and we should change it back. This is an OpenQASM test and you invoke debugQsharp, which is weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, that doesn't accurately describe the case for QASM. I'm renaming these based on Mine's suggestion above to runProgram and debugProgram respectively. The reason I'm wanting to move away from the names they had before is because they aren't accurate anymore. Instead of running/debugging the contents of the editor, what they really do is run/debug the project if there is one, or the file you are looking at otherwise. Based on that, runProgram and debugProgram more accurately describe what these commands do.

"command": "qsharp-vscode.debugEditorContents",
"when": "resourceLangId == qsharp || resourceLangId == openqasm"
"command": "qsharp-vscode.runQsharp",
"when": "resourceLangId == qsharp || resourceLangId == openqasm || (qsharp.isProjectFile && resourceLangId == qsharpcircuit)"
Copy link
Member

Choose a reason for hiding this comment

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

What do you need this isProjectFile context for? There's a lot of clunky code to set it on updates, and anyway the PR description says "This new functionality is available even if the circuit is not part of a Q# project"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was renamed to activeProjectDirectory but serves the same function. It is needed to know if we allow the Run and Debug commands to circuit files. These commands only make sense when the file is in a project. The Run Circuit command is separate and will always be available, though its internal details will change depending on if the file is part of a project or not. The difference is the Run Circuit command allows the user to run the circuit file by itself, where the Run command will run the project the circuit is a part of, which is the same behavior the Run command has when looking at Q# files.

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.

3 participants