task_display
task_display
¶
Task display types, lifecycle state, and status computation.
Provides display-oriented dataclasses (StatusInfo, ModeInfo),
status/mode lookup tables, TaskState (the lifecycle fields needed
for display), and functions for computing the effective status of a task.
Split from tasks.py to decouple presentation data from task
lifecycle and metadata I/O.
TaskState(container_state=None, exit_code=None, deleting=False, initialized=False)
dataclass
¶
Container lifecycle state used for display status computation.
Orchestration-level TaskMeta inherits from this to add identity,
configuration, and runtime metadata fields.
StatusInfo(label, emoji, color)
dataclass
¶
Display attributes for a task effective status.
ModeInfo(emoji, label)
dataclass
¶
Display attributes for a task mode.
ProjectBadge(emoji, label)
dataclass
¶
Display attributes for a project-level badge (security class, GPU, etc.).
has_gpu(project)
¶
Check whether a project has GPU enabled in its project.yml.
Accepts any object with a root attribute pointing to the project
directory (typically a Project instance). Returns False on
any I/O or parse error.
Source code in src/terok/lib/core/task_display.py
effective_status(task)
¶
Compute the display status from task lifecycle state.
Reads the following fields from a TaskState instance:
container_state(str | None): live podman state, or Noneexit_code(int | None): process exit code, or Nonedeleting(bool): persisted to YAML before deletion startsinitialized(bool): True onceready_atis persisted to YAML
Returns one of: "deleting", "running", "init",
"stopped", "completed", "failed", "created",
"not found".
Source code in src/terok/lib/core/task_display.py
mode_info(mode)
¶
Return the display info for a task mode string.