-
Notifications
You must be signed in to change notification settings - Fork 642
Improved Kubernetes dynamic pipeline retries #5107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
schustmi
wants to merge
1
commit into
develop
Choose a base branch
from
feature/improved-kubernetes-dynamic-pipeline-retries
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+213
−28
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
tests/unit/pipelines/dynamic/test_entrypoint_configuration.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # Copyright (c) ZenML GmbH 2026. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at: | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
| # or implied. See the License for the specific language governing | ||
| # permissions and limitations under the License. | ||
| """Tests for the dynamic pipeline entrypoint configuration.""" | ||
|
|
||
| from typing import Any | ||
|
|
||
| import pytest | ||
|
|
||
| from zenml.constants import DYNAMIC_PIPELINE_RUN_FAILED_EXIT_CODE | ||
| from zenml.enums import ExecutionStatus | ||
| from zenml.models import PipelineRequest, PipelineSnapshotRequest | ||
| from zenml.pipelines.dynamic.entrypoint_configuration import ( | ||
| DynamicPipelineEntrypointConfiguration, | ||
| ) | ||
|
|
||
|
|
||
| class _StubRun: | ||
| """Stub run exposing only the status the entrypoint configuration reads.""" | ||
|
|
||
| def __init__(self, status: ExecutionStatus) -> None: | ||
| self.status = status | ||
| self.id = "stub-run-id" | ||
|
|
||
|
|
||
| class _FailingStubRunner: | ||
| """Stub runner whose `run_pipeline` always raises.""" | ||
|
|
||
| def __init__(self, status: ExecutionStatus, **kwargs: Any) -> None: | ||
| self.run = _StubRun(status=status) | ||
|
|
||
| def run_pipeline(self) -> None: | ||
| raise RuntimeError("boom") | ||
|
|
||
|
|
||
| def _create_snapshot(clean_client: Any) -> Any: | ||
| pipeline = clean_client.zen_store.create_pipeline( | ||
| PipelineRequest( | ||
| name="pipeline", | ||
| project=clean_client.active_project.id, | ||
| ) | ||
| ) | ||
| request = PipelineSnapshotRequest( | ||
| user=clean_client.active_user.id, | ||
| project=clean_client.active_project.id, | ||
| run_name_template="", | ||
| pipeline_configuration={"name": "pipeline"}, | ||
| stack=clean_client.active_stack.id, | ||
| client_version="0.12.3", | ||
| server_version="0.12.3", | ||
| pipeline=pipeline.id, | ||
| ) | ||
| return clean_client.zen_store.create_snapshot(request) | ||
|
|
||
|
|
||
| def _entrypoint_config_with_stub_runner( | ||
| clean_client: Any, | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| status: ExecutionStatus, | ||
| ) -> DynamicPipelineEntrypointConfiguration: | ||
| snapshot = _create_snapshot(clean_client) | ||
|
|
||
| monkeypatch.setattr( | ||
| "zenml.pipelines.dynamic.entrypoint_configuration.DynamicPipelineRunner", | ||
| lambda **kwargs: _FailingStubRunner(status=status, **kwargs), | ||
| ) | ||
| monkeypatch.setattr( | ||
| "zenml.pipelines.dynamic.entrypoint_configuration.integration_registry.activate_integrations", | ||
| lambda: None, | ||
| ) | ||
| monkeypatch.setattr( | ||
| DynamicPipelineEntrypointConfiguration, | ||
| "prepare_code_environment", | ||
| lambda self: None, | ||
| ) | ||
|
|
||
| return DynamicPipelineEntrypointConfiguration( | ||
| arguments=["--snapshot_id", str(snapshot.id)] | ||
| ) | ||
|
|
||
|
|
||
| def test_run_exits_with_dedicated_code_when_run_reached_terminal_status( | ||
| clean_client: Any, monkeypatch: pytest.MonkeyPatch | ||
| ) -> None: | ||
| """Tests that `run()` exits with the dedicated code once the run is terminal.""" | ||
| entrypoint_config = _entrypoint_config_with_stub_runner( | ||
| clean_client, monkeypatch, status=ExecutionStatus.FAILED | ||
| ) | ||
|
|
||
| with pytest.raises(SystemExit) as exc_info: | ||
| entrypoint_config.run() | ||
|
|
||
| assert exc_info.value.code == DYNAMIC_PIPELINE_RUN_FAILED_EXIT_CODE | ||
|
|
||
|
|
||
| def test_run_reraises_when_run_did_not_reach_terminal_status( | ||
| clean_client: Any, monkeypatch: pytest.MonkeyPatch | ||
| ) -> None: | ||
| """Tests that `run()` re-raises the original exception when the run is not terminal.""" | ||
| entrypoint_config = _entrypoint_config_with_stub_runner( | ||
| clean_client, monkeypatch, status=ExecutionStatus.RUNNING | ||
| ) | ||
|
|
||
| with pytest.raises(RuntimeError, match="boom"): | ||
| entrypoint_config.run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: dict[str, Any] | None = None.