question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Quantum CreateJob fails when InputParams is defined

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
vxfieldcommented, Nov 19, 2021

#21836 was just merged and updated our samples and documentation to avoid this issue.

1reaction
vxfieldcommented, Oct 15, 2021

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.

// Submit job
var jobId = $"job-{Guid.NewGuid():N}";
var jobName = $"jobName-{Guid.NewGuid():N}";
var inputDataFormat = "microsoft.qio.v2";
var outputDataFormat = "microsoft.qio-results.v2";
var providerId = "microsoft";
var target = "microsoft.paralleltempering-parameterfree.cpu";
var inputParams = new Dictionary<string, object>() { { "params", new Dictionary<string, object>() } };
var createJobDetails = new JobDetails(containerUri, inputDataFormat, providerId, target)
{
    Id = jobId,
    InputDataUri = inputDataUri,
    Name = jobName,
    InputParams = inputParams,
    OutputDataFormat = outputDataFormat
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Parallel Cluster Profile Validation fails on Job test
my parallel toolbox fails, I am entirely on default settings, when validating Cluster Profile Manager I get failure in Job test (createjob), ...
Read more >
ComFormer/predict.csv at master
... execute wrapped bifunction with it s input params as captured this method ... throwable at the error level gets the value of...
Read more >
org.apache.spark.SparkContext Scala Example
This page shows Scala examples of org.apache.spark.SparkContext.
Read more >
wordlist_no_underscores.txt
... doge google61602b8864e616e8 concourse-plugin-core asst2 define-const ... pb002 pb032 bytematrix dephp pages-data maininterface error-500 miscperl ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found