Skip to content

Conversation

splch
Copy link
Contributor

@splch splch commented Apr 18, 2025

ionq results api can return a list of results or a single result, so this change allows for either a list or single element to be returned from the results endpoint

@splch splch requested review from a team, dabacon and vtomole as code owners April 18, 2025 21:04
Copy link

codecov bot commented Apr 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.38%. Comparing base (34f1f99) to head (23ce8a9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7285   +/-   ##
=======================================
  Coverage   99.38%   99.38%           
=======================================
  Files        1089     1089           
  Lines       97551    97583   +32     
=======================================
+ Hits        96950    96982   +32     
  Misses        601      601           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

assert service.remote_host == 'http://example.com'


def test_service_run_unwraps_single_result_list():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a test for the correctness of the order of multiple results being returned?

@mhucka
Copy link
Contributor

mhucka commented Apr 24, 2025

@splch Thank you for this work!

Could you let us know the status of this? For example, there was the comment from @Cynocracy to add a test, but it's not immediately clear if that was resolved.

Copy link
Contributor

@Cynocracy Cynocracy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new run batch preserves order test covers what I was hoping for :) lgtm

Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this cause any backwards incompatibility for programs people have already written?

@mhucka mhucka added kind/health For CI/testing/release process/refactoring/technical debt items interface/cirq-ionq labels Apr 29, 2025
@mhucka mhucka changed the title return a single results object instead of always a list - IonQ Return a single results object instead of always a list - IonQ Apr 29, 2025
@Cynocracy
Copy link
Contributor

@dstrain115 this is a good question. The answer is unfortunately yes, but it's attempting to revert a change in interface caused by #6652 (which made it so that jobs that previously returned a single Result were returning an Iterable of them). FWIW, I am conflicted on whether it makes sense to change back, as imo, both changes are somewhat burdensome to users.

@mhucka
Copy link
Contributor

mhucka commented Apr 30, 2025

@dstrain115 this is a good question. The answer is unfortunately yes, but it's attempting to revert a change in interface caused by #6652 (which made it so that jobs that previously returned a single Result were returning an Iterable of them). FWIW, I am conflicted on whether it makes sense to change back, as imo, both changes are somewhat burdensome to users.

Is there a way to consult users (perhaps some especially major users) and ask them for their input? (I guess this is a question for @Cynocracy )

@github-actions github-actions bot added the size: M 50< lines changed <250 label Apr 30, 2025
@dstrain115
Copy link
Collaborator

@Cynocracy Do we have a consensus as to whether to proceed on this change?
(Regarding previous comment: "FWIW, I am conflicted on whether it makes sense to change back")
If there is backwards incompatibility, maybe we can at least document it so users are aware?

@Cynocracy
Copy link
Contributor

@dstrain115 Documenting sounds like a good strategy to me here. Sorry for the lack of response, we've been trying to reach out to users to get some feedback, but we've been somewhat delayed by other priorities.

@splch would you mind adding documentation for the (previous) change to our docs?

@dstrain115
Copy link
Collaborator

I believe this change is still missing documentation as per the previous comment by @Cynocracy

@mhucka mhucka self-assigned this Aug 6, 2025
@Cynocracy
Copy link
Contributor

@splch do you still want to move forward with this PR?

@pavoljuhas pavoljuhas self-assigned this Sep 12, 2025
@dstrain115
Copy link
Collaborator

@Cynocracy @spich

Checking in on this PR since it seems to have stalled out. Is this still something we want to do? I think it was almost ready to go pending some documentation tweaks and confirmation from IonQ side.

@splch
Copy link
Contributor Author

splch commented Oct 9, 2025

hi @dstrain115 yes this is still something we want to do! sorry about the delay. ill get to documenting and resolving merge conflicts :)

@mhucka mhucka moved this to Nudged again in Follow-up tracker Oct 9, 2025
@mhucka
Copy link
Contributor

mhucka commented Oct 9, 2025

@splch There's also a cirq-ionq issue at #5216 that we were wondering about. It's unrelated to this PR, but if you're doing work on cirq-ionq and have a few moment to look at that, we'd welcome your input. It's not clear to us whether the issue still exists, so ti might be a very quick matter of just closing the issue.

@github-actions github-actions bot added size: L 250< lines changed <1000 and removed size: M 50< lines changed <250 labels Oct 9, 2025
Comment on lines 118 to 130
> **Note - result shape of `Job.results()`:** For jobs created from a **single circuit**,
> `job.results()` returns a **single** `ionq.QPUResult` or `ionq.SimulatorResult`.
> For **batch** jobs, it returns a **list** of those results. To write code that
> works with either shape:
>
> ```python
> r = job.results()
> results_list = r if isinstance(r, list) else [r]
> ```
>
> Each entry can be converted to a `cirq.Result` via `.to_cirq_result(...)`.
> (`Service.run(...)` continues to return a single `cirq.Result`.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@splch I know this PR was approved, but before merging, I wanted to check if the use of a Markdown blockquote is intentional here. The result in the formatted output is not great (e.g., it has hard line breaks). I would prefer to see this without the blockquote (i.e., without the leading > characters) unless I'm missing something.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mhucka - if it is just a matter of markdown appearance and you have a simple fix, feel free to push such change here and merge. We can always adjust if @splch has a strong preference for the current format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sounds good - I was going for a note-looking block but I'm happy to change it to normal formatting :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sounds good - I was going for a note-looking block but I'm happy to change it to normal formatting :)

Lemme see if something can be done to keep that aspect yet avoid the hard newlines …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interface/cirq-ionq kind/health For CI/testing/release process/refactoring/technical debt items size: L 250< lines changed <1000

Projects

Status: Nudged again

Development

Successfully merging this pull request may close these issues.

5 participants