From e4c94451b9184d0ecab9da757e2e3864b94d14ab Mon Sep 17 00:00:00 2001 From: 1fanwang <1fannnw@gmail.com> Date: Sun, 25 Oct 2026 23:40:17 -0700 Subject: [PATCH] Add the missing ExecutionMetadata.ExecutionMode values ExecutionMode listed MANUAL, SCHEDULED and SYSTEM, but the admin proto also defines RELAUNCH, CHILD_WORKFLOW, RECOVERED and TRIGGER, so code checking a fetched execution for one of those modes raised AttributeError. Take every value from the generated proto, as WorkflowExecutionPhase does, and test against the proto enum. Signed-off-by: 1fanwang <1fannnw@gmail.com> --- flytekit/models/execution.py | 10 +++++++--- tests/flytekit/unit/models/test_execution.py | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/flytekit/models/execution.py b/flytekit/models/execution.py index b60217c0c2..4fa92250e0 100644 --- a/flytekit/models/execution.py +++ b/flytekit/models/execution.py @@ -41,9 +41,13 @@ def from_flyte_idl(cls, pb2_object: flyteidl.admin.execution_pb2.SystemMetadata) class ExecutionMetadata(_common_models.FlyteIdlEntity): class ExecutionMode(object): - MANUAL = 0 - SCHEDULED = 1 - SYSTEM = 2 + MANUAL = _execution_pb2.ExecutionMetadata.MANUAL + SCHEDULED = _execution_pb2.ExecutionMetadata.SCHEDULED + SYSTEM = _execution_pb2.ExecutionMetadata.SYSTEM + RELAUNCH = _execution_pb2.ExecutionMetadata.RELAUNCH + CHILD_WORKFLOW = _execution_pb2.ExecutionMetadata.CHILD_WORKFLOW + RECOVERED = _execution_pb2.ExecutionMetadata.RECOVERED + TRIGGER = _execution_pb2.ExecutionMetadata.TRIGGER def __init__( self, diff --git a/tests/flytekit/unit/models/test_execution.py b/tests/flytekit/unit/models/test_execution.py index 8e1dfa749a..0f5c3bad49 100644 --- a/tests/flytekit/unit/models/test_execution.py +++ b/tests/flytekit/unit/models/test_execution.py @@ -2,6 +2,7 @@ from datetime import timezone import pytest +from flyteidl.admin import execution_pb2 as _execution_pb2 from flytekit.models import common as _common_models from flytekit.models import execution as _execution @@ -149,6 +150,11 @@ def test_execution_metadata(): assert obj2.system_metadata == system_metadata +@pytest.mark.parametrize("name, value", _execution_pb2.ExecutionMetadata.ExecutionMode.items()) +def test_execution_mode_matches_idl(name: str, value: int) -> None: + assert getattr(_execution.ExecutionMetadata.ExecutionMode, name) == value + + @pytest.mark.parametrize("literal_value_pair", _parameterizers.LIST_OF_SCALAR_LITERALS_AND_PYTHON_VALUE) def test_execution_spec(literal_value_pair): literal_value, _ = literal_value_pair