Skip to content

Commit

Permalink
Add instance property to job (#1771)
Browse files Browse the repository at this point in the history
* Add instance property to job

* Add release note

* add test

* assertEqual instead of True

* Update docstring
  • Loading branch information
kt474 authored Jun 27, 2024
1 parent b01a1b6 commit 10b21f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qiskit_ibm_runtime/base_runtime_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ def usage_estimation(self) -> Dict[str, Any]:

return self._usage_estimation

@property
def instance(self) -> Optional[str]:
"""For ibm_quantum channel jobs, return the instance where the job was run.
For ibm_cloud, `None` is returned.
"""
return self._backend._instance

@abstractmethod
def in_final_state(self) -> bool:
"""Return whether the job is in a final job state such as ``DONE`` or ``ERROR``."""
Expand Down
2 changes: 2 additions & 0 deletions release-notes/unreleased/1771.feat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added an ``instance`` property to :class:`BaseRuntimeJob` which returns the instance
where the job was run.
4 changes: 4 additions & 0 deletions test/integration/test_ibm_job_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def test_job_id(self):
"""Test getting a job ID."""
self.assertTrue(self.sim_job.job_id() is not None)

def test_job_instance(self):
"""Test getting job instance."""
self.assertEqual(self.dependencies.instance, self.sim_job.instance)

def test_get_backend_name(self):
"""Test getting a backend name."""
self.assertTrue(self.sim_job.backend().name == self.sim_backend.name)
Expand Down

0 comments on commit 10b21f4

Please sign in to comment.