pixano.datasets.utils.integrity
IntegrityCheck
Bases: Enum
Integrity check types.
Attributes:
Name | Type | Description |
---|---|---|
DEFINED_ID |
Check if the id field is defined. |
|
UNIQUE_ID |
Check if the id field is unique. |
|
REF_NAME |
Check if the ref name is defined in the schema. |
|
REF_TYPE |
Check if the ref type is defined in the schema. |
|
REF_ID |
Check if the ref id is stored in the referenced table. |
check_dataset_integrity(dataset)
Check the integrity of a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
Dataset to check. |
required |
Returns:
Type | Description |
---|---|
List of errors as tuples with the following values
|
|
-check_type
|
Check type. |
-table
|
Table name. |
-field_name
|
Field name that caused the error. |
-schema_id
|
Schema id that raised the error. |
-field
|
Field value that caused the error. |
Source code in pixano/datasets/utils/integrity.py
check_table_integrity(table_name, dataset, schemas=None, updating=False, ignore_checks=None)
Check the integrity of schemas against a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
Table name. |
required |
dataset
|
Dataset
|
Dataset that contains the table. |
required |
schemas
|
list[BaseSchema] | None
|
List of schemas to insert in table. If None, the table is checked, otherwise the schemas are checked against the table. |
None
|
updating
|
bool
|
If True, the table is being updated. It is used to avoid checking the id uniqueness when updating schemas. |
False
|
ignore_checks
|
list[IntegrityCheck] | None
|
List of integrity checks to ignore. |
None
|
Returns:
Type | Description |
---|---|
List of errors as tuples with the following values
|
|
-check_type
|
Check type. |
-table
|
Table name. |
-field_name
|
Field name that caused the error. |
-schema_id
|
Schema id that raised the error. |
-field
|
Field value that caused the error. |
Source code in pixano/datasets/utils/integrity.py
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 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
get_integry_checks_from_schemas(schemas, table_name)
Get the integrity checks to perform on a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
schemas
|
list[BaseSchema]
|
List of schemas to check. |
required |
table_name
|
str
|
Table name. |
required |
Returns:
Type | Description |
---|---|
list[list[tuple[str, str, str, str, Any]]]
|
List of integrity checks to perform on the table. The checks are grouped by type. |
-check_id
|
Check id (unique identifier for the checks). It is used to avoid checking subsequent checks with the same id when an error is found. |
-table
|
Table name. |
-schema_id
|
Schema id which is the id field value from the schema. |
-field_name
|
Field name to check. |
-field
|
Field value to check. |
Source code in pixano/datasets/utils/integrity.py
handle_integrity_errors(check_errors, raise_or_warn='raise')
Handle integrity check errors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
check_errors
|
list[tuple[IntegrityCheck, str, str, str, Any]]
|
List of errors. |
required |
raise_or_warn
|
Literal['raise', 'warn']
|
If "raise", raise a ValueError with the errors. If "warn", warns a UserWarning with the errors. |
'raise'
|