Metadata
datamate.metadata ¶
Module for handling metadata reading, writing and validation for Directory objects.
MetadataError ¶
Bases: ValueError
Base class for metadata-related errors.
Source code in datamate/metadata.py
22 23 24 25 |
|
MetadataParseError ¶
Bases: MetadataError
Raised when metadata YAML cannot be parsed.
Source code in datamate/metadata.py
28 29 30 31 |
|
MetadataValidationError ¶
Bases: MetadataError
Raised when metadata structure is invalid.
Source code in datamate/metadata.py
34 35 36 37 |
|
read_meta ¶
read_meta(path, retries=5)
Read and validate metadata from a directory’s _meta.yaml
file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Directory path containing |
required |
retries
|
int
|
Number of retry attempts for transient failures |
5
|
Returns:
Type | Description |
---|---|
Namespace
|
Namespace containing validated metadata with |
Raises:
Type | Description |
---|---|
MetadataParseError
|
If YAML parsing fails |
MetadataValidationError
|
If metadata structure is invalid |
FileNotFoundError
|
If |
NotADirectoryError
|
If path is not a directory |
Note
Returns default metadata (empty config, status=”done”) for non-existent paths
Source code in datamate/metadata.py
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 |
|
write_meta ¶
write_meta(path, config=None, status=None, **kwargs)
Write metadata to a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to write the metadata file |
required |
config
|
Optional[Dict[str, Any]]
|
Configuration dictionary to store |
None
|
status
|
Optional[Literal['done', 'error', 'running']]
|
Status string indicating directory state |
None
|
**kwargs
|
Any
|
Additional metadata fields to include |
{}
|
Note
Supports serialization of numpy types (arrays, integers, floats)
Source code in datamate/metadata.py
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 |
|