@cell_magic<EOL><INDENT>@magic_arguments.magic_arguments()<EOL>@magic_arguments.argument(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>type=float,<EOL>default=None,<EOL>help='<STR_LIT>'<EOL>)<EOL>def qiskit_job_status(self, line='<STR_LIT>', cell=None):<DEDENT>
args = magic_arguments.parse_argstring(self.qiskit_job_status, line)<EOL>if args.interval is None:<EOL><INDENT>args.interval = <NUM_LIT:2><EOL>_interval_set = False<EOL><DEDENT>else:<EOL><INDENT>_interval_set = True<EOL><DEDENT>cell_lines = cell.split('<STR_LIT:\n>')<EOL>line_vars = []<EOL>for cline in cell_lines:<EOL><INDENT>if '<STR_LIT:=>' in cline and '<STR_LIT>' not in cline:<EOL><INDENT>line_vars.append(cline.replace('<STR_LIT:U+0020>', '<STR_LIT>').split('<STR_LIT:=>')[<NUM_LIT:0>])<EOL><DEDENT>elif '<STR_LIT>' in cline:<EOL><INDENT>line_vars.append(cline.replace('<STR_LIT:U+0020>', '<STR_LIT>').split('<STR_LIT:(>')[<NUM_LIT:0>])<EOL><DEDENT><DEDENT>self.shell.ex(cell)<EOL>jobs = []<EOL>for var in line_vars:<EOL><INDENT>iter_var = False<EOL>if '<STR_LIT:#>' not in var:<EOL><INDENT>if '<STR_LIT:[>' in var:<EOL><INDENT>var = var.split('<STR_LIT:[>')[<NUM_LIT:0>]<EOL>iter_var = True<EOL><DEDENT>elif '<STR_LIT>' in var:<EOL><INDENT>var = var.split('<STR_LIT>')[<NUM_LIT:0>]<EOL>iter_var = True<EOL><DEDENT>if iter_var:<EOL><INDENT>for item in self.shell.user_ns[var]:<EOL><INDENT>if isinstance(item, qiskit.providers.basejob.BaseJob):<EOL><INDENT>jobs.append(item)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(self.shell.user_ns[var],<EOL>qiskit.providers.basejob.BaseJob):<EOL><INDENT>jobs.append(self.shell.user_ns[var])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if not any(jobs):<EOL><INDENT>raise Exception(<EOL>"<STR_LIT>")<EOL><DEDENT>multi_job = False<EOL>if len(jobs) > <NUM_LIT:1>:<EOL><INDENT>multi_job = True<EOL><DEDENT>job_checkers = []<EOL>for idx, job_var in enumerate(jobs):<EOL><INDENT>style = "<STR_LIT>"<EOL>if multi_job:<EOL><INDENT>idx_str = '<STR_LIT>' % idx<EOL><DEDENT>else:<EOL><INDENT>idx_str = '<STR_LIT>'<EOL><DEDENT>header = "<STR_LIT>".format(id=idx_str,<EOL>style=style)<EOL>status = widgets.HTML(<EOL>value=header % job_var.status().value)<EOL>thread = threading.Thread(target=_html_checker, args=(job_var, args.interval,<EOL>status, header,<EOL>_interval_set))<EOL>thread.start()<EOL>job_checkers.append(status)<EOL><DEDENT>box = widgets.VBox(job_checkers)<EOL>display(box)<EOL>
A Jupyter magic function to check the status of a Qiskit job instance.