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

Export rust QCS ClientConfiguration to python #235

Merged
merged 46 commits into from Jan 27, 2023

Conversation

jselig-rigetti
Copy link
Contributor

@jselig-rigetti jselig-rigetti commented Jan 19, 2023

Closes #231

Open questions:

  • The info method helps with testing, but one could mistake the output for being serializable when it isn't really. Any thoughts on if we should provide a serialized view of the client, or what should be inspectable by the client?
    Implemented the == operator overload without exposing Debug output.
  • How do we add pyi type stubs for nested submodules? Should everything be exported at the top level? Use https://www.maturin.rs/project_layout.html#mixed-rustpython-project but only have .pyi files.

Copy link
Contributor

@MarquessV MarquessV left a comment

Choose a reason for hiding this comment

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

According to maturin we want a <module_name>.pyi in the root for each module, but it isn't explicit about what to do for submodules. I would try just the module name first to see if that works. If not, maybe try the full module path? Ie. qcs_sdk.my_module.pyi

crates/python/tests/test_client.py Outdated Show resolved Hide resolved
@jselig-rigetti jselig-rigetti marked this pull request as ready for review January 20, 2023 22:48
Copy link
Contributor

@kalzoo kalzoo left a comment

Choose a reason for hiding this comment

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

I don't quite follow this sentence:

The info method helps with testing, but one could mistake the output for being serializable when it isn't really. Any thoughts on if we should provide a serialized view of the client, or what should be inspectable by the client?

Has that already been removed, or am I missing it in review? I think we're okay without serializing the client; it's just a handle on file data anyway (which is a neat serialized format) and there are getters and setters for everything, so I can't think of anything the user would need to do but couldn't.

Overall, this looks good to me, and neat 🗃️ . I'd like to ask for a look from @Shadow53 at the macro invocation for a full approval.

There's also the pyi type hints - I don't have any insight there and would likely just try the same things you are. If nothing else, make sure to clean up any experiments/cruft prior to final review & merge.

Other than that - I'd be happy to approve this.

crates/python/qcs_sdk/qpu/client/__init__.pyi Outdated Show resolved Hide resolved
crates/python/tests/test_client.py Show resolved Hide resolved
crates/python/src/qpu/client.rs Show resolved Hide resolved
Copy link
Contributor

@MarquessV MarquessV left a comment

Choose a reason for hiding this comment

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

Minor comment on the type hints, but looks good!

crates/python/qcs_sdk/qpu/client.pyi Show resolved Hide resolved
Copy link
Contributor

@MarquessV MarquessV left a comment

Choose a reason for hiding this comment

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

🚀

Base automatically changed from 208-return-pyo3-types to main January 24, 2023 19:29
jselig-rigetti and others added 3 commits January 24, 2023 12:31
* chore: add helper for listing qpu names

* chore: mr feedback

* chore: paginate with timeout

* chore: comment update

* Update crates/python/src/api.rs

Co-authored-by: Michael Bryant <mbryant@rigetti.com>

* chore: use tokio timeout

* chore: better error verbiage

* chore: fix imports add test

* chore: use namespacing instead of renaming

* chore: use error converter helper

* chore: remove superfluous gitignore

Co-authored-by: Michael Bryant <mbryant@rigetti.com>
Copy link
Contributor

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

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

The Rust looks good, except for a couple clarifications. There are things to be corrected with the pyi files, though.

I started to comment each instance, but I was basically repeating myself for the same 3-4 things, so I instead left a comment pointing out how a thing should be fixed and then left it as an exercise for the reader to find the others.

I'm open to pairing on this if there are any questions about how the pyi files should be written.

crates/lib/src/api.rs Outdated Show resolved Hide resolved
crates/python/qcs_sdk/__init__.py Outdated Show resolved Hide resolved
crates/python/qcs_sdk/_executable.pyi Outdated Show resolved Hide resolved
crates/python/qcs_sdk/_executable.pyi Outdated Show resolved Hide resolved
crates/python/qcs_sdk/__init__.pyi Outdated Show resolved Hide resolved
crates/python/qcs_sdk/_register_data.pyi Outdated Show resolved Hide resolved
crates/python/qcs_sdk/_register_data.pyi Outdated Show resolved Hide resolved
crates/python/qcs_sdk/api.pyi Outdated Show resolved Hide resolved
crates/python/src/qpu/client.rs Outdated Show resolved Hide resolved
crates/python/qcs_sdk/_executable.pyi Show resolved Hide resolved
Copy link
Contributor

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

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

Left a few notes. The big one is that there are types in the pyi files with @property getters but not setters, but I think they get setters from the macros

crates/python/qcs_sdk/_execution_data.pyi Show resolved Hide resolved
crates/python/src/executable.rs Outdated Show resolved Hide resolved
crates/python/src/executable.rs Outdated Show resolved Hide resolved
crates/python/tests/test_api.py Outdated Show resolved Hide resolved
Copy link
Contributor

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

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

A couple more places that might need setters in pyi, and a question whether a type can be a pyclass instead of a wrapped type.

crates/python/qcs_sdk/api.pyi Show resolved Hide resolved
crates/python/qcs_sdk/qpu/quilc.pyi Show resolved Hide resolved
crates/python/src/qpu/client.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Shadow53 Shadow53 left a comment

Choose a reason for hiding this comment

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

LGTM

@jselig-rigetti jselig-rigetti merged commit 39c878f into main Jan 27, 2023
@jselig-rigetti jselig-rigetti deleted the 231-qcs-client-config branch January 27, 2023 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export rust QCS ClientConfiguration to python
4 participants