Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class KubernetesOrchestratorSettings(BaseSettings):
scheduling a pipeline.
prevent_orchestrator_pod_caching: If `True`, the orchestrator pod will
not try to compute cached steps before starting the step pods.
always_build_pipeline_image: If `True`, the orchestrator will always
build the pipeline image, even if all steps have a custom build.
"""

synchronous: bool = True
Expand All @@ -88,6 +90,7 @@ class KubernetesOrchestratorSettings(BaseSettings):
failed_jobs_history_limit: Optional[NonNegativeInt] = None
ttl_seconds_after_finished: Optional[NonNegativeInt] = None
prevent_orchestrator_pod_caching: bool = False
always_build_pipeline_image: bool = False


class KubernetesOrchestratorConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
from zenml.stack import StackValidator

if TYPE_CHECKING:
from zenml.models import PipelineDeploymentResponse, PipelineRunResponse
from zenml.models import (
PipelineDeploymentBase,
PipelineDeploymentResponse,
PipelineRunResponse,
)
from zenml.stack import Stack

logger = get_logger(__name__)
Expand All @@ -84,6 +88,19 @@ class KubernetesOrchestrator(ContainerizedOrchestrator):

_k8s_client: Optional[k8s_client.ApiClient] = None

def should_build_pipeline_image(
self, deployment: "PipelineDeploymentBase"
) -> bool:
"""Whether to always build the pipeline image.

Returns:
Whether to always build the pipeline image.
"""
settings = cast(
KubernetesOrchestratorSettings, self.get_settings(deployment)
)
return settings.always_build_pipeline_image

def get_kube_client(
self, incluster: Optional[bool] = None
) -> k8s_client.ApiClient:
Expand Down
19 changes: 19 additions & 0 deletions src/zenml/orchestrators/containerized_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ def get_image(
component_key=ORCHESTRATOR_DOCKER_IMAGE_KEY, step=step_name
)

def should_build_pipeline_image(
self, deployment: "PipelineDeploymentBase"
) -> bool:
"""Whether to build the pipeline image.

Returns:
Whether to build the pipeline image.
"""
return False

def get_docker_builds(
self, deployment: "PipelineDeploymentBase"
) -> List["BuildConfiguration"]:
Expand Down Expand Up @@ -87,4 +97,13 @@ def get_docker_builds(
builds.append(pipeline_build)
included_pipeline_build = True

if not included_pipeline_build and self.should_build_pipeline_image(
deployment
):
pipeline_build = BuildConfiguration(
key=ORCHESTRATOR_DOCKER_IMAGE_KEY,
settings=pipeline_settings,
)
builds.append(pipeline_build)

return builds
Loading