This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Migration of Azure Quantum .NET components to track2 #716
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
59c15c4
Replace generated files in Quantum.Client with reference to the Azure…
anpaz 96b5fc2
Changes to enable Mocks for iq# and integrate with Live tests (#707)
anpaz a6492ff
Credentials parameter (#721)
anpaz 936beb2
Merge main (#731)
anpaz aa9af91
Merge branch 'main' into feature/track2-net
anpaz b18c6db
Merge branch 'main' into feature/track2-net
0a41482
Apply suggestions from code review
anpaz 80062b1
Incorporating feedback.
anpaz 39c2321
Build 0.17.2106.147878.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.snk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "msbuild-sdks": { | ||
| "Microsoft.Quantum.Sdk": "0.16.2105140327-beta" | ||
| "Microsoft.Quantum.Sdk": "0.17.2106147878-beta" | ||
| } | ||
| } |
76 changes: 76 additions & 0 deletions
76
src/Azure/Azure.Quantum.Client.Test/CredentialFactoryTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #nullable enable | ||
|
|
||
| using System; | ||
|
|
||
| using Azure.Identity; | ||
|
|
||
| using Microsoft.Azure.Quantum.Authentication; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace Microsoft.Azure.Quantum.Test | ||
| { | ||
| [TestClass] | ||
| public class CredentialFactoryTests | ||
| { | ||
| private const string SUBSCRIPTION = "916dfd6d-030c-4bd9-b579-7bb6d1926e97"; | ||
|
|
||
| [DataTestMethod] | ||
| [DataRow(CredentialType.Default, typeof(DefaultAzureCredential))] | ||
| [DataRow(CredentialType.Environment, typeof(EnvironmentCredential))] | ||
| [DataRow(CredentialType.ManagedIdentity, typeof(ManagedIdentityCredential))] | ||
| [DataRow(CredentialType.CLI, typeof(AzureCliCredential))] | ||
| [DataRow(CredentialType.SharedToken, typeof(SharedTokenCacheCredential))] | ||
| [DataRow(CredentialType.VisualStudio, typeof(VisualStudioCredential))] | ||
| [DataRow(CredentialType.VisualStudioCode, typeof(VisualStudioCodeCredential))] | ||
| [DataRow(CredentialType.Interactive, typeof(InteractiveBrowserCredential))] | ||
| [DataRow(CredentialType.DeviceCode, typeof(DeviceCodeCredential))] | ||
| public void TestCreateCredential(CredentialType credentialType, Type expectedType) | ||
| { | ||
| var actual = CredentialFactory.CreateCredential(credentialType); | ||
| Assert.IsNotNull(actual); | ||
| Assert.AreEqual(expectedType, actual.GetType()); | ||
|
|
||
| // Now test with a specific subscription id: | ||
| actual = CredentialFactory.CreateCredential(credentialType, SUBSCRIPTION); | ||
| Assert.IsNotNull(actual); | ||
| Assert.AreEqual(expectedType, actual.GetType()); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestInvalidCredentialType() | ||
| { | ||
| Assert.ThrowsException<ArgumentException>(() => CredentialFactory.CreateCredential((CredentialType)9999)); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestGetTenantId() | ||
| { | ||
| var actual = CredentialFactory.GetTenantId(SUBSCRIPTION); | ||
| Assert.IsNotNull(actual); | ||
| Assert.IsFalse(string.IsNullOrWhiteSpace(actual)); | ||
|
|
||
| var actual2 = CredentialFactory.GetTenantId(SUBSCRIPTION); | ||
| Assert.AreEqual(actual, actual2); | ||
| } | ||
|
|
||
| [DataTestMethod] | ||
| [DataRow(null, null)] | ||
| [DataRow("", null)] | ||
| [DataRow("some random string", null)] | ||
| [DataRow("string,with,random,values", null)] | ||
| [DataRow("string=with,random=,key=values", null)] | ||
| [DataRow("string=with,random=,authorization_uri=", null)] | ||
| [DataRow("string=with,invalid=authorization_uri,authorization_uri=some-random-value", null)] | ||
| [DataRow("string=with,invalid=authorization_uri,authorization_uri=http://foo.bar.com/some-random-value", null)] | ||
| [DataRow("string=missing,tenant_id=authorization_uri,authorization_uri=\"http://foo.bar.com/", null)] | ||
| [DataRow("authorization_uri=\"https://login.microsoftonline.com/tenantId\",key1=value1s,etc...", "tenantId")] | ||
| public void TestExtractTenantIdFromBearer(string? bearer, string? expected) | ||
| { | ||
| var actual = CredentialFactory.ExtractTenantIdFromBearer(bearer); | ||
| Assert.AreEqual(expected, actual); | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text.Json; | ||
| using System.Text.Json.Serialization; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Microsoft.Azure.Quantum.Test | ||
| { | ||
| public enum ProblemType : int | ||
| { | ||
| PUBO = 0, | ||
| Ising = 1, | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// This is the data structure that represents a QIO problem payload on the service. | ||
| /// It's currently not exposed in C#, so we have it here so we can test job submission of | ||
| /// the client libraries without having to serialize Q# programs. | ||
| /// </summary> | ||
| public class Problem | ||
| { | ||
| private readonly HashSet<Term> terms = new HashSet<Term>(); | ||
|
|
||
| public Problem(ProblemType type = ProblemType.PUBO) | ||
| { | ||
| ProblemType = type; | ||
| } | ||
|
|
||
| public Problem(IEnumerable<Term> collection) | ||
| : this() | ||
| { | ||
| AddRange(collection); | ||
| } | ||
|
|
||
| [JsonPropertyName("version")] | ||
| public string Version => "1.1"; | ||
|
|
||
| [JsonPropertyName("type")] | ||
| [JsonConverter(typeof(JsonStringEnumConverter))] | ||
| public ProblemType ProblemType { get; } | ||
|
|
||
| [JsonPropertyName("terms")] | ||
| public IEnumerable<Term> Terms => terms; | ||
|
|
||
| public void Add(Term term) | ||
| { | ||
| terms.Add(term); | ||
| } | ||
|
|
||
| public void Add(int i, float c) | ||
| { | ||
| terms.Add(new Term(new int[] { i }, c)); | ||
| } | ||
|
|
||
| public void Add(int i, int j, float c) | ||
| { | ||
| terms.Add(new Term(new int[] { i, j }, c)); | ||
| } | ||
|
|
||
| public void Add(int i, int j, int k, float c) | ||
| { | ||
| terms.Add(new Term(new int[] { i, j, k }, c)); | ||
| } | ||
|
|
||
| public void AddRange(IEnumerable<Term> collection) | ||
| { | ||
| foreach (var term in collection) | ||
| { | ||
| terms.Add(term); | ||
| } | ||
| } | ||
|
|
||
| public Task SerializeAsync(Stream stream) | ||
| { | ||
| var root = new SerializationWrapper | ||
| { | ||
| CostFunction = this, | ||
| }; | ||
|
|
||
| // Save to the writer | ||
| return JsonSerializer.SerializeAsync(stream, root); | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| var root = new SerializationWrapper | ||
| { | ||
| CostFunction = this, | ||
| }; | ||
|
|
||
| return JsonSerializer.Serialize(root); | ||
| } | ||
|
|
||
| private struct SerializationWrapper | ||
| { | ||
| [JsonPropertyName("cost_function")] | ||
| public Problem CostFunction { get; set; } | ||
| } | ||
|
|
||
| public class Term | ||
| { | ||
| public Term(int[] ids, float c) | ||
| { | ||
| this.IDs = ids; | ||
| this.Weight = c; | ||
| } | ||
|
|
||
| [JsonPropertyName("c")] | ||
| public float Weight { get; } | ||
|
|
||
| [JsonPropertyName("ids")] | ||
| public int[] IDs { get; } | ||
| } | ||
| } | ||
| } |
14 changes: 0 additions & 14 deletions
14
src/Azure/Azure.Quantum.Client.Test/Helpers/TestConstants.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.