Artifacts naming
Understand how you can name your ZenML artifacts.
In ZenML pipelines, you often need to reuse the same step multiple times with different inputs, resulting in multiple artifacts. However, the default naming convention for artifacts can make it challenging to track and differentiate between these outputs, especially when they need to be used in subsequent pipelines. Below you can find a detailed exploration of how you might name your output artifacts dynamically or statically, depending on your needs.
ZenML uses type annotations in function definitions to determine artifact names. Output artifacts with the same name are saved with incremented version numbers.
ZenML provides flexible options for naming output artifacts, supporting both static and dynamic naming strategies:
Names can be generated dynamically at runtime
Support for string templates (standard and custom placeholders supported)
Compatible with single and multiple output scenarios
Annotations help define naming strategy without modifying core logic
Naming Strategies
Static Naming
Static names are defined directly as string literals.
Dynamic Naming
Dynamic names can be generated using:
String Templates Using Standard Placeholders
Use the following placeholders that ZenML will replace automatically:
{date}
will resolve to the current date, e.g.2024_11_18
{time}
will resolve to the current time, e.g.11_07_09_326492
String Templates Using Custom Placeholders
Use any placeholders that ZenML will replace for you, if they are provided into a step via substitutions
parameter:
Another option is to use with_options
to dynamically redefine the placeholder, like this:
The substitutions for the custom placeholders like stage
can be set in:
@pipeline
decorator, so they are effective for all steps in this pipelinepipeline.with_options
function, so they are effective for all steps in this pipeline run@step
decorator, so they are effective for this step (this overrides the pipeline settings)step.with_options
function, so they are effective for this step run (this overrides the pipeline settings)
Standard substitutions always available and consistent in all steps of the pipeline are:
{date}
: current date, e.g.2024_11_27
{time}
: current time in UTC format, e.g.11_07_09_326492
Multiple Output Handling
If you plan to return multiple artifacts from you ZenML step you can flexibly combine all naming options outlined above, like this:
Naming in cached runs
If your ZenML step is running with enabled caching and cache was used the names of the outputs artifacts (both static and dynamic) will remain the same as in the original run.
These 2 runs will produce output like the one below:
Last updated