Skip to content

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:

Terminal window
python -m pip install "relationalai==2.2.0"

For the latest installation instructions, see Install and run PyRel.

  • Model Deployment now raises an UnpublishedQueryOutput error when a query reads a result that your model doesn’t publish. For example, say you call Graph.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 with rai models deploy and 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.

  • Prescriptive Reasoning and Predictive Reasoning can now use the MEM_X64_G2_32 reasoner size on AWS and Azure. To use it, set ReasonerConfig.size. To see which sizes you can use, run rai reasoners sizes. Both features are in Public Preview. Prescriptive Reasoning is available by request.

  • New projects that you create with rai models init no longer include the auto_deploy setting. Projects that already have the setting still work. If you leave it out, it defaults to False. If you query a model that isn’t deployed, the error now tells you to run rai 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.

  • Fixed an issue that caused rai models list to 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 --limit option 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() and aggregates.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. Then aggregates.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 with Aggregate.per(), as in aggregates.percentile(75, Employee, Employee.salary).per(Department).

  • Fixed an issue that caused aggregates.top(), aggregates.bottom(), aggregates.limit(), and aggregates.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. Recursive top queries can return more rows than the limit.

  • Fixed an issue that caused an Unknown column error 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 NULL values 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 KeyError reported 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.