[BUG] Quantum CreateJob fails when InputParams is defined
See original GitHub issueDescribe the bug When trying to create an Azure Quantum job from the SDK setting the value for the InputParams object causes the request to fail.
Expected behavior Should be able to set parameters for the target solver.
Actual behavior (include Exception or Stack Trace) What is the actual behavior? SDK cannot serialize request [2021-10-08T02:23:03.160Z] Executed ‘CreateJob’ (Failed, Id=742d4854-467b-4ca9-a190-d54ba5106457, Duration=22741ms) [2021-10-08T02:23:03.161Z] System.Private.CoreLib: Exception while executing function: CreateJob. Azure.Quantum.Jobs: Service request failed. [2021-10-08T02:23:03.161Z] Status: 400 (Bad Request) [2021-10-08T02:23:03.162Z] [2021-10-08T02:23:03.162Z] Content: [2021-10-08T02:23:03.162Z] {“errors”:{“inputParams”:[“Error setting value to ‘InputParams’ on ‘Microsoft.Quantum.DataContract.ViewModel.Job’.”]},“type”:“https://tools.ietf.org/html/rfc7231#section-6.5.1",“title”:"One or more validation errors occurred.”,“status”:400,“traceId”:“00-8dedfde9ff4b4949a789f229b0355e35-b3904a4c63ac3548-00”} [2021-10-08T02:23:03.162Z] [2021-10-08T02:23:03.163Z] Headers: [2021-10-08T02:23:03.163Z] Server: Microsoft-IIS/10.0 [2021-10-08T02:23:03.164Z] Request-Context: REDACTED [2021-10-08T02:23:03.164Z] Strict-Transport-Security: REDACTED [2021-10-08T02:23:03.165Z] x-ms-request-id: b3904a4c63ac3548 [2021-10-08T02:23:03.166Z] X-Powered-By: REDACTED [2021-10-08T02:23:03.166Z] Set-Cookie: REDACTED [2021-10-08T02:23:03.167Z] Date: Fri, 08 Oct 2021 02:23:01 GMT [2021-10-08T02:23:03.168Z] Content-Length: 308 [2021-10-08T02:23:03.168Z] Content-Type: application/problem+json; charset=utf-8 [2021-10-08T02:23:03.169Z] .
To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)
I have tried setting InputParams via both a anonymous object and a string
[FunctionName("CreateJob")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation($"CreateJob function started {DateTime.Now}");
var client =
new QuantumJobClient(
Environment.GetEnvironmentVariable("subId"),
Environment.GetEnvironmentVariable("workspace"),
Environment.GetEnvironmentVariable("workspace"),
"eastUS",
new DefaultAzureCredential());
var jobId = Guid.NewGuid().ToString().Replace("-", "");
var job = new JobDetails($"{Environment.GetEnvironmentVariable("quantumStorage")}/ createnumbers", "microsoft.ionq-ir.v2", "IonQ", "ionq.qpu");
job.InputParams = "{ 'shots': 50 }";
job.InputDataUri = $"{Environment.GetEnvironmentVariable("quantumStorage")}/createnumbers/inputData";
job.OutputDataFormat = "microsoft.quantum-results.v1";
job.OutputDataUri = $"{Environment.GetEnvironmentVariable("quantumStorage")}/quantum-job-{jobId}/mappingData";
var response = client.CreateJob(jobId, job);
return new OkObjectResult(JsonConvert.SerializeObject(response));
}
Environment:
- Azure.Quantum.Jobs 1.0.0-beta.2
- Windows 10 .NET Core 3.1.413
- .NET SDK Version: 5.0.301 Commit: ef17233f86
- Visual Studio 2019 v16.10.3
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
#21836 was just merged and updated our samples and documentation to avoid this issue.
Actually the specific issue you faced was related to the
InputParams
, which should be initialized with at least an empty dictionary (see snippet below). However, you would still need to compress the problem to gzip, so better to use this sample code anyway.I’ll work to update our public sample to avoid future confusions.