Skip to content

Commit 29583ff

Browse files
authored
Azure Quantum: Update generated client and support for Cost Estimate upon job completion (Azure#26442)
* Update autorest.md with latest published swagger version * Automation scripts * Updated generated client * Fix autorest.md to a commit * Update generated client * Update generated client and unit test recordings * Update API and samples
1 parent 2ea9b50 commit 29583ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1430
-20697
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
temp/

sdk/quantum/Azure.Quantum.Jobs/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Release History
22

3-
## 1.0.0-beta.3 (Unreleased)
3+
## 1.0.0-beta.4 (Unreleased)
44

5+
## 1.0.0-beta.3 (2022-01-18)
6+
- When submitting a job to Azure Quantum, the resulting job details may include the cost estimate of the job (if supported by the provider). The final cost on your bill might be slightly different due to added taxes and currency conversion rates.
57

68
## 1.0.0-beta.2 (2021-03-30)
79
- Fixed a bug where the client was unable to authenticate using Interactive or Service Principal credentials (issue #19588)

sdk/quantum/Azure.Quantum.Jobs/api/Azure.Quantum.Jobs.netstandard2.0.cs

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public BlobDetails(string containerName) { }
4040
public string BlobName { get { throw null; } set { } }
4141
public string ContainerName { get { throw null; } }
4242
}
43+
public partial class CostEstimate
44+
{
45+
internal CostEstimate() { }
46+
public string CurrencyCode { get { throw null; } }
47+
public float? EstimatedTotal { get { throw null; } }
48+
public System.Collections.Generic.IReadOnlyList<Azure.Quantum.Jobs.Models.UsageEvent> Events { get { throw null; } }
49+
}
4350
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
4451
public readonly partial struct DimensionScope : System.IEquatable<Azure.Quantum.Jobs.Models.DimensionScope>
4552
{
@@ -70,6 +77,7 @@ public JobDetails(string containerUri, string inputDataFormat, string providerId
7077
public System.DateTimeOffset? BeginExecutionTime { get { throw null; } }
7178
public System.DateTimeOffset? CancellationTime { get { throw null; } }
7279
public string ContainerUri { get { throw null; } set { } }
80+
public Azure.Quantum.Jobs.Models.CostEstimate CostEstimate { get { throw null; } }
7381
public System.DateTimeOffset? CreationTime { get { throw null; } }
7482
public System.DateTimeOffset? EndExecutionTime { get { throw null; } }
7583
public Azure.Quantum.Jobs.Models.ErrorData ErrorData { get { throw null; } }
@@ -83,6 +91,7 @@ public JobDetails(string containerUri, string inputDataFormat, string providerId
8391
public string OutputDataUri { get { throw null; } set { } }
8492
public string ProviderId { get { throw null; } set { } }
8593
public Azure.Quantum.Jobs.Models.JobStatus? Status { get { throw null; } }
94+
public System.Collections.Generic.IList<string> Tags { get { throw null; } set { } }
8695
public string Target { get { throw null; } set { } }
8796
}
8897
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
@@ -106,6 +115,36 @@ public JobDetails(string containerUri, string inputDataFormat, string providerId
106115
public static bool operator !=(Azure.Quantum.Jobs.Models.JobStatus left, Azure.Quantum.Jobs.Models.JobStatus right) { throw null; }
107116
public override string ToString() { throw null; }
108117
}
118+
public partial class JsonPatchDocument
119+
{
120+
public JsonPatchDocument(Azure.Quantum.Jobs.Models.JsonPatchOperation op, string path) { }
121+
public string From { get { throw null; } set { } }
122+
public Azure.Quantum.Jobs.Models.JsonPatchOperation Op { get { throw null; } }
123+
public string Path { get { throw null; } }
124+
public object Value { get { throw null; } set { } }
125+
}
126+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
127+
public readonly partial struct JsonPatchOperation : System.IEquatable<Azure.Quantum.Jobs.Models.JsonPatchOperation>
128+
{
129+
private readonly object _dummy;
130+
private readonly int _dummyPrimitive;
131+
public JsonPatchOperation(string value) { throw null; }
132+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Add { get { throw null; } }
133+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Copy { get { throw null; } }
134+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Move { get { throw null; } }
135+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Remove { get { throw null; } }
136+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Replace { get { throw null; } }
137+
public static Azure.Quantum.Jobs.Models.JsonPatchOperation Test { get { throw null; } }
138+
public bool Equals(Azure.Quantum.Jobs.Models.JsonPatchOperation other) { throw null; }
139+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
140+
public override bool Equals(object obj) { throw null; }
141+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
142+
public override int GetHashCode() { throw null; }
143+
public static bool operator ==(Azure.Quantum.Jobs.Models.JsonPatchOperation left, Azure.Quantum.Jobs.Models.JsonPatchOperation right) { throw null; }
144+
public static implicit operator Azure.Quantum.Jobs.Models.JsonPatchOperation (string value) { throw null; }
145+
public static bool operator !=(Azure.Quantum.Jobs.Models.JsonPatchOperation left, Azure.Quantum.Jobs.Models.JsonPatchOperation right) { throw null; }
146+
public override string ToString() { throw null; }
147+
}
109148
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
110149
public readonly partial struct MeterPeriod : System.IEquatable<Azure.Quantum.Jobs.Models.MeterPeriod>
111150
{
@@ -161,14 +200,23 @@ internal QuantumJobQuota() { }
161200
public Azure.Quantum.Jobs.Models.DimensionScope? Scope { get { throw null; } }
162201
public float? Utilization { get { throw null; } }
163202
}
203+
public partial class QuantumJobQuotaList
204+
{
205+
internal QuantumJobQuotaList() { }
206+
public string NextLink { get { throw null; } }
207+
public System.Collections.Generic.IReadOnlyList<Azure.Quantum.Jobs.Models.QuantumJobQuota> Value { get { throw null; } }
208+
}
164209
public static partial class QuantumModelFactory
165210
{
211+
public static Azure.Quantum.Jobs.Models.CostEstimate CostEstimate(string currencyCode = null, System.Collections.Generic.IEnumerable<Azure.Quantum.Jobs.Models.UsageEvent> events = null, float? estimatedTotal = default(float?)) { throw null; }
166212
public static Azure.Quantum.Jobs.Models.ErrorData ErrorData(string code = null, string message = null) { throw null; }
167-
public static Azure.Quantum.Jobs.Models.JobDetails JobDetails(string id = null, string name = null, string containerUri = null, string inputDataUri = null, string inputDataFormat = null, object inputParams = null, string providerId = null, string target = null, System.Collections.Generic.IDictionary<string, string> metadata = null, string outputDataUri = null, string outputDataFormat = null, Azure.Quantum.Jobs.Models.JobStatus? status = default(Azure.Quantum.Jobs.Models.JobStatus?), System.DateTimeOffset? creationTime = default(System.DateTimeOffset?), System.DateTimeOffset? beginExecutionTime = default(System.DateTimeOffset?), System.DateTimeOffset? endExecutionTime = default(System.DateTimeOffset?), System.DateTimeOffset? cancellationTime = default(System.DateTimeOffset?), Azure.Quantum.Jobs.Models.ErrorData errorData = null) { throw null; }
213+
public static Azure.Quantum.Jobs.Models.JobDetails JobDetails(string id = null, string name = null, string containerUri = null, string inputDataUri = null, string inputDataFormat = null, object inputParams = null, string providerId = null, string target = null, System.Collections.Generic.IDictionary<string, string> metadata = null, string outputDataUri = null, string outputDataFormat = null, Azure.Quantum.Jobs.Models.JobStatus? status = default(Azure.Quantum.Jobs.Models.JobStatus?), System.DateTimeOffset? creationTime = default(System.DateTimeOffset?), System.DateTimeOffset? beginExecutionTime = default(System.DateTimeOffset?), System.DateTimeOffset? endExecutionTime = default(System.DateTimeOffset?), System.DateTimeOffset? cancellationTime = default(System.DateTimeOffset?), Azure.Quantum.Jobs.Models.CostEstimate costEstimate = null, Azure.Quantum.Jobs.Models.ErrorData errorData = null, System.Collections.Generic.IEnumerable<string> tags = null) { throw null; }
168214
public static Azure.Quantum.Jobs.Models.ProviderStatus ProviderStatus(string id = null, Azure.Quantum.Jobs.Models.ProviderAvailability? currentAvailability = default(Azure.Quantum.Jobs.Models.ProviderAvailability?), System.Collections.Generic.IEnumerable<Azure.Quantum.Jobs.Models.TargetStatus> targets = null) { throw null; }
169215
public static Azure.Quantum.Jobs.Models.QuantumJobQuota QuantumJobQuota(string dimension = null, Azure.Quantum.Jobs.Models.DimensionScope? scope = default(Azure.Quantum.Jobs.Models.DimensionScope?), string providerId = null, float? utilization = default(float?), float? holds = default(float?), float? limit = default(float?), Azure.Quantum.Jobs.Models.MeterPeriod? period = default(Azure.Quantum.Jobs.Models.MeterPeriod?)) { throw null; }
216+
public static Azure.Quantum.Jobs.Models.QuantumJobQuotaList QuantumJobQuotaList(System.Collections.Generic.IEnumerable<Azure.Quantum.Jobs.Models.QuantumJobQuota> value = null, string nextLink = null) { throw null; }
170217
public static Azure.Quantum.Jobs.Models.SasUriResponse SasUriResponse(string sasUri = null) { throw null; }
171218
public static Azure.Quantum.Jobs.Models.TargetStatus TargetStatus(string id = null, Azure.Quantum.Jobs.Models.TargetAvailability? currentAvailability = default(Azure.Quantum.Jobs.Models.TargetAvailability?), long? averageQueueTime = default(long?), string statusPage = null) { throw null; }
219+
public static Azure.Quantum.Jobs.Models.UsageEvent UsageEvent(string dimensionId = null, string dimensionName = null, string measureUnit = null, float? amountBilled = default(float?), float? amountConsumed = default(float?), float? unitPrice = default(float?)) { throw null; }
172220
}
173221
public partial class SasUriResponse
174222
{
@@ -202,4 +250,14 @@ internal TargetStatus() { }
202250
public string Id { get { throw null; } }
203251
public string StatusPage { get { throw null; } }
204252
}
253+
public partial class UsageEvent
254+
{
255+
internal UsageEvent() { }
256+
public float? AmountBilled { get { throw null; } }
257+
public float? AmountConsumed { get { throw null; } }
258+
public string DimensionId { get { throw null; } }
259+
public string DimensionName { get { throw null; } }
260+
public string MeasureUnit { get { throw null; } }
261+
public float? UnitPrice { get { throw null; } }
262+
}
205263
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
$ExportAPIScript = Join-Path $PSScriptRoot "../../../../eng/scripts/Export-API.ps1"
5+
&$ExportAPIScript -ServiceDirectory "quantum" -SDKType "client" | Write-Verbose
6+
7+
$UpdateSnippetsScript = Join-Path $PSScriptRoot "../../../../eng/scripts/Update-Snippets.ps1"
8+
&$UpdateSnippetsScript -ServiceDirectory "quantum" | Write-Verbose
9+
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.SYNOPSIS
6+
Checkout a git repository
7+
.DESCRIPTION
8+
This script checkouts a git repository, for a specific branch/commit into a target folder.
9+
It optionally checkout only specific folders (using sparse checkout) to speed-up the checkout process.
10+
.PARAMETER RepoUrl
11+
The URL of the git repo
12+
.PARAMETER TargetFolder
13+
The path of the folder to checkout the git repo
14+
.PARAMETER BranchName
15+
The name of the branch to checkout (defaults to the HEAD branch)
16+
.PARAMETER CommitId
17+
The specific CommitId to checkout (defaults to the HEAD commit id)
18+
.PARAMETER PathAllowList
19+
An array of paths to be checkout (all other paths are not checkout)
20+
.PARAMETER Force
21+
Deletes the TargetFolder before doing the checkout if it already exists
22+
23+
.EXAMPLE
24+
Checkout-Repo.ps1 -RepoUrl https://github.com/microsoft/qdk-python.git -TargetFolder ./qdk-python -Force
25+
26+
# Checks-out the entire qdk-python repo
27+
28+
.EXAMPLE
29+
Checkout-Repo.ps1 -RepoUrl https://github.com/microsoft/qdk-python.git -TargetFolder ./qdk-python -CommitId 8481428bd7eed9d68f960afa6af4ab34de1c75a2 -Force
30+
31+
# Checks-out a specific commit of the qdk-python repo
32+
33+
.EXAMPLE
34+
Checkout-Repo.ps1 -RepoUrl https://github.com/microsoft/qdk-python.git -TargetFolder ./qdk-python -BranchName release/v0.15.2102 -Force
35+
36+
# Checks-out a specific branch of the qdk-python repo
37+
38+
.EXAMPLE
39+
Checkout-Repo.ps1 -RepoUrl https://github.com/microsoft/qdk-python.git -TargetFolder ./qdk-python -PathAllowList /azure-quantum/,/build/ -Force
40+
41+
# Checks-out specific folders of the qdk-python repo
42+
43+
#>
44+
45+
[CmdletBinding()]
46+
Param (
47+
[ValidateNotNullOrEmpty()]
48+
[Parameter(Mandatory=$True)]
49+
[string] $RepoUrl,
50+
[ValidateNotNullOrEmpty()]
51+
[Parameter(Mandatory=$True)]
52+
[string] $TargetFolder,
53+
[string] $BranchName,
54+
[string] $CommitId,
55+
[string[]] $PathAllowList,
56+
[switch] $Force
57+
)
58+
59+
$TargetFolderExisted = Test-Path $TargetFolder
60+
if ($TargetFolderExisted)
61+
{
62+
if ($Force)
63+
{
64+
Write-Verbose "Deleting existing folder: $TargetFolder"
65+
Remove-Item $TargetFolder -Recurse -Force | Write-Verbose
66+
}
67+
else
68+
{
69+
Write-Verbose "Path already exists: $TargetFolder"
70+
Write-Verbose "Skipping checkout for $RepoUrl"
71+
exit 0
72+
}
73+
}
74+
75+
Write-Verbose "Creating folder: $TargetFolder"
76+
New-Item -ItemType "directory" -Path $TargetFolder -Force | Write-Verbose
77+
78+
Push-Location $TargetFolder
79+
try {
80+
git init | Write-Verbose
81+
if ($LASTEXITCODE -ne 0) { throw "Error initializing git repo" }
82+
83+
if (@($PathAllowList).Count -gt 0)
84+
{
85+
git config core.sparsecheckout true | Write-Verbose
86+
if ($LASTEXITCODE -ne 0) { throw "Error enabling git sparse checkout" }
87+
88+
git sparse-checkout init --cone | Write-Verbose
89+
if ($LASTEXITCODE -ne 0) { throw "Error initializing git sparse checkout" }
90+
91+
Write-Verbose "Sparse checkout enabled for the following paths:"
92+
foreach ($Path in $PathAllowList)
93+
{
94+
Write-Verbose " $Path"
95+
git sparse-checkout add $Path | Write-Verbose
96+
if ($LASTEXITCODE -ne 0) { throw "Error adding git sparse checkout path: $Path" }
97+
}
98+
}
99+
100+
Write-Verbose "Git remote URL: $RepoUrl"
101+
git remote add origin $RepoUrl | Write-Verbose
102+
if ($LASTEXITCODE -ne 0) { throw "Error adding git remote" }
103+
104+
if (![string]::IsNullOrEmpty($CommitId))
105+
{
106+
Write-Verbose "Checking out specific commit: $CommitId"
107+
git fetch --depth=1 origin $CommitId | Write-Verbose
108+
if ($LASTEXITCODE -ne 0) { throw "Error running git fetch for commit $CommitId" }
109+
git checkout $CommitId | Write-Verbose
110+
if ($LASTEXITCODE -ne 0) { throw "Error running git checkout for commit $CommitId" }
111+
}
112+
elseif (![string]::IsNullOrEmpty($BranchName))
113+
{
114+
Write-Verbose "Checking out specific branch: $BranchName"
115+
git fetch --depth=1 origin $BranchName | Write-Verbose
116+
if ($LASTEXITCODE -ne 0) { throw "Error running git fetch for branch $BranchName" }
117+
git checkout $BranchName | Write-Verbose
118+
if ($LASTEXITCODE -ne 0) { throw "Error running git fetch for branch $BranchName" }
119+
}
120+
else
121+
{
122+
Write-Verbose "Checking out default branch"
123+
git fetch --depth=1 origin | Write-Verbose
124+
if ($LASTEXITCODE -ne 0) { throw "Error running git fetch for default branch" }
125+
git pull origin HEAD | Write-Verbose
126+
if ($LASTEXITCODE -ne 0) { throw "Error running git pull for default branch" }
127+
}
128+
129+
exit 0
130+
}
131+
catch {
132+
# Delete the target folder if it didn't existed before
133+
# to avoid a partial checkout folder
134+
if (!$TargetFolderExisted)
135+
{
136+
Write-Verbose "Cleaning up partial checkout folder: $TargetFolder"
137+
Remove-Item $TargetFolder -Recurse -Force | Write-Verbose
138+
}
139+
throw
140+
}
141+
finally {
142+
Pop-Location
143+
}
144+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
$SwaggerTagVersion = "preview/2021-11-01-preview"
5+
6+
$SpecsRepo = "https://github.com/Azure/azure-rest-api-specs.git"
7+
$SpecsBranch = "main"
8+
$SpecsCommitId = ""
9+
$PathAllowList = ("specification/quantum")
10+
11+
$TempFolder = Join-Path $PSScriptRoot "../temp/"
12+
$SpecsFolder = Join-Path $TempFolder "/specs/"
13+
14+
# Check-out specs repo to get the latest swagger API Definition file
15+
$CheckoutScript = Join-Path $PSScriptRoot "./Checkout-Repo.ps1"
16+
&$CheckoutScript -RepoUrl $SpecsRepo -TargetFolder $SpecsFolder -PathAllowList $PathAllowList -BranchName $SpecsBranch -CommitId $SpecsCommitId -Force | Write-Verbose
17+
18+
$AutoRestConfig = Join-Path $PSScriptRoot "../src/autorest.md"
19+
20+
# Make sure we have the latest AutoRest
21+
npm install -g autorest@latest | Write-Verbose
22+
23+
# Delete the old generated client and copy the new one there
24+
$AzureQuantumClient_Folder = Join-Path $PSScriptRoot "../src/Generated/"
25+
if (Test-Path $AzureQuantumClient_Folder) {
26+
Remove-Item $AzureQuantumClient_Folder -Recurse | Write-Verbose
27+
}
28+
29+
30+
$NewAutorestConfig = @"
31+
# Generated code configuration
32+
33+
Run ``dotnet build /t:GenerateCode`` to generate code.
34+
35+
`````` yaml
36+
input-file:
37+
`$(this-folder)../temp/specs/specification/quantum/data-plane/Microsoft.Quantum/$SwaggerTagVersion/quantum.json
38+
``````
39+
"@
40+
41+
try
42+
{
43+
Copy-Item $AutoRestConfig -Destination "$AutoRestConfig.bkp" -Force | Write-Verbose
44+
45+
Set-Content -Path $AutoRestConfig -Value $NewAutorestConfig | Write-Verbose
46+
47+
# Generate the client
48+
dotnet build /t:GenerateCode /p:AutoRestAdditionalParameters="--verbose" | Write-Verbose
49+
}
50+
finally
51+
{
52+
Copy-Item "$AutoRestConfig.bkp" -Destination $AutoRestConfig -Force | Write-Verbose
53+
Remove-Item "$AutoRestConfig.bkp" -Force | Write-Verbose
54+
}

sdk/quantum/Azure.Quantum.Jobs/samples/Azure.Quantum.Jobs.Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Description>Azure Quantum Jobs library samples</Description>
55
<AssemblyTitle>Azure Quantum Jobs Samples</AssemblyTitle>
6-
<Version>1.0.0-beta.1</Version>
6+
<Version>1.0.0-beta.3</Version>
77
<PackageTags>Azure;Quantum;Quantum Jobs</PackageTags>
88
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
99
<OutputType>Exe</OutputType>

0 commit comments

Comments
 (0)