Validate and translate Logical Query Protocol (LQP) S-expressions into Protobuf
Project description
LQP Python SDK
Python SDK for the Logical Query Protocol (LQP). Provides ProtoBuf bindings, a parser and pretty-printer for the human-readable S-expression syntax, and a CLI for converting between S-expression and ProtoBuf formats.
Installation
The lqp package is available on PyPI. Install it with
uv add lqp
or, equivalently, pip install lqp.
CLI Usage
To run the CLI without installing it into your project, use uvx:
uvx lqp --help
usage: lqp [-h] [-v] [--no-validation] [--out] [--bin | --json | --lqp] input
Parse, validate, and translate LQP files.
positional arguments:
input .lqp or .bin file, or a directory
options:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--no-validation skip validation
--out write output to stdout
--bin write protobuf binary output
--json write protobuf JSON output
--lqp pretty-print LQP output
Examples
lqp --no-validation --bin --json foo/bar.lqp
Will create two files in foo/ named bar.bin and bar.json containing the binary and JSON encodings of the parsed ProtoBuf.
In this case, the parser will not go through the client-side validations we do to check for well-formed LQP.
lqp --bin --json foo
This will look for .lqp files both at the top-level and inside an lqp subdirectory.
Then it will organize the generated binary and JSON into folders, as well as the original found files. So, for example, if foo has this structure:
foo/
| bar.lqp
| lqp/
| | baz.lqp
Then after executing the above command, it should have this structure:
foo/
| bin/
| | bar.bin
| | baz.bin
| json/
| | bar.json
| | baz.json
| lqp/
| | bar.lqp
| | baz.lqp
lqp --bin --out foo.lqp
Will write the ProtoBuf binary parsed from the foo.lqp to stdout. The result can be piped
into the desired output file, e.g., lqp --bin --out foo.lqp > foo.bin.
Development
This project uses uv for dependency management. A uv.lock
file is committed to the repo to ensure reproducible builds. There is no manual setup
required — uv run automatically creates a virtualenv and installs locked dependencies on
first use.
From the repo root, common tasks are available via make:
make test-python # run tests (includes lint + type check)
make test-python-update-snapshots # update test snapshots
make check-python # lint + type check only
make format-python # auto-format with ruff
Or run tools directly from within sdks/python/:
uv run lqp --help # run the lqp CLI from source
uv run python -m pytest # run tests
uv run python -m pytest --snapshot-update # update snapshots
uv run ruff check # lint
uv run ruff format # auto-format
uv run pyrefly check # type check
uv run python -m build # build distribution
To add testcases, add a .lqp file to the top-level tests/lqp directory. New
files get picked up automatically. To generate or update the corresponding output files
(binary, debug mode, and pretty-printing snapshots), run pytest --snapshot-update.
Formatting
The LQP S-expression syntax was chosen to align with that of the Clojure programming language, in order to leverage the existing tools in that ecosystem. LQP syntax should be formatted via cljfmt with the following configuration:
;; .cljfmt.edn
{:indents {#re ".*" [[:inner 0]]}
:remove-surrounding-whitespace? false
:remove-trailing-whitespace? false
:remove-consecutive-blank-lines? false}
This configuration is explained here and simply works better for LQP, which does not have many of the Clojure keywords that are treated as special cases during formatting by default.
See the next section for an easy way to integrate cljfmt into your VSCode workflow.
VSCode
Editing nested S-expressions by hand can get a little tedious, which is why
paredit is an established tool in the Clojure world. To
integrate paredit and cljfmt into your VSCode workflow, just install the Calva
extension and follow the configuration
guide to use the cljfmt configuration pasted
in the previous section.
Out-of-the-box, Calva also runs a Clojure linter, which of course does not know what to do
with LQP, resulting in lots of squiggly lines. For that reason, it is also advisable to
create the following config file at .lsp/config.edn from the project root:
;; .lsp/config.edn
{:linters {:clj-kondo {:level :off}}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lqp-0.5.2.tar.gz.
File metadata
- Download URL: lqp-0.5.2.tar.gz
- Upload date:
- Size: 86.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5ed352574bd7edc3c8098eaa2867a348d10ad562047e0b65ef71de018c6a126
|
|
| MD5 |
833bc758cf10df8849e0e3c225f34478
|
|
| BLAKE2b-256 |
57f9f43608ba0cc8705ebd787da7e4ffdb8d7faffa7eaf27a9d1bc22ec7d8b8a
|
Provenance
The following attestation bundles were made for lqp-0.5.2.tar.gz:
Publisher:
publish-python.yml on RelationalAI/logical-query-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lqp-0.5.2.tar.gz -
Subject digest:
e5ed352574bd7edc3c8098eaa2867a348d10ad562047e0b65ef71de018c6a126 - Sigstore transparency entry: 1327714377
- Sigstore integration time:
-
Permalink:
RelationalAI/logical-query-protocol@6484c767559ff6d3460ece0171cc49de2fdfa28c -
Branch / Tag:
refs/tags/v0.5.2 - Owner: https://github.com/RelationalAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@6484c767559ff6d3460ece0171cc49de2fdfa28c -
Trigger Event:
release
-
Statement type:
File details
Details for the file lqp-0.5.2-py3-none-any.whl.
File metadata
- Download URL: lqp-0.5.2-py3-none-any.whl
- Upload date:
- Size: 82.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec8f5fd57b96d4079430143a629da5c517a241a46cbc7161d0674a0057947a51
|
|
| MD5 |
882a31583d577761cbcae53c3347a8c8
|
|
| BLAKE2b-256 |
de774719e820f207bd62efd365911bdaec206663f3c8e816a404eed6899eabc5
|
Provenance
The following attestation bundles were made for lqp-0.5.2-py3-none-any.whl:
Publisher:
publish-python.yml on RelationalAI/logical-query-protocol
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lqp-0.5.2-py3-none-any.whl -
Subject digest:
ec8f5fd57b96d4079430143a629da5c517a241a46cbc7161d0674a0057947a51 - Sigstore transparency entry: 1327714479
- Sigstore integration time:
-
Permalink:
RelationalAI/logical-query-protocol@6484c767559ff6d3460ece0171cc49de2fdfa28c -
Branch / Tag:
refs/tags/v0.5.2 - Owner: https://github.com/RelationalAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@6484c767559ff6d3460ece0171cc49de2fdfa28c -
Trigger Event:
release
-
Statement type: