Develop a Custom Step Operator
Learning how to develop a custom step operator.
Base Abstraction
from abc import ABC, abstractmethod
from typing import List, Type
from zenml.enums import StackComponentType
from zenml.stack import StackComponent, StackComponentConfig, Flavor
from zenml.config.step_run_info import StepRunInfo
class BaseStepOperatorConfig(StackComponentConfig):
"""Base config for step operators."""
class BaseStepOperator(StackComponent, ABC):
"""Base class for all ZenML step operators."""
@abstractmethod
def launch(
self,
info: StepRunInfo,
entrypoint_command: List[str],
) -> None:
"""Abstract method to execute a step.
Subclasses must implement this method and launch a **synchronous**
job that executes the `entrypoint_command`.
Args:
info: Information about the step run.
entrypoint_command: Command that executes the step.
"""
class BaseStepOperatorFlavor(Flavor):
"""Base class for all ZenML step operator flavors."""
@property
@abstractmethod
def name(self) -> str:
"""Returns the name of the flavor."""
@property
def type(self) -> StackComponentType:
"""Returns the flavor type."""
return StackComponentType.STEP_OPERATOR
@property
def config_class(self) -> Type[BaseStepOperatorConfig]:
"""Returns the config class for this flavor."""
return BaseStepOperatorConfig
@property
@abstractmethod
def implementation_class(self) -> Type[BaseStepOperator]:
"""Returns the implementation class for this flavor."""Build your own custom step operator
Enabling CUDA for GPU-backed hardware
Last updated
Was this helpful?