Skip to content

Commit

Permalink
fix: produce the entire job result for microsoft.dft target + Job doc…
Browse files Browse the repository at this point in the history
… fix (#577)

* fix: return original DFT job result + doc fixes
  • Loading branch information
kikomiss authored Feb 22, 2024
1 parent 85babe2 commit 2f1db3d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions azure-quantum/azure/quantum/job/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def wait_until_completed(
:type timeout_secs: int
:param print_progress: Print "." to stdout to display progress
:type print_progress: bool
:raises TimeoutError: If the total poll time exceeds timeout, raise
:raises: :class:`TimeoutError` If the total poll time exceeds timeout, raise.
"""
self.refresh()
poll_wait = Job._default_poll_wait
Expand All @@ -106,10 +106,12 @@ 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.
:param timeout_secs: Timeout in seconds, defaults to 300
:type timeout_secs: float
:raises RuntimeError: Raises RuntimeError if job execution failed
:return: Results dictionary with histogram shots, or raw results if not a json object.
:rtype: Any
"""
if self.results is not None:
return self.results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ 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 RuntimeError: Raises RuntimeError if job execution failed
:raises: :class:`RuntimeError` Raises RuntimeError if job execution failed
:return: Results dictionary with histogram shots, or raw results if not a json object.
"""

try:
job_results = super().get_results(timeout_secs)
return job_results["results"]
return job_results
except JobFailedWithResultsError as e:
failure_results = e.get_failure_results()
if MicrosoftElementsDftJob._is_dft_failure_results(failure_results):
Expand Down
2 changes: 1 addition & 1 deletion azure-quantum/tests/unit/test_microsoft_elements_dft.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_dft_success(self):

results = job.get_results(timeout_secs=DEFAULT_TIMEOUT_SECS)
self.assertIsNotNone(results)
self.assertIsNotNone(results[0]["return_result"])
self.assertIsNotNone(results["results"][0]["return_result"])

@pytest.mark.microsoft_elements_dft
def test_dft_failure_invalid_input(self):
Expand Down

0 comments on commit 2f1db3d

Please sign in to comment.