From 1aee8610fd17d0dfab773148efa8c24c0cb284ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Arag=C3=B3n?= Date: Mon, 21 Oct 2024 12:36:38 +0200 Subject: [PATCH] feat: use job instead of get job by id --- qiskit_ibm_catalog/catalog.py | 20 +++++++++++++++++++- qiskit_ibm_catalog/serverless.py | 20 +++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qiskit_ibm_catalog/catalog.py b/qiskit_ibm_catalog/catalog.py index 9122510..f37ae8e 100644 --- a/qiskit_ibm_catalog/catalog.py +++ b/qiskit_ibm_catalog/catalog.py @@ -21,6 +21,7 @@ from __future__ import annotations from typing import Optional, List +import warnings from qiskit_ibm_runtime import QiskitRuntimeService from qiskit_serverless.core.client import IBMServerlessClient @@ -100,7 +101,7 @@ def jobs(self, **kwargs) -> List[Job]: **{**kwargs, **{"filter": self.PRE_FILTER_KEYWORD}} ) - def get_job_by_id(self, job_id: str) -> Optional[Job]: + def job(self, job_id: str) -> Optional[Job]: """Returns job by id. Args: @@ -111,6 +112,23 @@ def get_job_by_id(self, job_id: str) -> Optional[Job]: """ return self._client.get_job_by_id(job_id=job_id) + def get_job_by_id(self, job_id: str) -> Optional[Job]: + """Returns job by id. + + Args: + job_id (str): job id + + Returns: + Job: job + """ + warnings.warn( + "`get_job_by_id` method has been deprecated. " + "And will be removed in future releases. " + "Please, use `job` instead.", + DeprecationWarning, + ) + return self.job(job_id=job_id) + def __repr__(self) -> str: return "" diff --git a/qiskit_ibm_catalog/serverless.py b/qiskit_ibm_catalog/serverless.py index d2e61c3..72ec7d4 100644 --- a/qiskit_ibm_catalog/serverless.py +++ b/qiskit_ibm_catalog/serverless.py @@ -22,6 +22,7 @@ from __future__ import annotations from typing import Optional, List +import warnings from qiskit_ibm_runtime import QiskitRuntimeService from qiskit_serverless.core.client import IBMServerlessClient @@ -116,7 +117,7 @@ def jobs(self, **kwargs) -> List[Job]: **{**kwargs, **{"filter": self.PRE_FILTER_KEYWORD}} ) - def get_job_by_id(self, job_id: str) -> Optional[Job]: + def job(self, job_id: str) -> Optional[Job]: """Returns job by id. Args: @@ -127,6 +128,23 @@ def get_job_by_id(self, job_id: str) -> Optional[Job]: """ return self._client.get_job_by_id(job_id=job_id) + def get_job_by_id(self, job_id: str) -> Optional[Job]: + """Returns job by id. + + Args: + job_id (str): job id + + Returns: + Job: Job + """ + warnings.warn( + "`get_job_by_id` method has been deprecated. " + "And will be removed in future releases. " + "Please, use `job` instead.", + DeprecationWarning, + ) + return self.job(job_id=job_id) + def __repr__(self) -> str: return ""