kapps_ogm.mapping.class_spec#

class kapps_ogm.mapping.class_spec.ClassHydrationLevel(*values)[source]#

Bases: Enum

REFERENCE = 'reference'#
SCOPE = 'scope'#
FULL = 'full'#
class kapps_ogm.mapping.class_spec.ClassSpec(iri: 'Optional[IRI]', label: 'Optional[str]' = None, comment: 'Optional[str]' = None, properties: 'Dict[IRI, PropertySpec]'=<factory>, types: 'List[IRI]' = <factory>, superclasses: 'List[IRI]' = <factory>, pydantic_base_model: 'Optional[Type[pd.BaseModel]]' = <class 'pydantic.main.BaseModel'>, metadata: 'Dict[str, Any]'=<factory>, hydration_level: 'ClassHydrationLevel' = <ClassHydrationLevel.REFERENCE: 'reference'>)[source]#

Bases: object

iri: IRI | None#
label: str | None = None#
comment: str | None = None#
properties: Dict[IRI, PropertySpec]#
types: List[IRI]#
superclasses: List[IRI]#
pydantic_base_model#

alias of BaseModel

metadata: Dict[str, Any]#
hydration_level: ClassHydrationLevel = 'reference'#
to_string() → str[source]#
property hydrated: bool#

Whether this ClassSpec has been fully hydrated from the ontology.

hydrate(ogm: OGM) → ClassSpec[source]#

Populate this ClassSpec with all details from the ontology. Uses specify internally and updates this instance in place. Returns self

to_pydantic_model() → Type[BaseModel][source]#

Convert ClassSpec into a Pydantic model. Delegates to PropertySpec.to_pydantic_field() for consistent field generation.

classmethod specify_from_instance(model_cls: Type[pd.BaseModel], instance: pd.BaseModel, ogm: OGM, hydration_level: ClassHydrationLevel) → ClassSpec[source]#

create a ClassSpec for the given Pydantic model by analyzing its RDF data in the GraphDB via the OGM instance.

Args:

model_cls: The Pydantic model class to specify ogm: The OGM instance with access to the GraphDB

Returns:

A ClassSpec instance representing the class specification

classmethod specify(class_iri: IRI, ogm: OGM, hydration_level: ClassHydrationLevel, class_scope: ClassScope | None = None) → ClassSpec[source]#

create a ClassSpec for the given IRI by analyzing the ClassScope, its RDF data in the GraphDB via the OGM instance.

Args:

iri: The IRI of the class to specify ogm: The OGM instance with access to the GraphDB class_scope: The ClassScope defining the class and property structure hydration_level: Whether to include all immediate properties or not

Returns:

A ClassSpec instance representing the class specification