def _submit_job( self, qobj: Qobj, job_name: Optional[str] = None, job_share_level: Optional[ApiJobShareLevel] = None) -> IBMQJob: """Submit qobj job to IBM-Q. Args: qobj: description of job. job_name: custom name to be assigned to the job. This job name can subsequently be used as a filter in the ``jobs()`` function call. Job names do not need to be unique. job_share_level: level the job should be shared at. Returns: an instance derived from BaseJob Events: ibmq.job.start: The job has started. Raises: IBMQBackendApiError: If an unexpected error occurred while submitting the job. IBMQBackendError: If an unexpected error occurred after submitting the job. IBMQBackendApiProtocolError: If an unexpected value received when the server. """ try: qobj_dict = qobj.to_dict() submit_info = self._api.job_submit( backend_name=self.name(), qobj_dict=qobj_dict, use_object_storage=getattr(self.configuration(), 'allow_object_storage', False), job_name=job_name, job_share_level=job_share_level) except ApiError as ex: raise IBMQBackendApiError('Error submitting job: {}'.format( str(ex))) # Error in the job after submission: # Transition to the `ERROR` final state. if 'error' in submit_info: raise IBMQBackendError('Error submitting job: {}'.format( str(submit_info['error']))) # Submission success. submit_info.update({ '_backend': self, 'api': self._api, 'qObject': qobj_dict }) try: job = IBMQJob.from_dict(submit_info) except ModelValidationError as err: raise IBMQBackendApiProtocolError( 'Unexpected return value from the server ' 'when submitting job: {}'.format(str(err))) Publisher().publish("ibmq.job.start", job) return job
def _submit_job(self, qobj: Qobj, job_name: Optional[str] = None, job_share_level: Optional[ApiJobShareLevel] = None, job_tags: Optional[List[str]] = None) -> IBMQJob: """Submit the Qobj to the backend. Args: qobj: The Qobj to be executed. job_name: Custom name to be assigned to the job. This job name can subsequently be used as a filter in the ``jobs()``method. Job names do not need to be unique. job_share_level: Level the job should be shared at. job_tags: Tags to be assigned to the job. Returns: The job to be executed, an instance derived from BaseJob. Events: ibmq.job.start: The job has started. Raises: IBMQBackendApiError: If an unexpected error occurred while submitting the job. IBMQBackendError: If an unexpected error occurred after submitting the job. IBMQBackendApiProtocolError: If an unexpected value is received from the server. """ try: qobj_dict = qobj.to_dict() submit_info = self._api.job_submit(backend_name=self.name(), qobj_dict=qobj_dict, job_name=job_name, job_share_level=job_share_level, job_tags=job_tags) except ApiError as ex: raise IBMQBackendApiError('Error submitting job: {}'.format( str(ex))) from ex # Error in the job after submission: # Transition to the `ERROR` final state. if 'error' in submit_info: raise IBMQBackendError('Error submitting job: {}'.format( str(submit_info['error']))) # Submission success. submit_info.update({ '_backend': self, 'api': self._api, 'qObject': qobj }) try: job = IBMQJob.from_dict(submit_info) logger.debug('Job %s was successfully submitted.', job.job_id()) except ModelValidationError as err: raise IBMQBackendApiProtocolError( 'Unexpected return value received from the server ' 'when submitting job: {}'.format(str(err))) from err Publisher().publish("ibmq.job.start", job) return job