inspect
relationalai.semantics
Inspect a PyRel model’s schema and rules without an engine connection.
A PyRel Model declares:
- Concepts — entity types (e.g.
Person,Order). Each concept can have identity properties (fromidentify_by=) and other properties (attributes). In the DSL,Propertyis a subclass ofRelationship; both are represented asRelationshipInfowithis_property. - Relationships — multi-valued associations between concepts
(
Customer placed Order). - Tables — external table references (for example Snowflake tables) or
temporary table-like objects backed by in-memory data
(
model.data([...])).TableInfo.loadsshows which concepts a table populates;ConceptInfo.data_sourcesshows the reverse. - Enums — enumeration types (
Priority: LOW, MEDIUM, HIGH). - Rules —
define()andrequire()fragments registered on the model, exposed asRuleInfowith rendered text.
Standalone declarations (not owned by any concept) appear in
bare_relationships on ModelSchema.
Example usage:
from relationalai.semantics import inspect
ms = inspect.schema(model)print(ms) # human-readable summaryms["Person"].identify_by # identity propertiesms["Person"].has_data # True if loaded from a table or model.data()ms.defines # all define() rules as RuleInfoms.to_dict() # JSON-safe dictionary
concept = inspect.to_concept(Person.name) # resolve Chain -> Conceptrefs = inspect.fields(Person.friends) # FieldRefs for select()This module is read-only and frontend-level only — nothing is mutated and no compiler or engine connection is required.
For table-backed concepts (define(Concept.new(table.to_schema()))),
identity properties only appear when identify_by= is passed to the
Concept constructor:
Customer = m.Concept("Customer", identify_by={"C_CUSTKEY": Integer})define(Customer.new(customer_tbl.to_schema()))Without identify_by, all properties are reported as non-identity
properties.
Example output of print(ms):
Model: scheduling=================
Task Identity: id: Integer Properties: name: String priority: Priority Relationships: Worker is assigned to Task
Data Sources: db.tasks -> Task [ID: Integer, NAME: String, PRIORITY: String]
Standalone Declarations: Task costs Float:cost
Enums: Priority: LOW, MEDIUM, HIGH
Defines: (2 rules) ...
Requires: (1 rules) ...Functions
Functions exposed by this module.
schema()Return the complete schema of model as frozen dataclasses.
to_concept()Return the
Concept that obj resolves to.Classes
Classes exposed by this module.
FieldInfoA typed field in a property or relationship.
RelationshipInfoRead-only view of a
Relationship.ConceptInfoRead-only view of a
Concept.TableInfoAn external table reference or a temporary table-like object backed by in-memory data.
EnumInfoAn enumeration type with its members.
RuleInfoA registered
define() or require() rule.ModelSchemaComplete schema of a
Model.Referenced By
RelationalAI Documentation └── Release Notes └── Python API Release Notes └── What’s New in Version 1.24.0 └── New Features and Enhancements