field_spec
MIAPPE field specification for the metadata editor UILink
Defines every editable leaf field of the canonical MIAPPE-aligned scan
metadata tree (see plantdb.commons.fsdb.metadata_schema) plus the detailed
explanations of each field (sourced from the MIAPPE checklist data model TSV).
It also provides helpers to flatten a nested metadata dict to a flat
{dot.path: value} mapping and to rebuild the tree, which the UI uses to
render editable forms and to write values back.
coerce
Link
Coerce value to the declared type of the field at path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Dot-separated field path whose declared type is applied. |
required |
|
Any
|
Value to coerce. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The coerced value, the original value if it cannot be coerced, or
|
Source code in plantdb/client/metadata_app/field_spec.py
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 | |
collect_suggestions
Link
Return the sorted unique non-empty values of path across scans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list of dict of str to Any
|
A list of flattened scan dicts (see :func: |
required |
|
str
|
Dot-separated field path to collect values for. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
Sorted unique values. |
Source code in plantdb/client/metadata_app/field_spec.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
flatten
Link
Flatten a nested metadata dict into a flat {dot.path: value} mapping.
Only leaf fields declared in FIELD_SPECS are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict of str to Any
|
The nested metadata dict to flatten. |
required |
|
str
|
Dot-separated path prefix to prepend (used in recursion). |
''
|
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
The flattened mapping. |
Source code in plantdb/client/metadata_app/field_spec.py
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 | |
sections
Link
sections()
Return the ordered top-level MIAPPE section names.
Returns:
| Type | Description |
|---|---|
list of str
|
The top-level keys of the biological schema. |
Source code in plantdb/client/metadata_app/field_spec.py
276 277 278 279 280 281 282 283 284 | |
specs_for_section
Link
specs_for_section(section)
Return the field specs whose dot-path starts with section.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Top-level MIAPPE section name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
list of FieldSpec
|
The field specs belonging to the section. |
Source code in plantdb/client/metadata_app/field_spec.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 | |
unflatten
Link
unflatten(flat)
Rebuild a nested metadata dict from a flat {dot.path: value} mapping.
Intermediate sections are created as needed. Values are coerced to the declared field type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
dict of str to Any
|
The flattened mapping to rebuild. |
required |
Returns:
| Type | Description |
|---|---|
dict of str to Any
|
The nested metadata tree. |
Source code in plantdb/client/metadata_app/field_spec.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |