Update deployment and CLI tooling: - TUI models (jobs, state) with scheduler data - TUI store with scheduler endpoints - TUI config with scheduler settings - Deployment Makefile with scheduler targets - Deploy script with scheduler registration - Docker Compose files with scheduler services - Remove obsolete Dockerfiles (api-server, full-prod, test) - Update remaining Dockerfiles with scheduler integration
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
// Package model provides TUI data structures and state management
|
|
package model
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/charmbracelet/lipgloss"
|
|
)
|
|
|
|
// JobStatus represents the status of a job
|
|
type JobStatus string
|
|
|
|
// JobStatus constants represent different job states
|
|
const (
|
|
StatusPending JobStatus = "pending" // Job is pending
|
|
StatusQueued JobStatus = "queued" // Job is queued
|
|
StatusRunning JobStatus = "running" // Job is running
|
|
StatusFinished JobStatus = "finished" // Job is finished
|
|
StatusFailed JobStatus = "failed" // Job is failed
|
|
)
|
|
|
|
// Job represents a job in the TUI
|
|
type Job struct {
|
|
OutcomeStatus string
|
|
Status JobStatus
|
|
TaskID string
|
|
Hypothesis string
|
|
Context string
|
|
Intent string
|
|
ExpectedOutcome string
|
|
ActualOutcome string
|
|
Name string
|
|
Priority int64
|
|
GPUDeviceID int
|
|
GPUUtilization int
|
|
GPUMemoryUsed int64
|
|
}
|
|
|
|
// Title returns the job title for display
|
|
func (j Job) Title() string { return j.Name }
|
|
|
|
// Description returns a formatted description with status icon and GPU info
|
|
func (j Job) Description() string {
|
|
icon := map[JobStatus]string{
|
|
StatusPending: "⏸",
|
|
StatusQueued: "⏳",
|
|
StatusRunning: "▶",
|
|
StatusFinished: "✓",
|
|
StatusFailed: "✗",
|
|
}[j.Status]
|
|
pri := ""
|
|
if j.Priority > 0 {
|
|
pri = fmt.Sprintf(" [P%d]", j.Priority)
|
|
}
|
|
gpu := ""
|
|
if j.GPUDeviceID >= 0 {
|
|
gpu = fmt.Sprintf(" [GPU:%d %d%%]", j.GPUDeviceID, j.GPUUtilization)
|
|
}
|
|
|
|
// Apply status color to the status text
|
|
statusStyle := lipgloss.NewStyle().Foreground(StatusColor(j.Status))
|
|
coloredStatus := statusStyle.Render(string(j.Status))
|
|
|
|
return fmt.Sprintf("%s %s%s%s", icon, coloredStatus, pri, gpu)
|
|
}
|
|
|
|
// FilterValue returns the value used for filtering
|
|
func (j Job) FilterValue() string { return j.Name }
|