Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rai_swan-0.0.1-py3-none-win_arm64.whl (13.4 MB view details)

Uploaded Python 3Windows ARM64

rai_swan-0.0.1-py3-none-win_amd64.whl (14.2 MB view details)

Uploaded Python 3Windows x86-64

rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl (15.5 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ x86-64

rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl (13.8 MB view details)

Uploaded Python 3manylinux: glibc 2.39+ ARM64

rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl (15.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl (13.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl (11.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl (12.0 MB view details)

Uploaded Python 3macOS 10.15+ x86-64

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

Hashes for rai_swan-0.0.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 4c257bfe5069b8acbb4eb36d5551cc208089ea5320a2a4880a3b9733d0ac6750
MD5 6715184367aec415d466dc980e8f48df
BLAKE2b-256 f0e36219ec5b812a176dd225247c3d91690acb6b9d06f5be179bf851742ad1c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.1-py3-none-win_arm64.whl:

Publisher: PublishWheels.yml on RelationalAI/swan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for rai_swan-0.0.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d4f0ebdbfda8dccf6c72bff6199f0c3453be24ba00aec0dbfad9a38243985467
MD5 812f5d0a7a743bf689cb6429b65608c6
BLAKE2b-256 797fab480359c76664b83c1eb82d35ec057dcf9f84d2c4a842d6463fc7ac5943

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.1-py3-none-win_amd64.whl:

Publisher: PublishWheels.yml on RelationalAI/swan

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 05bb14beab96fe47d5adff2b0d6e0b5e83eed2f95dd198277e23d84ce97fbebc
MD5 f5c258f57c38030f2cd7977a30bb8c30
BLAKE2b-256 35f2e87e006e172fa25439034794ef11e8e3b6474f2f0615e61b375938cff12a

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-manylinux_2_39_aarch64.whl
Algorithm Hash digest
SHA256 f40112107c24b94d03d32c25d7d4fde3707950ad9f80434109cca48f21dec81b
MD5 8a01692db72068e17baee4222a19b806
BLAKE2b-256 895e984466fea858add59d5de9c3b3b8e1ea01359832828ef51d166dfbfcf06f

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bfee84a94b732489a86808cc311eb52677fc3ee76bdc7882cbdbfc5c0043514b
MD5 8a88939d30454caafc0249c25ab50c4d
BLAKE2b-256 e1506a5c97e17b2f43c85af456f8231dec531fd4ce2e722c1e78c224303106af

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b501f34bd9a2ff882b322956876b49775d5bcc20410a1369649e69c31142bc81
MD5 2105b9294f1bb5b60272001b82171b8e
BLAKE2b-256 f49799a047ff023b52d73daebd5b3f3c32135d50f40757db568baa85179731f7

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 389ce5042ef4f7ba7ab4c6d503b4f58e27641d295f026550264bf425850f0528
MD5 0239ffc3b8fe04c500cae3f8f734d5cd
BLAKE2b-256 6af563a1e6dd4d911df18571ce86c6e67755fd76b215d8d7bd55422b4f4c60fe

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.1-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bef595d9b128b251ed14f9c53585e59021757378784e020f962ae14dda66ab48
MD5 934aea37ab5434f889adb2f105d5cf3d
BLAKE2b-256 c63840c93e9cb841b21b0061f673a2311cb5b043adc98e2c9cc296018fea6db3

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page