Metadata Models API
Purpose
This module defines validation models for metadata (metadata.json) used in RDEToolKit. It provides functionality for metadata structure validation, type safety assurance, and data integrity verification.
Key Features
Metadata Models
- Structure definition of metadata items
- Management of validatable items
- Processing of meta values and variables
Data Validation
- Pydantic-based type safety
- Metadata validity verification
- Detailed error messages
src.rdetoolkit.models.metadata.MetadataItem
Bases: BaseModel
metadata-def.json class.
Stores metadata extracted by the data structuring process.
Attributes:
Name | Type | Description |
---|---|---|
constant |
dict[str, MetaValue]
|
A set of metadata common to all measurements. |
variable |
ValidableItems
|
An array of metadata sets that vary with each measurement. |
constant: dict[str, MetaValue]
instance-attribute
variable: ValidableItems
instance-attribute
src.rdetoolkit.models.metadata.ValidableItems
Bases: RootModel
A class representing validatable items of metadata.
This class inherits from RootModel
, and the root
attribute holds a list of dictionaries,
where each dictionary has a string as a key and a MetaValue
as a value.
Attributes:
Name | Type | Description |
---|---|---|
root |
list[dict[str, MetaValue]]
|
A list of validatable items of metadata. |
root: list[dict[str, MetaValue]]
instance-attribute
src.rdetoolkit.models.metadata.MetaValue
Bases: BaseModel
Metadata class for the 'value' and 'unit' attributes.
unit: str | None = None
class-attribute
instance-attribute
value: Any
instance-attribute
check_value_size(v)
classmethod
Validator that verifies that the size of the 'value' does not exceed 1024 bytes if it is a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
dict[str, Any]
|
Value of the metadata |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Exception error if the value of the metadata is more than 1024 bytes |
src.rdetoolkit.models.metadata.Variable
Bases: BaseModel
Metadata class for the 'variable' attribute.
variable: dict[str, Any]
instance-attribute
check_value_size(v)
classmethod
Validator that verifies that the size of the 'variable' type metadata value does not exceed 1024 bytes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
dict[str, Any]
|
Metadata of 'variable' |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Exception error if the value of the metadata is more than 1024 bytes |
Practical Usage
Basic Metadata Item
basic_metadata_item.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Managing Validatable Items
validable_items.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Variable Processing
variable_processing.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
Metadata Validation System
metadata_validation_system.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 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 |
|