Skip to content

Commit

Permalink
fix: document JobFailedWithResultsError (#580)
Browse files Browse the repository at this point in the history
* fix: document JobFailedWithResutlsError
  • Loading branch information
kikomiss authored Feb 26, 2024
1 parent 5a5371f commit db9bc9d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion azure-quantum/azure/quantum/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"SessionHost",
"SessionDetails",
"SessionStatus",
"SessionJobFailurePolicy"
"SessionJobFailurePolicy",
"JobFailedWithResultsError"
]
5 changes: 4 additions & 1 deletion azure-quantum/azure/quantum/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ def wait_until_completed(
def get_results(self, timeout_secs: float = DEFAULT_TIMEOUT):
"""Get job results by downloading the results blob from the
storage container linked via the workspace.
Raises :class:`RuntimeError` if job execution fails.
Raises :class:`azure.quantum.job.JobFailedWithResultsError` if job execution fails,
but failure results could still be retrieved (e.g. for jobs submitted against "microsoft.dft" target).
:param timeout_secs: Timeout in seconds, defaults to 300
:type timeout_secs: float
Expand Down
16 changes: 12 additions & 4 deletions azure-quantum/azure/quantum/job/job_failed_with_results_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@
from typing import Any, Dict, Union

class JobFailedWithResultsError(RuntimeError):
"""
Error produced when Job completes with status "Failed" and the Job
"""Error produced when Job completes with status "Failed" and the Job
supports producing failure results.
The failure results can be accessed with get_failure_results() method
The failure results can be accessed with get_failure_results() method.
"""

def __init__(self, message: str, failure_results: Any, *args: object) -> None:
"""Initializes error produced when Job completes with status "Failed" and the Job
supports producing failure results.
:param message: Error message.
:type message: str
:param failure_results: Failure results produced by the job.
:type failure_results: Any
"""

self._set_error_details(message, failure_results)
super().__init__(message, *args)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def get_results(self, timeout_secs: float = DEFAULT_TIMEOUT) -> Dict[str, Any]:
:param timeout_secs: Timeout in seconds, defaults to 300
:type timeout_secs: float
:raises: :class:`RuntimeError` Raises RuntimeError if job execution failed
:raises: :class:`RuntimeError` if job execution failed.
:raises: :class:`azure.quantum.job.JobFailedWithResultsError` if job execution failed,
but failure results could still be retrieved.
:return: Results dictionary with histogram shots, or raw results if not a json object.
"""

Expand Down

0 comments on commit db9bc9d

Please sign in to comment.