From 49711b86550a622bf76bb5fa1c411d6876e2f6ad Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Sun, 8 Oct 2023 14:35:51 -0400 Subject: [PATCH 1/3] use job creation date in properties --- qiskit_ibm_provider/job/ibm_job.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qiskit_ibm_provider/job/ibm_job.py b/qiskit_ibm_provider/job/ibm_job.py index 07455d3d0..9899a7abe 100644 --- a/qiskit_ibm_provider/job/ibm_job.py +++ b/qiskit_ibm_provider/job/ibm_job.py @@ -79,11 +79,14 @@ def properties( datetime: By specifying `datetime`, this function returns an instance of the :class:`BackendProperties` whose timestamp is closest to, but older than, the specified `datetime`. + If not specified, the datetime of the job creation is used. Returns: - The backend properties used for this job, or ``None`` if - properties are not available. + The backend properties used for this job, at the time the job was run, + or ``None`` if properties are not available. """ + if not datetime: + datetime = self.creation_date() return self._backend.properties(refresh, datetime) @abstractmethod From 927a44611374841f453e1976c046d0141c9ce7ff Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Sun, 8 Oct 2023 14:45:10 -0400 Subject: [PATCH 2/3] add reno --- .../job-properties-creation-date-658a3ad4bfcb923b.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/job-properties-creation-date-658a3ad4bfcb923b.yaml diff --git a/releasenotes/notes/job-properties-creation-date-658a3ad4bfcb923b.yaml b/releasenotes/notes/job-properties-creation-date-658a3ad4bfcb923b.yaml new file mode 100644 index 000000000..d7739ce39 --- /dev/null +++ b/releasenotes/notes/job-properties-creation-date-658a3ad4bfcb923b.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + When retrieving the backend properties of a job with + :meth:`~qiskit_ibm_provider.job.IBMJob.properties`, the job creation date is now + used to get the specific backend properties used when the job was run. + From bc99daefc9c68d9bdde256b017b426b4adbf3da9 Mon Sep 17 00:00:00 2001 From: kevin-tian Date: Mon, 9 Oct 2023 11:18:02 -0400 Subject: [PATCH 3/3] remove datetime param --- qiskit_ibm_provider/job/ibm_composite_job.py | 7 ++----- qiskit_ibm_provider/job/ibm_job.py | 12 ++---------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/qiskit_ibm_provider/job/ibm_composite_job.py b/qiskit_ibm_provider/job/ibm_composite_job.py index 7a62650b2..11e1a6038 100644 --- a/qiskit_ibm_provider/job/ibm_composite_job.py +++ b/qiskit_ibm_provider/job/ibm_composite_job.py @@ -374,16 +374,13 @@ def _async_submit(self, sub_job: SubJob) -> None: @_requires_submit def properties( - self, refresh: bool = False, datetime: Optional[python_datetime] = None + self, refresh: bool = False ) -> Optional[Union[List[BackendProperties], BackendProperties]]: """Return the backend properties for this job. Args: refresh: If ``True``, re-query the server for the backend properties. Otherwise, return a cached version. - datetime: By specifying `datetime`, this function returns an instance - of the :class:`BackendProperties` - whose timestamp is closest to, but older than, the specified `datetime`. Note: This method blocks until all sub-jobs are submitted. @@ -401,7 +398,7 @@ def properties( self._properties = [] properties_ts = [] for job in self._get_circuit_jobs(): - props = job.properties(refresh, datetime) + props = job.properties(refresh) if props.last_update_date not in properties_ts: self._properties.append(props) properties_ts.append(props.last_update_date) diff --git a/qiskit_ibm_provider/job/ibm_job.py b/qiskit_ibm_provider/job/ibm_job.py index 9899a7abe..beb860756 100644 --- a/qiskit_ibm_provider/job/ibm_job.py +++ b/qiskit_ibm_provider/job/ibm_job.py @@ -68,26 +68,18 @@ def __init__( # Append suffix to key to avoid conflicts. self._data[key + "_"] = value - def properties( - self, refresh: bool = False, datetime: Optional[python_datetime] = None - ) -> Optional[BackendProperties]: + def properties(self, refresh: bool = False) -> Optional[BackendProperties]: """Return the backend properties for this job. Args: refresh: If ``True``, re-query the server for the backend properties. Otherwise, return a cached version. - datetime: By specifying `datetime`, this function returns an instance - of the :class:`BackendProperties` - whose timestamp is closest to, but older than, the specified `datetime`. - If not specified, the datetime of the job creation is used. Returns: The backend properties used for this job, at the time the job was run, or ``None`` if properties are not available. """ - if not datetime: - datetime = self.creation_date() - return self._backend.properties(refresh, datetime) + return self._backend.properties(refresh, self.creation_date()) @abstractmethod def result(