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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

rai_swan-0.0.3-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.3-py3-none-win_arm64.whl.

File metadata

  • Download URL: rai_swan-0.0.3-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.3-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 0941bd374f896ed07cca45fdfbe5a7908b007c7ebc7caafde718a51f7071dbac
MD5 04288d8c6fdce95f6b444b6cc5c3519d
BLAKE2b-256 34d53915fa62ea5dd78817064abdb65f908e88c48055f3c478c965cf4b0d6ea9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rai_swan-0.0.3-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.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 46bc710eef9accdd79495829d5c38b11682e517807757c47c13701adf156e8c0
MD5 7c7643cb4c3dc3134d1b2c9ca2f7144b
BLAKE2b-256 177c22349b08fc77e4a98b07aae1d6af07230fa1423b37a5c709297bc9f0dcb1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rai_swan-0.0.3-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 121cda35f3da166d23d0254682e6a8be3bab10d23dbca9e511a253ef2a71eb5e
MD5 a4ce346329648195e64bddc98e9bc093
BLAKE2b-256 b58011c671691fe797ba9c500085d6aea48ea2e5f3cec8f5e014a95d959d1d55

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rai_swan-0.0.3-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4f346cc372152936b1b4660caadc6895a75ed858aa7c9b4745ef3de95d047936
MD5 e02df1c09d1541979d43239cb648bb6b
BLAKE2b-256 ccf6c5274b28dd5061fbd4e09171c3ffbe9cc7b17a4d980223164169ffc9f415

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rai_swan-0.0.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d86da65080fc00fcf02fa787c013db24e687441b9443131f70159946f968b1d
MD5 a5898ac2561ba5762d9207d1eae0756f
BLAKE2b-256 165ff47d2fc967cb34a21d2947d06ee342cfca74f887d7ccc49261737ad108ab

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rai_swan-0.0.3-py3-none-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 41243f6a2e47a85c038961a7d7b755acd161ff8d421ec5bc631ababec560b0b3
MD5 bcb9d5339b5f55903f396598731ab376
BLAKE2b-256 55ad15e02e9e5c950d0c619140393f5bb6ff83003ae8c08871d3d27b667ef49a

See more details on using hashes here.

Provenance

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