Skip to content

Commit

Permalink
Merge pull request #19 from Qiskit/feat/use-job-instead-of-get-job-by-id
Browse files Browse the repository at this point in the history
feat: use job instead of get job by id
  • Loading branch information
paaragon authored Oct 22, 2024
2 parents 4045bf7 + 1aee861 commit 738b5d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion qiskit_ibm_catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 "<QiskitFunctionsCatalog>"

Expand Down
20 changes: 19 additions & 1 deletion qiskit_ibm_catalog/serverless.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 "<QiskitServerless>"

Expand Down

0 comments on commit 738b5d2

Please sign in to comment.