Skip to content
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

Make PrimitiveJob serializable #12963

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

kt474
Copy link
Member

@kt474 kt474 commented Aug 15, 2024

Summary

In qiskit-ibm-runtime we want to add job methods to our QiskitRuntimeLocalService (Issue Qiskit/qiskit-ibm-runtime#1607). In order to save PrimitiveJob objects locally we need a way to serialize them. It's currently not serializable due to the use of ThreadPoolExecutor:

executor = ThreadPoolExecutor(max_workers=1) # pylint: disable=consider-using-with
self._future = executor.submit(self._function, *self._args, **self._kwargs)

Credit to @t-imamichi

Details and comments

@kt474 kt474 requested review from a team as code owners August 15, 2024 17:23
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core
  • @ajavadia
  • @levbishop
  • @t-imamichi

@@ -93,9 +93,6 @@ def __init__(self, *, shape: ShapeInput = (), **data):
def __len__(self):
return len(self._data)

def __setattr__(self, *_):
raise NotImplementedError

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it ok to remove this? This __setattr__ is preventing the serialization of the job result

Copy link
Member

Choose a reason for hiding this comment

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

Could you answer the question, @ihincks?

Copy link
Member

Choose a reason for hiding this comment

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

#12787 asked the same question.

@coveralls
Copy link

coveralls commented Aug 15, 2024

Pull Request Test Coverage Report for Build 10423431976

Details

  • 15 of 21 (71.43%) changed or added relevant lines in 1 file are covered.
  • 8 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 89.582%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/primitives/primitive_job.py 15 21 71.43%
Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.02%
crates/qasm2/src/lex.rs 1 92.73%
crates/qasm2/src/parse.rs 6 97.15%
Totals Coverage Status
Change from base Build 10423065630: 0.02%
Covered Lines: 67600
Relevant Lines: 75462

💛 - Coveralls

@t-imamichi t-imamichi added mod: primitives Related to the Primitives module Changelog: New Feature Include in the "Added" section of the changelog labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: primitives Related to the Primitives module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants