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.2-py3-none-win_arm64.whl (13.4 MB view details)

Uploaded Python 3Windows ARM64

rai_swan-0.0.2-py3-none-win_amd64.whl (14.4 MB view details)

Uploaded Python 3Windows x86-64

rai_swan-0.0.2-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.2-py3-none-manylinux_2_28_aarch64.whl (13.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

rai_swan-0.0.2-py3-none-macosx_11_0_arm64.whl (11.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

rai_swan-0.0.2-py3-none-macosx_10_15_x86_64.whl (12.2 MB view details)

Uploaded Python 3macOS 10.15+ x86-64

File details

Details for the file rai_swan-0.0.2-py3-none-win_arm64.whl.

File metadata

  • Download URL: rai_swan-0.0.2-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.2-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 e6c7184e89d91ee4e226159201c6134e8c2b8c709b0d0c44d58785e5311f5d4b
MD5 c40d0c04f8d626245c617f9ceab06fdb
BLAKE2b-256 17b2ee8ca745c94bf1600f1d37149ab7c7ea66c5a574dd9e769f2e057d24abae

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: rai_swan-0.0.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 14.4 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.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0a4efecc7d0c8bfdc5bf8f71ee105bacec7ee97f3518227d79f16e36cd82a891
MD5 1ba8fc8bd65aca882f4d585f317562ea
BLAKE2b-256 687a920241d3224a4f4e9bbca11ccc5c513430f32507d38e77ddf48653e3472c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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.2-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.2-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ec4c9016a3cb2c6f0378e1ed0a035c2d716b41212f4775a6d4a8e6fa2bd7e6e6
MD5 1be5e3755641baa9a95a9b275d0d8c52
BLAKE2b-256 0d753975abecc8e7021018aedf53424850ed4e2962fb1f76ffb482c3e564e908

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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.2-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.2-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a0a222600c06c7f47b6e92cd9accb5cde7633975d216109c575777a942161f70
MD5 bedbdc9ec7fec67707905a2b692c8184
BLAKE2b-256 05e147b1868cf6498e0fdfd05099e227f6bd2e5dd3c17bb9548d15953f75dd2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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.2-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c3c9fd7516d1bc4a757615b66ea9d32685f26421e5666132b525a0f25fdd63c
MD5 ec0f383b417769417a517fb533962cba
BLAKE2b-256 174ff4e1fc7846847a9d49a78dffd00c9e07a88ede54e68de67253c0c8e9d4b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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.2-py3-none-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rai_swan-0.0.2-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 083e19fc604b17e38add81b4ad394a4c59e029356aa756ad6724cbdb4c4c88ca
MD5 a72640e140c56b7d12261a768ae37f74
BLAKE2b-256 900302e37a52da2ef13ad65087f1a7cb96de367fbba200f43aae1f9fdc7002da

See more details on using hashes here.

Provenance

The following attestation bundles were made for rai_swan-0.0.2-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