Overview
Thelog_step_metadata() function allows you to attach metadata to step runs during pipeline execution. This is particularly useful for logging metrics, parameters, or custom tracking information from within your steps.
Signature
Parameters
Dictionary of metadata key-value pairs to log. Supported value types:
- Primitives:
str,int,float,bool - URI:
Urifor file/resource references - Structured:
dict,list
Name of the step to log metadata to. If not provided, logs to the currently executing step.
Return Value
This function does not return a value. Metadata is logged to the ZenML server and associated with the step run.
Usage Examples
Log Metrics During Training
Log Hyperparameters
Log Data Quality Metrics
Log from Different Steps
Metadata Types
ZenML supports various metadata types:Supported Metadata Types
Supported Metadata Types
- Primitives:
str,int,float,bool - URI:
Urifor file paths and URLs - Storage Size:
StorageSizefor byte sizes - Structured:
dict,listfor complex data - Custom: Any JSON-serializable type
Best Practices
Log Early
Log hyperparameters and config at the start of your step for complete tracking
Use Descriptive Keys
Use clear, consistent naming for metadata keys (e.g., “training_accuracy” not “acc”)
Log Incrementally
You can call log_step_metadata multiple times - metadata is accumulated
Track Versions
Log versions of data, models, and dependencies for reproducibility
Related Functions
log_metadata
General metadata logging function
log_artifact_metadata
Log metadata to artifacts
log_model_metadata
Log metadata to models
get_step_context
Access step context information
Notes
Metadata logged with
log_step_metadata() is visible in the ZenML dashboard and can be used for filtering, searching, and comparing step runs.If you call
log_step_metadata() multiple times within the same step, the metadata is accumulated (not replaced).