-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Return a single results object instead of always a list - IonQ #7285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
assert service.remote_host == 'http://example.com' | ||
|
||
|
||
def test_service_run_unwraps_single_result_list(): |
There was a problem hiding this comment.
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?
@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. |
There was a problem hiding this 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
There was a problem hiding this 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?
@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 ) |
@Cynocracy Do we have a consensus as to whether to proceed on this change? |
@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? |
I believe this change is still missing documentation as per the previous comment by @Cynocracy |
@splch do you still want to move forward with this PR? |
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. |
hi @dstrain115 yes this is still something we want to do! sorry about the delay. ill get to documenting and resolving merge conflicts :) |
@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. |
docs/hardware/ionq/jobs.md
Outdated
> **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`.) | ||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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 …
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