Reference
This part of the documentation provides automatically generated information about RDFProxy symbols.
rdfproxy.adapter.SPARQLModelAdapter
Bases: Generic[_TModelInstance]
Adapter/Mapper for SPARQL query result set to Pydantic model conversions.
The rdfproxy.SPARQLModelAdapter class allows to run a query against an endpoint and map a flat SPARQL query result set to a potentially nested Pydantic model.
SPARQLModelAdapter.query returns a Page model object with a default pagination size of 100 results.
SPARQL bindings are implicitly assigned to model fields of the same name, explicit SPARQL binding to model field allocation is available with rdfproxy.SPARQLBinding.
Result grouping is controlled through the model, i.e. grouping is triggered when a field of list[pydantic.BaseModel] is encountered.
See https://github.com/acdh-oeaw/rdfproxy/tree/main/examples for examples.
Source code in rdfproxy/adapter.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
query(query_parameters=QueryParameters())
Run a query against an endpoint and return a Page model object.
Source code in rdfproxy/adapter.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
rdfproxy.constructor._QueryConstructor
The class encapsulates dynamic SPARQL query modification logic for implementing purely SPARQL-based, deterministic pagination.
Public methods get_items_query and get_count_query are used in rdfproxy.SPARQLModelAdapter to construct queries for retrieving arguments for Page object instantiation.
Source code in rdfproxy/constructor.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
|
get_count_query()
Construct a SPARQL count query for use in rdfproxy.SPARQLModelAdapter
Source code in rdfproxy/constructor.py
54 55 56 57 58 59 60 61 |
|
get_items_query()
Construct a SPARQL items query for use in rdfproxy.SPARQLModelAdapter.
Source code in rdfproxy/constructor.py
48 49 50 51 52 |
|
rdfproxy.mapper._ModelBindingsMapper
Bases: Generic[_TModelInstance]
Utility class for mapping bindings to nested/grouped Pydantic models.
RDFProxy utilizes Pydantic models also as a modelling grammar for grouping and aggregation, mainly by treating the 'group_by' entry in ConfigDict in combination with list-type annoted model fields as grouping and aggregation indicators. _ModelBindingsMapper applies this grammar for mapping flat bindings to potentially nested and grouped Pydantic models.
Note: _ModelBindingsMapper is intended for use in rdfproxy.SPARQLModelAdapter and - since no model sanity checking runs in the mapper itself - somewhat coupled to SPARQLModelAdapter. The mapper can be useful in its own right though. For standalone use, the initializer should be overwritten and model sanity checking should be added to the _ModelBindingsMapper subclass.
Source code in rdfproxy/mapper.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
|
get_models()
Run the model mapping logic against bindings and collect a list of model instances.
Source code in rdfproxy/mapper.py
44 45 46 |
|
rdfproxy.utils._types.ConfigDict
Bases: ConfigDict
pydantic.ConfigDict extension for RDFProxy model_config options.
Source code in rdfproxy/utils/_types.py
50 51 52 53 54 |
|
rdfproxy.utils._types.SPARQLBinding
Bases: str
SPARQLBinding type for explicit SPARQL binding to model field allocation.
This type's intended use is with typing.Annotated in the context of a Pyantic field definition.
Example:
class Work(BaseModel):
name: Annotated[str, SPARQLBinding("title")]
class Person(BaseModel):
name: str
work: Work
This signals to the RDFProxy SPARQL-to-model mapping logic to use the "title" SPARQL binding (not the "name" binding) to populate the Work.name field.
Source code in rdfproxy/utils/_types.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
rdfproxy.utils.models.Page
Bases: BaseModel
, Generic[_TModelInstance]
Page model for rdfproxy pagination functionality.
This model is loosely inspired by the fastapi-pagination Page class, see https://github.com/uriyyo/fastapi-pagination.
Also see https://docs.pydantic.dev/latest/concepts/models/#generic-models for Generic Pydantic models.
Source code in rdfproxy/utils/models.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
rdfproxy.utils.models.QueryParameters
Bases: BaseModel
Query parameter model for SPARQLModelAdapter.query.
See https://fastapi.tiangolo.com/tutorial/query-param-models/
Source code in rdfproxy/utils/models.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|