3
$\begingroup$

I am going to be running a large volume of jobs. In the past, with smaller volumes, I've gone through and changed the tags of the jobs by hand so as to more easily keep track of them (knowing how many were run on which quantum computer for example). However, the number of jobs I will be running will be large enough that doing this by hand would be very tedious and inconvenient.

I would like to be able to edit the job tags automatically, either when the job is first sent, or after the fact. A few google searches, searches on this forum, and skimming the qiskit documentation hasn't yielded any solutions, but it's possible that I could have missed something. Does anyone know a way to accomplish this?

$\endgroup$

1 Answer 1

3
$\begingroup$

To add tags to primitive jobs you can do this :

from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.circuit.random import random_circuit
from qiskit_ibm_runtime import Options, Sampler

service = QiskitRuntimeService(channel="ibm_quantum")
backend = service.backend("ibmq_qasm_simulator")

circuit = random_circuit(2, 2, seed=0, measure=True).decompose(reps=1)

options = Options(optimization_level=1, environment={"job_tags": ["hi_there"]})
sampler = Sampler(session=backend, options=options)
result = sampler.run(circuit).result()

And to get back the jobs you do this

jobs = service.jobs(job_tags='hi_there')
$\endgroup$
4
  • $\begingroup$ I'm marking this answer as correct becuase it does in fact work to edit the tags for a job. However, I feel really dumb as I just realized that I had made a mistake in asking my question, what I had really intended to figure out was how to automatically rename the job itself, not add a tag. I don't suppose you know off hand how that is done? $\endgroup$
    – YaGoi Root
    Feb 7, 2023 at 3:23
  • 1
    $\begingroup$ @YaGoiRoot Can you ask a separate question for renaming jobs? $\endgroup$ Feb 7, 2023 at 8:58
  • $\begingroup$ @JunyeHuang Certainly, I just didn't want to post another question immediately and have it be considered as spam. $\endgroup$
    – YaGoi Root
    Feb 7, 2023 at 19:37
  • $\begingroup$ @JunyeHuang The new question is here: quantumcomputing.stackexchange.com/q/30109/20907 $\endgroup$
    – YaGoi Root
    Feb 7, 2023 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.