Skip to content
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

raise DagsterError for trying to re-execute a not failed run #17535

Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions python_modules/dagster/dagster/_core/execution/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,11 @@ def from_failure(run_id: str, instance: DagsterInstance) -> "ReexecutionOptions"
from dagster._core.execution.plan.state import KnownExecutionState

parent_run = check.not_none(instance.get_run_by_id(run_id))
check.invariant(
parent_run.status == DagsterRunStatus.FAILURE,
"Cannot reexecute from failure a run that is not failed",
)
if parent_run.status != DagsterRunStatus.FAILURE:
raise DagsterInvariantViolationError(
"Cannot reexecute from failure a run that is not failed"
)

# Tried to thread through KnownExecutionState to execution plan creation, but little benefit.
# It is recalculated later by the re-execution machinery.
step_keys_to_execute, _ = KnownExecutionState.build_resume_retry_reexecution(
Expand Down
8 changes: 4 additions & 4 deletions python_modules/dagster/dagster/_core/instance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,10 +1575,10 @@ def create_reexecuted_run(
run_config = run_config if run_config is not None else parent_run.run_config

if strategy == ReexecutionStrategy.FROM_FAILURE:
check.invariant(
parent_run.status == DagsterRunStatus.FAILURE,
"Cannot reexecute from failure a run that is not failed",
)
if parent_run.status != DagsterRunStatus.FAILURE:
raise DagsterInvariantViolationError(
"Cannot reexecute from failure a run that is not failed",
)

(
step_keys_to_execute,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dagster._check as check
import pytest
from dagster import (
AssetKey,
Expand Down Expand Up @@ -260,7 +259,7 @@ def test_reexecute_from_failure_successful_run(instance):
) as result:
assert result.success

with pytest.raises(check.CheckError, match="run that is not failed"):
with pytest.raises(DagsterInvariantViolationError, match="run that is not failed"):
ReexecutionOptions.from_failure(result.run_id, instance)


Expand Down
Loading