Skip to content

metadata

Metadata Management ModuleLink

This module provides a robust interface for managing metadata in JSON format, offering essential functionality for loading, storing, and manipulating metadata for files, filesets, and scans within a plant database system.

Key FeaturesLink

  • Metadata Loading Operations
  • Load metadata from JSON files for files, filesets, and scan datasets
  • Handle JSON decode errors gracefully with appropriate error logging
  • Support both string and Path objects for file paths
  • Maintain backward compatibility with legacy metadata storage patterns

  • Metadata Storage Operations

  • Save metadata to JSON files with consistent formatting
  • Automatic creation of necessary directory structures
  • Support for hierarchical metadata organization

  • Metadata Manipulation

  • Deep copy functionality to prevent unintended modifications
  • Flexible key-value pair management
  • Support for both single value updates and bulk dictionary updates

Usage ExamplesLink

```python

Loading metadata from a fileLink

metadata = _load_metadata("path/to/metadata.json")

Setting metadata valuesLink

metadata_dict = {} _set_metadata(metadata_dict, "key", "value")

Or update with a dictionaryLink

_set_metadata(metadata_dict, {"key1": "value1", "key2": "value2"}, None)

Getting metadata with a default valueLink

value = _get_metadata(metadata_dict, "key", default={})

MetadataManager Link

Bases: object

Common helper for updating metadata on Scan, Fileset and File objects.