Skip to content

Commit 634193a

Browse files
authored
v2 workspace handling: fix generated Python; upload circuit diagram by default (#2869)
- The "generate Python code to connect to workspace" code should recognize the `-v2` suffix (currently the only expected suffix) - We should upload the circuit diagram data by default to these workspaces.
1 parent a46da2e commit 634193a

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

source/vscode/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,11 @@
183183
"default": false,
184184
"description": "Suppress notifications about new QDK updates. If true, you will not be prompted about new features after updates."
185185
},
186-
"Q#.azure.experimental.uploadSupplementalData": {
186+
"Q#.azure.uploadSupplementalData": {
187187
"type": "boolean",
188-
"default": false,
188+
"default": true,
189189
"tags": [
190-
"experimental"
190+
"hidden"
191191
],
192192
"description": "Upload supplemental input data (circuit diagram) to the storage container when submitting jobs to Azure Quantum."
193193
}

source/vscode/src/azure/commands.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,17 +672,22 @@ async function uploadSupplementalData(
672672
token: string,
673673
associationId: string,
674674
) {
675-
const circuitDiagram = await getCircuitJson(program);
676-
677-
await uploadBlob(
678-
storageUris,
679-
quantumUris,
680-
token,
681-
"circuitDiagram",
682-
circuitDiagram,
683-
"application/json",
684-
associationId,
685-
);
675+
const endpointMatch = quantumUris.endpoint.match(QuantumUris.endpointRegExp);
676+
const isV2Workspace = endpointMatch?.groups?.versionSuffix === "-v2";
677+
678+
if (isV2Workspace) {
679+
const circuitDiagram = await getCircuitJson(program);
680+
681+
await uploadBlob(
682+
storageUris,
683+
quantumUris,
684+
token,
685+
"circuitDiagram",
686+
circuitDiagram,
687+
"application/json",
688+
associationId,
689+
);
690+
}
686691
}
687692

688693
/**

source/vscode/src/azure/networkRequests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ export class AzureUris {
217217
export class QuantumUris {
218218
readonly apiVersion = "2022-09-12-preview";
219219

220+
// Regular expression to extract the first part of the endpointUri
221+
// - Captures only an exact "-v2" suffix (as versionSuffix) if present
222+
// - Otherwise, keeps any other suffix as part of the location
223+
// e.g. "https://westus.quantum.azure.com" -> location="westus", versionSuffix=undefined
224+
// e.g. "https://eastus2-v2.quantum.azure.com" -> location="eastus2", versionSuffix="-v2"
225+
public static readonly endpointRegExp =
226+
/https:\/\/(?<location>[^.]+?)(?<versionSuffix>-v2)?\./;
227+
220228
constructor(
221229
public endpoint: string, // e.g. "https://westus.quantum.azure.com"
222230
public id: string, // e.g. "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/quantumResourcegroup/providers/Microsoft.Quantum/Workspaces/quantumworkspace1"

source/vscode/src/azure/workspaceActions.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@ export function getPythonCodeForWorkspace(
9191
const idRegex =
9292
/\/subscriptions\/(?<subscriptionId>[^/]+)\/resourceGroups\/(?<resourceGroup>[^/]+)/;
9393

94-
// Regular expression to extract the first part of the endpointUri
95-
const endpointRegex = /https:\/\/(?<location>[^.]+)\./;
96-
9794
const idMatch = id.match(idRegex);
98-
const endpointMatch = endpointUri.match(endpointRegex);
95+
const endpointMatch = endpointUri.match(QuantumUris.endpointRegExp);
9996

10097
const subscriptionId = idMatch?.groups?.subscriptionId;
10198
const resourceGroup = idMatch?.groups?.resourceGroup;

source/vscode/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ export function getShowDevDiagnostics(): boolean {
4848
export function getUploadSupplementalData(): boolean {
4949
return vscode.workspace
5050
.getConfiguration("Q#")
51-
.get<boolean>("azure.experimental.uploadSupplementalData", false);
51+
.get<boolean>("azure.uploadSupplementalData", true);
5252
}

0 commit comments

Comments
 (0)