@@ -129,7 +129,7 @@ def _authenticate(self, token=None):
129129 def _run (self , info , device ):
130130 """
131131 Run the quantum code to the IBMQ machine.
132- Update since March2020 : only protocol available is what they call
132+ Update since September 2020 : only protocol available is what they call
133133 'object storage' where a job request via the POST method gets in
134134 return a url link to which send the json data. A final http validates
135135 the data communication.
@@ -162,19 +162,10 @@ def _run(self, info, device):
162162 ** json_step1 )
163163 request .raise_for_status ()
164164 r_json = request .json ()
165- download_endpoint_url = r_json ['objectStorageInfo' ][
166- 'downloadQObjectUrlEndpoint' ]
167- upload_endpoint_url = r_json ['objectStorageInfo' ][
168- 'uploadQobjectUrlEndpoint' ]
169165 upload_url = r_json ['objectStorageInfo' ]['uploadUrl' ]
166+ execution_id = r_json ['id' ]
170167
171- # STEP2: WE USE THE ENDPOINT TO GET THE UPLOT LINK
172- json_step2 = {'allow_redirects' : True , 'timeout' : (5.0 , None )}
173- request = super (IBMQ , self ).get (upload_endpoint_url , ** json_step2 )
174- request .raise_for_status ()
175- r_json = request .json ()
176-
177- # STEP3: WE USE THE ENDPOINT TO GET THE UPLOT LINK
168+ # STEP2: WE UPLOAD THE CIRCUIT DATA
178169 n_classical_reg = info ['nq' ]
179170 # hack: easier to restrict labels to measured qubits
180171 n_qubits = n_classical_reg # self.backends[device]['nq']
@@ -194,7 +185,7 @@ def _run(self, info, device):
194185 data += ('"parameter_binds": [], "memory_slots": '
195186 + str (n_classical_reg ))
196187 data += (', "n_qubits": ' + str (n_qubits )
197- + '}, "schema_version": "1.1 .0", ' )
188+ + '}, "schema_version": "1.2 .0", ' )
198189 data += '"type": "QASM", "experiments": [{"config": '
199190 data += '{"n_qubits": ' + str (n_qubits ) + ', '
200191 data += '"memory_slots": ' + str (n_classical_reg ) + '}, '
@@ -205,31 +196,31 @@ def _run(self, info, device):
205196 data += '"clbit_labels": ' + str (c_label ).replace ('\' ' , '\" ' ) + ', '
206197 data += '"memory_slots": ' + str (n_classical_reg ) + ', '
207198 data += '"creg_sizes": [["c", ' + str (n_classical_reg ) + ']], '
208- data += ('"name": "circuit0"}, "instructions": ' + instruction_str
199+ data += ('"name": "circuit0", "global_phase": 0 }, "instructions": ' + instruction_str
209200 + '}]}' )
210201
211- json_step3 = {
202+ json_step2 = {
212203 'data' : data ,
213204 'params' : {
214205 'access_token' : None
215206 },
216207 'timeout' : (5.0 , None )
217208 }
218- request = super (IBMQ , self ).put (r_json [ 'url' ] , ** json_step3 )
209+ request = super (IBMQ , self ).put (upload_url , ** json_step2 )
219210 request .raise_for_status ()
220211
221- # STEP4 : CONFIRM UPLOAD
222- json_step4 = {
212+ # STEP3 : CONFIRM UPLOAD
213+ json_step3 = {
223214 'data' : None ,
224215 'json' : None ,
225216 'timeout' : (self .timeout , None )
226217 }
227- upload_data_url = upload_endpoint_url .replace ('jobUploadUrl' ,
228- 'jobDataUploaded' )
229- request = super (IBMQ , self ).post (upload_data_url , ** json_step4 )
218+
219+ upload_data_url = urljoin (_API_URL ,
220+ 'Network/ibm-q/Groups/open/Projects/main/Jobs/' + str (execution_id )
221+ + '/jobDataUploaded' )
222+ request = super (IBMQ , self ).post (upload_data_url , ** json_step3 )
230223 request .raise_for_status ()
231- r_json = request .json ()
232- execution_id = upload_endpoint_url .split ('/' )[- 2 ]
233224
234225 return execution_id
235226
0 commit comments