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

Use namespace packages for direct connectables #1259

Open
Julian opened this issue Jun 6, 2024 · 0 comments
Open

Use namespace packages for direct connectables #1259

Julian opened this issue Jun 6, 2024 · 0 comments
Labels
internal Non-user-facing improvements

Comments

@Julian
Copy link
Member

Julian commented Jun 6, 2024

We recently added a way to directly connect to an implementation importable from Python.

Specifically, we now support:

bowtie validate -i direct:foo.bar:baz <(printf '{}') <(printf '12')

which means "import foo.bar, and in there is something called baz which is an object Bowtie can use to talk to some implementation, possibly the one called foo.bar". This is meant to support someone writing a Bowtie harness which lives in an arbitrary place on the PYTHONPATH (e.g. me, while developing a new direct harness, or for our integration tests).

We also support shorter "named" direct connectables, which look like:

bowtie validate -i direct:python-jsonschema <(printf '{}') <(printf '12')

where Bowtie internally has some object suitable for talking to python-jsonschema.

While this works fine for just one implementation, if we were to support larger numbers of direct connectables (which I hope to), this will mean that installing Bowtie's python package will install lots of direct connectables, some of which may require heavy binary dependencies -- e.g. if we had one for a rust implementation, that may imply we can only run on platforms with Rust available.

We instead should look into using a namespace package (or a related plugin mechanism) in order to support these connectables.

Specifically: writing direct:python-jsonschema should attempt to import a module called bowtie.direct.python_jsonschema from a namespace package called bowtie.direct. Anyone would then be able to publish to PyPI a package which installs into this namespace, and thereby make a new direct implementation available. Bowtie itself would then not depend on all of them, and would leave up to the user to install whichever ones they wished, though we could also offer a [direct] packaging extra such that doing (uv) pip install bowtie-json-schema[direct] would install many of these dependencies automatically.

Needing resolution as part of doing this would be how to (or if we can sanely) support bowtie filter-implementations --direct as doing so would need to walk the PYTHONPATH potentially importing packages. Though hopefully there is some non-stateful way to filter the list of installed packages by whether they're the appropriate kind of namespace package.

@Julian Julian added the internal Non-user-facing improvements label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Non-user-facing improvements
Projects
None yet
Development

No branches or pull requests

1 participant