Importable bloq manifest#1875
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request makes galois an optional dependency by moving its imports to TYPE_CHECKING blocks and using string annotations. It exposes numerous bloq classes in package __init__.py files, updates the manifest list (BLOQ_CLASS_NAMES and BLOQ_EXAMPLE_OBJECTSTRINGS) to include and enable many previously commented-out bloq examples, and adds a new test (manifest_test.py) to ensure all manifest classes can be imported with minimal dependencies. Additionally, several classes now implement the _pkg_ classmethod to correctly resolve their package names. I have no feedback to provide as there are no review comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another step forwards in having programmatic access to importing bloqs.
In an earlier PR we added the "bloq manifest", which is in
bloqs/manifest.pyand defines two static lists of strings (essentially). The first is a list of all the bloq class names (fully qualified). The bloq classes report their canonical import path with our_pkg_class method, which defaults to one level up from the leaf module the class is defined in. This presumes that we "re-export" our classes one level up. This PR adds a check that the bloq class names from the manifest actually are importable and fixes the failures by re-exporting the import to an__init__.pyor by overriding_pkg_to make it a "local" bloq.The test also compliments the "minimal install" test from #1871 by asserting that everything is at least importable without heavy dependencies except for specific subpackages (galois bloqs need the
galoispackage is the main one)