1313 QaaSClient ,
1414 QaaSPlatform ,
1515 QaaSPlatformAvailability ,
16- QaaS ,
16+ QaaSJobBackendData ,
17+ QaaSJobRunData ,
18+ QaaSJobData ,
19+ QaaSCircuitData
1720)
1821
1922
@@ -28,18 +31,56 @@ def __init__(
2831 self .__session_id : str = None
2932
3033 def allocate (self , ** kwargs ) -> None :
34+ if self .__session_id :
35+ return
36+
3137 deduplication_id = kwargs .get ("deduplication_id" , None )
3238 session = self .__client .create_session (
3339 self .__platform .id , deduplication_id = deduplication_id
3440 )
3541 self .__session_id = session .id
3642
3743 def deallocate (self , ** kwargs ) -> None :
44+ if self .__session_id :
45+ return
46+
3847 self .__client .terminate_session (self .__session_id )
3948
40- def run (self , model : ComputationalModel , ** kwargs ) -> BackendRunResult :
49+ def run (self , model : ComputationalModel , shots : int , ** kwargs ) -> BackendRunResult :
50+ run_data = QaaSJobRunData (
51+ options = {
52+ "shots" : shots ,
53+ },
54+ circuits = list (
55+ map (
56+ lambda c : QaaSCircuitData (
57+ serialization_format = model .serialization_format ,
58+ circuit_serialization = model .serialization ,
59+ ),
60+ self ._circuits ,
61+ )
62+ ),
63+ )
64+
65+ backend_data = QaaSJobBackendData (
66+ name = self .backend ().name ,
67+ version = self .backend ().version ,
68+ )
69+
70+ data = QaaSJobData .schema ().dumps (
71+ QaaSJobData (
72+ backend = backend_data ,
73+ run = run_data ,
74+ client = None ,
75+ )
76+ )
77+
4178 model = self .__client .create_model (model )
42- self .__client .create_job (self .__session_id , model_id = model .id )
79+
80+ if not model :
81+ raise RuntimeError ("Failed to push circuit data" )
82+
83+ job = self .__client .create_job (self .__session_id , model_id = model .id )
4384
4485 @property
4586 def max_qubit_count (self ) -> int :
0 commit comments