Major Features: - Backward compatibility: VALIDATE_INPUTS handles old boolean True/False values for enable_runtime_hooks parameter - Phase 3: XMP region metadata with MWG-RS compliance (faces, areas, coordinates, extensions) - Phase 4.4: Per-node UI toggle for runtime hooks (dropdown: Auto/Enabled/Disabled) - Runtime hooks enhancements: performance tracking, disagreement logging, configurable limits New Files: - config.json: Configuration file for runtime hooks and metadata settings - eric_metadata/hooks/runtime_capture.py: Runtime hook infrastructure - eric_metadata/utils/config.py: Configuration loader with priority system - eric_metadata/utils/version.py: Version helper for generated_by labels - eric_metadata/utils/a1111.py: Automatic1111 parameter string generation - eric_metadata/utils/jpeg_fallback.py: 4-stage JPEG metadata fallback - eric_metadata/workflow/: Workflow parsing and generation helpers - tests/test_backward_compatibility.py: 7 tests for parameter migration - tests/test_xmp_regions.py: 6 tests for XMP region round-trip - tests/test_per_node_runtime_hooks.py: 9 tests for per-node toggle Documentation: - CONFIG_GUIDE.md: Configuration options and usage - RUNTIME_HOOKS_QUICK_REFERENCE.md: Quick reference for runtime hooks - RUNTIME_HOOKS_ENHANCEMENTS_SUMMARY.md: Detailed enhancement documentation - SAFE_RUNTIME_HOOKS_RESEARCH.md: Safety analysis and validation - edit_log.md: Complete change history Test Results: All 143 tests passing - 7 backward compatibility tests - 6 XMP region tests - 9 per-node toggle tests - 17 runtime hooks enhancement tests - 104 existing tests Breaking Changes: None - fully backward compatible
3.4 KiB
3.4 KiB
Metadata Emitter Integration Checklist
Use this checklist when wiring any custom node or utility into the AAA Metadata System so emitted data remains consistent and versioned correctly.
1. Imports and shared constants
from custom_nodes.AAA_Metadata_System import MetadataServicefrom custom_nodes.AAA_Metadata_System.eric_metadata.utils.version import get_metadata_system_version_label- Cache once per module:
METADATA_SYSTEM_GENERATED_BY = get_metadata_system_version_label()
2. Acquire the MetadataService
- Reuse a service passed in by parent nodes when available.
- Otherwise construct one during
__init__(e.g.,self.metadata_service = MetadataService(debug=self.debug, human_readable_text=True)). - Do not instantiate a new service inside hot call loops.
3. Decide where the emitter sits in the pipeline
Choose the correct section in the metadata payload:
ai_info.generationfor sampler/execution details (already defined by save-image nodes).ai_info.analysisfor inspections or classifiers.workflow/assistnamespaces only if aligning with established schema; coordinate before introducing new top-level keys.
4. Shape and merge the payload
- Start from an empty dict or augment an existing metadata object with
_deep_merge/_merge_metadata. - Always add a provenance stamp:
payload_section['generated_by'] = METADATA_SYSTEM_GENERATED_BY. - Prefer explicit keys (
top_prompt,primary_subject) over ambiguous arrays. - Clamp numeric values, strip long strings when embedding, and move large blobs to sidecar attachments.
5. Select targets before writing
| Use Case | Suggested Targets |
|---|---|
| Human-readable summary only | ['txt'] |
| Structured data only | ['xmp'] |
| Shareable + structured | ['txt', 'xmp'] |
| PNG/JPEG with small payload | include 'embedded' |
| Database sync enabled | append 'db' |
Adjust per node defaults or expose toggles to the user.
6. Write the metadata
self.metadata_service.write_metadata(
resource_path,
payload,
targets=targets,
resource_identifier=resource_uri, # optional but recommended
)
resource_pathshould point at the primary output file.- If emitting pre-save (e.g., analysis-only node), use a logical URI and let downstream writers merge later.
7. Coordinate with discovery mode
- When
self.metadata_service.discovery_modeisTrue, collect unknown labels, node types, or schema changes and push them intometadata_service.discovery_logger. - Keep log messages concise; avoid spamming the console.
8. Tests & validation
- Extend or add pytest coverage that exercises the emitter and asserts the expected keys.
- Run the standard regression suite:
A:/Comfy25/ComfyUI_windows_portable/python_embeded/python.exe -m pytest tests/prep/test_module_boundaries.py - Manually inspect an emitted TXT/XMP file to confirm
generated_bymatchesversion.txt. - (If applicable) open the discovery report to ensure new fields appear under the correct namespace.
9. Documentation & change log
- Summarize the emitter addition in
documentation/edit_log.mdwith test command. - Update any relevant schema docs so downstream consumers know about new keys or namespaces.
Following this checklist keeps every metadata emitter aligned with the shared version helper and prevents accidental divergence between nodes.