-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransform.py
55 lines (42 loc) · 1.37 KB
/
transform.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
import os, sys
from bloqade import loads
src = None
with open(sys.argv[1], "r") as f:
src = json.load(f)
tasks = src["remote_batch"]["tasks"]
new_tasks = []
for tid, task in tasks:
task_id = task["braket_task"]["task_id"]
task_ir = task["braket_task"]["task_ir"]["quera_task_specification"]
task_result_ir = task["braket_task"]["task_result_ir"]["task_result_ir"]
backend = task["braket_task"]["backend"]["braket_backend"]
parallel_decoder = (
None
if "parallel_decoder" not in task["braket_task"]
or task["braket_task"]["parallel_decoder"] is None
else task["braket_task"]["parallel_decoder"]["parallel_decoder"]
)
tsk = {
"bloqade.task.braket.BraketTask": {
"backend": backend,
"parallel_decoder": parallel_decoder,
"task_id": task_id,
"task_result_ir": task_result_ir,
"task_ir": task_ir,
"metadata": task["braket_task"]["metadata"],
}
}
new_tasks.append([tid, tsk])
new_future = {
"bloqade.task.batch.RemoteBatch": {
"source": src["remote_batch"]["source"],
"name": src["remote_batch"]["name"],
"tasks": new_tasks,
}
}
a = loads(json.dumps(new_future))
# str = json.dumps(new_future)
with open(sys.argv[1] + ".new", "w") as f:
json.dump(new_future, f, indent=2)
# print(str)