Python package and CLI 2.2.0
Queries to unpublished outputs fail in PyRel 2.2.0.
How to install this version
Review the changes below before installing. To install this version, activate a compatible Python virtual environment and run:
python -m pip install "relationalai==2.2.0"For the latest installation instructions, see Install and run PyRel.
Breaking Changes
Section titled “Breaking Changes”-
Model Deployment now raises an
UnpublishedQueryOutputerror when a query reads a result that your model doesn’t publish. For example, say you callGraph.degree()but never attach the result to a concept or use it in a definition. PyRel saves that result only in the model’s internal schema. Earlier versions let queries read this internal copy. To fix the error, attach the result to a concept. Then deploy the model again withrai models deployand query the new property:# Works: attach the result, deploy, and query it.Account.degree = graph.degree()m.select(Account.id, Account.degree).to_df()# Raises UnpublishedQueryOutput: the result isn't attached.degree = graph.degree()count = Integer.ref()m.where(degree(Account, count)).select(Account.id, count).to_df()If you can’t attach a result to a concept, use it in a definition instead. See Expose algorithm results as outputs.
New Features and Enhancements
Section titled “New Features and Enhancements”-
Prescriptive Reasoning and Predictive Reasoning can now use the
MEM_X64_G2_32reasoner size on AWS and Azure. To use it, setReasonerConfig.size. To see which sizes you can use, runrai reasoners sizes. Both features are in Public Preview. Prescriptive Reasoning is available by request. -
New projects that you create with
rai models initno longer include theauto_deploysetting. Projects that already have the setting still work. If you leave it out, it defaults toFalse. If you query a model that isn’t deployed, the error now tells you to runrai models deploy. See Configure deployment. -
Models with many concepts now deploy faster. In one DuckDB test, a model with 480 entities deployed in 16 seconds instead of 31 seconds. Your results may differ.
-
With the SQL Reasoner, queries that join a table to itself and filter by a list now run faster. In one test with 4,000 items, a query took 0.46 seconds instead of 5.04 seconds. This was a single test, and the PyRel query was still slower than the same query in plain SQL.
Bug Fixes
Section titled “Bug Fixes”-
Fixed an issue that caused
rai models listto fail on large Snowflake accounts. The command now checks up to 10,000 matches across your account. It warns you when the list might be incomplete. If you see this warning, a model that isn’t listed might still exist. The--limitoption only controls how many results you see. It doesn’t raise the 10,000-match cap. Some older models that use only tags as their ID might not appear in the list. -
Fixed an issue that caused
aggregates.median()andaggregates.percentile()to fail when you passed a key before the value. These calls now use one value for each key, so repeated values count. For example, say four employees earn 10, 10, 10, and 40. Thenaggregates.median(Employee, Employee.salary)returns 10. Without the key,aggregates.median(Employee.salary)counts each distinct value once and returns 25. Keyed calls also work withAggregate.per(), as inaggregates.percentile(75, Employee, Employee.salary).per(Department). -
Fixed an issue that caused
aggregates.top(),aggregates.bottom(),aggregates.limit(), andaggregates.rank()to return different rows when values were tied. This happened with the SQL Reasoner. These functions now break ties with the values that identify each entity, so the same query returns the same rows. Two cases can still change the results. Floating-point sums that differ only by rounding can change the order. Recursivetopqueries can return more rows than the limit. -
Fixed an issue that caused an
Unknown columnerror when deploying with the SQL Reasoner. This happened when a concept was identified by more than one field. A definition that read a one-field relationship of that concept, such as{Order} is flagged, failed. This bug started in PyRel 2.0.0. -
Fixed an issue that caused a count to return 0 for every entity when a definition compared it with the entity’s own ID. This bug affected the SQL Reasoner in PyRel 2.1.1.
-
Fixed an issue that caused deployment to Snowflake to fail for a definition that filtered grouped aggregates with a union. A union matches rows that meet any of several conditions.
-
Fixed an issue that caused the order of selected columns to change which rows a query returned. This happened with the SQL Reasoner.
-
Fixed an issue that caused a query to return a related value when the relationship needed to reach it didn’t exist. This happened with the SQL Reasoner.
-
Fixed an issue that caused a query to drop an entity that it matched through more than one relationship. This happened when the selected property was missing on one of those relationships. This bug affected the SQL Reasoner.
-
Fixed an issue that caused a query that selects only aggregates to return different results based on column order. Now, if any aggregate has no input values, the query returns no rows. To get a value instead, add a default, such as
aggregates.sum(Employee.salary)| 0.0. This bug affected the SQL Reasoner. -
Fixed an issue that caused definitions to treat
NULLvalues in source tables as real values. The SQL Reasoner now treats them as missing. -
Fixed an issue that caused Model Deployment with the Logic Reasoner to fail for some subtypes. This happened when a subtype inherited an ID made of more than one field. This fix addresses a
KeyErrorreported in PyRel 2.1.1. -
Fixed an issue that caused unclear errors when PyRel couldn’t read a source table or column. The error now explains why. For a missing column, it names the table and lists the columns that PyRel knows about. If that list might be out of date, the error tells you to clear the schema cache. See Declare data sources.
Deprecations and Removals
Section titled “Deprecations and Removals”-
Model Branching is retired in PyRel 2.2.0. Its legacy branches are Snowflake schemas, not source control branches. PyRel now rejects them when you pull or deploy. It doesn’t move them for you. To keep using a model from a legacy branch, deploy the full model to a new standalone schema with
rai models deploy. Then runrai models teardownto remove the legacy branch. -
Your local project might have unfinished work from Model Branching. In that case, PyRel 2.2.0 won’t overwrite your local state file. Instead,
rai models pull --forceandrai models deploy --forcefail. Don’t edit or delete that file.rai doctorreports the state as unsupported. It recommends that you deploy the full model to a new standalone schema.