pasqal-io / Pulser

Library for pulse-level/analog control of neutral atom devices. Emulator with QuTiP.
Apache License 2.0
182 stars 65 forks source link

[FEAT] Handle batches with partial results #707

Closed MatthieuMoreau0 closed 2 months ago

MatthieuMoreau0 commented 4 months ago

Currently if one of the job of a batch fails, it is impossible to retrieve the results for any jobs of the batch - this raises an exception. In this PR, I suggest instead to add None to the list of results for that submission when a job has no results. I don't know if returning None is the most idiomatic way to do this in pulser; I also contemplated creating a new subclass of Result called EmptyResult but I wanted to gather some feedback before going for that because it would imply some refactoring of the Result class and I'm not entirely convinced it would bring much.

HGSilveri commented 4 months ago

I don't know if returning None is the most idiomatic way to do this in pulser; I also contemplated creating a new subclass of Result called EmptyResult but I wanted to gather some feedback before going for that because it would imply some refactoring of the Result class and I'm not entirely convinced it would bring much.

I was thinking of something along those lines too, I think it would be better than None. I also considered having PendingResult for distinguishing pending jobs from failed ones but that's maybe beyond the scope of this PR.

HGSilveri commented 2 months ago

I think we both agree that the current format that we use to return results is limiting us and that there doesn't seem to be a nice way to include partial results within it. As such, I would propose we add an alternative, more flexible method to RemoteResults instead. I was thinking of something along the lines of

RemoteResults.get_available_results() -> dict[JobId, Result]:

This would give the user a workaround when something failed in the traditional method. We could also point the user to this alternative method through the error message. What do you think about this @MatthieuMoreau0 ?