Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable retrieval of historical data for 'target' #743

Merged
merged 6 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions qiskit_ibm_runtime/ibm_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,14 @@ def __getattr__(self, name: str) -> Any:
)
)

def _get_properties(self) -> None:
def _get_properties(self, datetime: Optional[python_datetime] = None) -> None:
"""Gets backend properties and decodes it"""
if datetime:
datetime = local_to_utc(datetime)
if not self._properties:
api_properties = self._api_client.backend_properties(self.name)
api_properties = self._api_client.backend_properties(
self.name, datetime=datetime
)
if api_properties:
backend_properties = properties_from_server_data(api_properties)
self._properties = backend_properties
Expand Down Expand Up @@ -311,6 +315,16 @@ def target(self) -> Target:
self._convert_to_target()
return self._target

def target_history(self, datetime: Optional[python_datetime] = None) -> Target:
"""A :class:`qiskit.transpiler.Target` object for the backend.
Returns:
Target with properties found on `datetime`
"""
self._get_properties(datetime=datetime)
self._get_defaults()
self._convert_to_target()
return self._target

def properties(
self, refresh: bool = False, datetime: Optional[python_datetime] = None
) -> Optional[BackendProperties]:
Expand Down
7 changes: 7 additions & 0 deletions releasenotes/notes/target-history-93e8eca3abf49230.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
features:
- |
Added the method :meth:`~qiskit_ibm_runtime.IBMBackend.target_history`.
This method is similar to :meth:`~qiskit_ibm_runtime.IBMBackend.target`.
The difference is that the new method enables the user to pass a `datetime` parameter,
to retrieve historical data from the backend.