-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathkernel_process_step_metadata.py
More file actions
37 lines (25 loc) · 1.21 KB
/
kernel_process_step_metadata.py
File metadata and controls
37 lines (25 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright (c) Microsoft. All rights reserved.
from dataclasses import dataclass
from semantic_kernel.utils.feature_stage_decorator import experimental
@experimental
@dataclass(frozen=True)
class KernelProcessStepMetadataAttribute:
"""Metadata describing the version of the Step's implementation for serialization and replay."""
version: str = "v1"
@experimental
def kernel_process_step_metadata(version: str = "v1"):
"""Decorator to attach a version string representing the Step's implementation version.
This version is serialized in `versionInfo` for each step, enabling replay
and process recovery to instantiate the correct Step variant.
The version string used in @kernel_process_step_metadata must uniquely identify the Step class'
behavior and contract version. Different versions imply incompatible step behavior, state schema,
or function/event definitions.
Example usage:
@kernel_process_step_metadata("CutFoodStep.V2")
class CutFoodWithSharpeningStep(KernelProcessStep[MyState]):
...
"""
def decorator(cls):
setattr(cls, "_kernel_process_step_metadata", KernelProcessStepMetadataAttribute(version))
return cls
return decorator