model
EleanorAI Framework Task Execution Data Models
This module defines the data model classes used by the EleanorAI Task Execution Framework. These classes represent the various states, statuses, and policies associated with task execution stages. They are essential for managing the lifecycle of tasks, including checkpointing, rollbacks, and retries.
These models are used by the TaskEngine and BaseStage classes in the task execution framework to manage and persist the state of each stage in a task. They provide a structured way to track the progress, retries, and history of each stage, ensuring that tasks can be resumed or rolled back as needed.
Attributes:
-
ACTIVE_STATES
(set
) –Set of active stage statuses.
-
INACTIVE_STATES
(set
) –Set of inactive stage statuses.
-
STAGE_NAME_MAX_LENGTH
(int
) –Maximum length of a stage name.
Attributes
Classes
BaseStageState
Bases: BaseModel
, Generic[STAGE_RESULT]
Base class for stage state data. This class should be subclassed to provide specific fields for managing state data.
Note that all stages in a task share the same state class. This is a deliberate design decision to ensure the currently executing stag as access to all relevant state details of every stage that came before it.
Attributes
attempts
class-attribute
instance-attribute
attempts: int = Field(
default=0,
ge=0,
title="Run attempts",
description="Number of times the stage has been run, value of 0 indicates it has not beenrun yet. Primary used to track retries.",
)
history
class-attribute
instance-attribute
history: List[StageStateHistoryEntry] = Field(
default=[],
title="History",
description="Stage state history",
)
model_config
class-attribute
instance-attribute
result
class-attribute
instance-attribute
result: STAGE_RESULT | None = Field(
default=None,
title="Result",
description="Contains the stage execution result. The intended use case is to store the output of the final stage such that external systems can inspect the final stage to determine the overall result of the task. A value of None indicates that the stage has not been completed successfully",
)
stage_name
class-attribute
instance-attribute
stage_name: str = Field(
"",
max_length=STAGE_NAME_MAX_LENGTH,
title="Stage Name",
description="Unique stage name / identifier. This field will be used to generate the statemetadata file/object and persisted during execution",
)
status
class-attribute
instance-attribute
status: StageStatus = Field(
default=UNBOUND,
title="Stage Status",
description="Stage execution status, used by the task execution engine to determine whetherthis state needs to be executed or skipped",
)
RecordStatus
RetryPolicy
Bases: Enum
Task retry policy enumeration.
Attributes:
SimpleRecordsResult
Bases: BaseModel
Simple task result model indented to provide useful summary statistics in the RDBMS.
Attributes
fail_count
class-attribute
instance-attribute
fail_count: int = Field(
default=0,
ge=0,
title="Fail Count",
description="Number of failed records",
)
message
class-attribute
instance-attribute
success_count
class-attribute
instance-attribute
success_count: int = Field(
default=0,
ge=0,
title="Success Count",
description="Number of successful records",
)
StageStateHistoryEntry
Bases: BaseModel
Stage state history
Attributes
attempt
class-attribute
instance-attribute
attempt: int = Field(
...,
ge=0,
title="Attempt",
description="Run attempt number corresponding to this history entry",
)
begin_status
class-attribute
instance-attribute
begin_status: StageStatus = Field(
...,
title="Begin Status",
description="Status of the stage prior to the run",
)
begin_ts
class-attribute
instance-attribute
end_status
class-attribute
instance-attribute
end_status: StageStatus = Field(
...,
title="End Status",
description="Status of the stage after the run",
)
end_ts
class-attribute
instance-attribute
message
class-attribute
instance-attribute
StageStatus
Bases: Enum
Task status enumeration.
Attributes:
-
UNBOUND
(str
) –Task has not been bound to a task engine.
-
CREATED
(str
) –Task has been created but not yet started.
-
RUNNING
(str
) –Task is currently running.
-
RETRY
(str
) –Task encountered an error and is eligible for to be retried.
-
ERROR
(str
) –Task has encountered an error and cannot be retried.
-
COMPLETE
(str
) –Task has completed successfully.
-
CANCELED
(str
) –Task has been canceled.