ValidationException action is invalid json string using boto3

0

Hi all,

I'm trying to create a quantum task using the boto client and I get a ValidationException "action is invalid json string".

I am creating a python string for the "action" that seems legal, but for some reason I keep getting this exception. The (very simple) string is:

{"braketSchemaHeader": {"name": "braket.ir.jaqcd.program", "version": "1"}, "results": [], "basis_rotation_instructions": [], "instructions": [{"type": "h", "target": 0}, {"type": "h", "target": 1}, {"type": "h", "target": 0}, ]}

I get no other more detailed information on the exception or validation.

Thanks in advance for your help
Best

fim
已提問 3 年前檢視次數 345 次
2 個答案
0

Hi all,

The original message is not showing the complete json action... I'll try to edit it to show the complete string.

But the answer is: the offending character is the last comma in the instructions. You can check that using json.loads(action_string) with and without the comma.

The next problem to solve was the "properties". The boto3 documentation is horrible in the description of the fields. In fact, no description at all.

Thanks
Best

fim
已回答 3 年前
0

Glad to hear that you were able to find the issue with action string!

Thanks for the feedback on the boto3 documentation! This is super helpful. I'm assuming you're referring to the documentation for the parameters here https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/braket.html#Braket.Client.create_quantum_task

We'll work on adding more details to boto3. Meanwhile you can look at the amazon-braket-schemas repository https://github.com/aws/amazon-braket-schemas-python/blob/main/src/braket/ir/jaqcd/program_v1.py which contains the specifications for this field.

We would also love to hear more about the other issues you encountered using Braket and learn more about what tools/details you think you would have found helpful in order to improve your experience. Please feel free to add in additional observations here and we'll try to incorporate those.

AWS
已回答 3 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南