Skip to content

New

relationalai.semantics.frontend.base
New(
concept: Concept,
args: Sequence[Any],
kwargs: dict[str, Any],
identity_only: bool = False,
)

Represents a “new entity” statement for a concept.

New objects are produced by Concept.new (and Concept.to_identity) rather than constructed directly. They can be passed to Model.define to create/update an entity, and they can also be used as a value in other statements (for example as the argument to a relationship).

  • concept

    (Concept) - The entity concept being constructed/referred to.
  • args

    (Sequence[Any]) - Optional attached statements and/or schemas (expanded like Concept.new).
  • kwargs

    (dict[str, Any]) - Property/relationship values to set (or to filter by, when used as a lookup).
  • identity_only

    (bool, default: False) - If True, compile as an identity-only lookup (see Concept.to_identity).
>>> from relationalai.semantics import Model
>>> m = Model()
>>> Person = m.Concept("Person")
>>> m.define(Person.new(id=1, name="Alice"))
>>> m.where(Person.id == 1).select(Person.name).to_df()

Most users should not instantiate this class directly. Prefer Concept.new.

NewExpressionVariableDSLBase
 semantics > frontend > base
└──  Concept
    ├──  new
    └──  to_identity
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Build a semantic model
        └──  Define base facts
            └──  Define entities and their properties with Concept.new