How relationalai/rai-sdk-python works
Project Type and Purpose
• This is an open-source Python SDK (“rai-sdk”) that exposes RelationalAI’s REST (and gRPC) APIs to Python developers. It provides both:
• Core “railib” modules for talking to RAI, handling configuration, credentials, protobuf messages, HTTP/gRPC transport, and convenience commands (“show”).
• A Snowflake-integration subpackage (relationalai-sdk-snowflake) to embed the SDK into Snowflake UDFs or pipelines.
• The SDK is packaged via setuptools/pyproject and published to PyPI. Top‐level folders include: examples (stand-alone usage), railib (core library), relationalai-sdk-snowflake (Snowflake extension), tests, CI/CD workflows, and config templates.
File Structure Analysis
• Top-level modules:
• railib/: core Python package
– api.py – high-level client calls
– rest.py – HTTP wrapper
– pb/ – protobuf definitions and generated code
– credentials.py – OAuth or API-key loader
– config.py – INI-style config parser
– show.py – CLI helper for printing results
• relationalai-sdk-snowflake/: separate package embedding railib in Snowflake UDF context
• examples/: ~60 stand-alone scripts demonstrating each API endpoint
• test/: unit and integration tests
• CI/CD (.github/), packaging (setup.py, pyproject.toml), and config.spec
README Insights
• Primary communication is over REST (HTTPS) by default, with optional gRPC via generated protobufs.
• SDK reads credentials/config from ~/.rai/config.
• Example scripts simply instantiate railib.API() and call methods like list_engines(), execute(), etc.