model
¤
Classes:
-
BaseRdfModel
–Base class for RDF-mappable Pydantic models.
BaseRdfModel
pydantic-model
¤
Bases: BaseModel
Base class for RDF-mappable Pydantic models.
Config:
arbitrary_types_allowed
:True
Fields:
-
uri
(PydanticURIRef
)
all_entities
classmethod
¤
Return all entities of this model's RDF type from the graph.
Returns:
-
list[T]
–A list of model instances for each entity of this RDF type in the graph.
Raises:
-
CircularReferenceError
–If a circular reference is detected during parsing.
-
ValueError
–If any entity URI does not have the expected RDF type.
-
UnsupportedFieldTypeError
–If a field type is not supported for RDF parsing.
Example
entities = MyModel.all_entities(graph)
model_dump_rdf
¤
model_dump_rdf() -> Graph
Serialize this model instance to an RDF graph.
Returns:
-
Graph
–An RDFLib Graph representing this model instance.
Example
graph = instance.model_dump_rdf()
parse_graph
classmethod
¤
Parse an RDF entity from the graph into a model instance.
Uses a cache to prevent recursion and circular references.
Parameters:
-
_cache
(RDFEntityCache | None
, default:None
) –Optional cache for already-parsed entities.
Returns:
-
T
–An instance of the model corresponding to the RDF entity.
Raises:
-
CircularReferenceError
–If a circular reference is detected during parsing.
-
ValueError
–If the URI does not have the expected RDF type.
-
UnsupportedFieldTypeError
–If a field type is not supported for RDF parsing.
Example
model = MyModel.parse_graph(graph, EX.some_uri)