Private python package for RelationalAI Swan semantic reasoner on DuckDB. See https://relationalai.github.io/swan for documentation.
Project description
Swan
Swan is a semantic modeling and query optimization framework for DuckDB. It lets you define database constraints, schemas, advanced algebraic properties (such as symmetry, transitivity, equivalence, and disjointness), and mathematical optimization problems (LP/MIP via the HiGHS solver) as an executable semantic layer.
Unlike passive metadata catalogs, Swan's semantic definitions are actively compiled and enforced:
- Python Client-Side AST Rewrite Passes: Declarative PyRel queries are automatically analyzed and rewritten to prune logical contradictions, optimize optional matches, push down filters, swap symmetric traversals, and materialize shared query blocks.
- C++ Native Optimizer Extension: Integrates directly with DuckDB's query compilation pipeline to dynamically inject check constraints, eliminate redundant joins, and replace expensive recursive joins with custom physical structures (like connected components and transitive reachability indexes).
- Prescriptive Reasoner (HiGHS Integration): Formulates mathematical optimization problems directly over database records, compiling variables, bounds, and indicator constraints to DuckDB C++ queries for native execution speed.
- Predictive Reasoner (GNN + ONNX Runtime): Trains Graph Neural Networks over graph-structured database records and serves predictions natively in DuckDB, with built-in explainability for feature/edge importance and attention weights.
By treating semantics as executable code, Swan compiles highly-declarative traversals into ultra-efficient, vectorized SQL executions.
Installation
pip install rai-swan
This automatically detects your operating system and CPU architecture and downloads the matching prebuilt wheel (Linux x86_64/ARM64, macOS Intel/Apple Silicon, Windows x64) -- no compiler required.
Verify the install (this also loads the bundled native extension):
from pyrel_duckdb import Model
model = Model()
print("Swan successfully initialized!")
Quick Start
import duckdb
from pyrel_duckdb import Model, String
con = duckdb.connect("my_database.db", config={"allow_unsigned_extensions": "true"})
model = Model(name="my_model", connection=con)
# Declare a concept (maps to a physical table) with an identity scheme (primary key)
Customer = model.Concept("Customer", identify_by={"name": String})
See the full documentation for modeling concepts/properties/relationships, rules and constraints, graph algorithms, and the prescriptive/predictive reasoners.
Documentation
Full guides, API reference, and build templates: https://relationalai.github.io/swan
License
Proprietary -- see LICENSE for the terms under which the compiled distributions of this package may be used.
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 Distributions
Built Distributions
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 rai_swan-0.0.1-py3-none-win_arm64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-win_arm64.whl
- Upload date:
- Size: 13.4 MB
- Tags: Python 3, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c257bfe5069b8acbb4eb36d5551cc208089ea5320a2a4880a3b9733d0ac6750
|
|
| MD5 |
6715184367aec415d466dc980e8f48df
|
|
| BLAKE2b-256 |
f0e36219ec5b812a176dd225247c3d91690acb6b9d06f5be179bf851742ad1c3
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-win_arm64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-win_arm64.whl -
Subject digest:
4c257bfe5069b8acbb4eb36d5551cc208089ea5320a2a4880a3b9733d0ac6750 - Sigstore transparency entry: 2277917409
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-win_amd64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-win_amd64.whl
- Upload date:
- Size: 14.2 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4f0ebdbfda8dccf6c72bff6199f0c3453be24ba00aec0dbfad9a38243985467
|
|
| MD5 |
812f5d0a7a743bf689cb6429b65608c6
|
|
| BLAKE2b-256 |
797fab480359c76664b83c1eb82d35ec057dcf9f84d2c4a842d6463fc7ac5943
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-win_amd64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-win_amd64.whl -
Subject digest:
d4f0ebdbfda8dccf6c72bff6199f0c3453be24ba00aec0dbfad9a38243985467 - Sigstore transparency entry: 2257610091
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@7310a86ed3812b170b6dd4a5d2354533b16265df -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@7310a86ed3812b170b6dd4a5d2354533b16265df -
Trigger Event:
push
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 15.5 MB
- Tags: Python 3, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05bb14beab96fe47d5adff2b0d6e0b5e83eed2f95dd198277e23d84ce97fbebc
|
|
| MD5 |
f5c258f57c38030f2cd7977a30bb8c30
|
|
| BLAKE2b-256 |
35f2e87e006e172fa25439034794ef11e8e3b6474f2f0615e61b375938cff12a
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl -
Subject digest:
05bb14beab96fe47d5adff2b0d6e0b5e83eed2f95dd198277e23d84ce97fbebc - Sigstore transparency entry: 2257609937
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@7310a86ed3812b170b6dd4a5d2354533b16265df -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@7310a86ed3812b170b6dd4a5d2354533b16265df -
Trigger Event:
push
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl
- Upload date:
- Size: 13.8 MB
- Tags: Python 3, manylinux: glibc 2.39+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f40112107c24b94d03d32c25d7d4fde3707950ad9f80434109cca48f21dec81b
|
|
| MD5 |
8a01692db72068e17baee4222a19b806
|
|
| BLAKE2b-256 |
895e984466fea858add59d5de9c3b3b8e1ea01359832828ef51d166dfbfcf06f
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl -
Subject digest:
f40112107c24b94d03d32c25d7d4fde3707950ad9f80434109cca48f21dec81b - Sigstore transparency entry: 2257610162
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@7310a86ed3812b170b6dd4a5d2354533b16265df -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@7310a86ed3812b170b6dd4a5d2354533b16265df -
Trigger Event:
push
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 15.7 MB
- Tags: Python 3, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfee84a94b732489a86808cc311eb52677fc3ee76bdc7882cbdbfc5c0043514b
|
|
| MD5 |
8a88939d30454caafc0249c25ab50c4d
|
|
| BLAKE2b-256 |
e1506a5c97e17b2f43c85af456f8231dec531fd4ce2e722c1e78c224303106af
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl -
Subject digest:
bfee84a94b732489a86808cc311eb52677fc3ee76bdc7882cbdbfc5c0043514b - Sigstore transparency entry: 2277917431
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 13.9 MB
- Tags: Python 3, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b501f34bd9a2ff882b322956876b49775d5bcc20410a1369649e69c31142bc81
|
|
| MD5 |
2105b9294f1bb5b60272001b82171b8e
|
|
| BLAKE2b-256 |
f49799a047ff023b52d73daebd5b3f3c32135d50f40757db568baa85179731f7
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl -
Subject digest:
b501f34bd9a2ff882b322956876b49775d5bcc20410a1369649e69c31142bc81 - Sigstore transparency entry: 2277917507
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@e14511c8fc1b6a77874169b5f0d2059b0c1f055b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 11.3 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
389ce5042ef4f7ba7ab4c6d503b4f58e27641d295f026550264bf425850f0528
|
|
| MD5 |
0239ffc3b8fe04c500cae3f8f734d5cd
|
|
| BLAKE2b-256 |
6af563a1e6dd4d911df18571ce86c6e67755fd76b215d8d7bd55422b4f4c60fe
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl -
Subject digest:
389ce5042ef4f7ba7ab4c6d503b4f58e27641d295f026550264bf425850f0528 - Sigstore transparency entry: 2257609996
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@7310a86ed3812b170b6dd4a5d2354533b16265df -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@7310a86ed3812b170b6dd4a5d2354533b16265df -
Trigger Event:
push
-
Statement type:
File details
Details for the file rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl.
File metadata
- Download URL: rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl
- Upload date:
- Size: 12.0 MB
- Tags: Python 3, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bef595d9b128b251ed14f9c53585e59021757378784e020f962ae14dda66ab48
|
|
| MD5 |
934aea37ab5434f889adb2f105d5cf3d
|
|
| BLAKE2b-256 |
c63840c93e9cb841b21b0061f673a2311cb5b043adc98e2c9cc296018fea6db3
|
Provenance
The following attestation bundles were made for rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl:
Publisher:
PublishWheels.yml on RelationalAI/swan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl -
Subject digest:
bef595d9b128b251ed14f9c53585e59021757378784e020f962ae14dda66ab48 - Sigstore transparency entry: 2257610050
- Sigstore integration time:
-
Permalink:
RelationalAI/swan@7310a86ed3812b170b6dd4a5d2354533b16265df -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/RelationalAI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
PublishWheels.yml@7310a86ed3812b170b6dd4a5d2354533b16265df -
Trigger Event:
push
-
Statement type: