debuginfo

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package debuginfo provides detailed workflow metadata parsing for debugging and analysis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSubWorkflowChildren

func AddSubWorkflowChildren(node *TreeNode, subWM *WorkflowMetadata, baseDepth int)

AddSubWorkflowChildren adds the calls from a subworkflow as children of the given node.

func AggregateStatus

func AggregateStatus(calls []CallDetails) string

AggregateStatus returns the aggregate status for a list of calls. Priority: Running > Done > Failed > Preempted This ensures that if a shard is retrying after a preemption, it shows as Running, not Done (from the previous successful attempt that was preempted).

func CalculatePreemptionStats

func CalculatePreemptionStats(calls map[string][]CallDetails)

CalculatePreemptionStats calculates preemption statistics for all calls. It groups calls by task name and shard, then calculates stats for each group.

func ConvertToCallData

func ConvertToCallData(calls map[string][]CallDetails) map[string][]preemption.CallData

ConvertToCallData converts CallDetails to preemption.CallData.

func EarliestStart

func EarliestStart(calls []CallDetails) time.Time

EarliestStart returns the earliest start time from a list of calls.

func FormatBytes

func FormatBytes(b int64) string

FormatBytes formats bytes into a human-readable string.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration in a human-readable format.

func LatestEnd

func LatestEnd(calls []CallDetails) time.Time

LatestEnd returns the latest end time from a list of calls.

func ParseCPU

func ParseCPU(s string) float64

ParseCPU parses CPU string (e.g., "4", "4.0") to float64.

func ParseMemoryGB

func ParseMemoryGB(s string) float64

ParseMemoryGB parses memory string (e.g., "8 GB", "8GB", "8192 MB") to GB.

Types

type CallDetails

type CallDetails struct {
	// Identification
	Name       string
	ShardIndex int
	Attempt    int
	JobID      string

	// Status
	ExecutionStatus string
	BackendStatus   string
	ReturnCode      *int

	// Timing
	Start       time.Time
	End         time.Time
	VMStartTime time.Time
	VMEndTime   time.Time

	// Execution
	CommandLine string
	Backend     string
	CallRoot    string

	// Logs
	Stdout        string
	Stderr        string
	MonitoringLog string

	// Docker
	DockerImage     string
	DockerImageUsed string
	DockerSize      string

	// Resources
	CPU         string
	Memory      string
	Disk        string
	Preemptible string
	Zones       string

	// Cache
	CacheHit    bool
	CacheResult string

	// Cost
	VMCostPerHour float64

	// Preemption stats (calculated from all attempts of this task)
	PreemptionStats *PreemptionStats

	// Inputs/Outputs
	Inputs  map[string]interface{}
	Outputs map[string]interface{}

	// Events
	ExecutionEvents []ExecutionEvent

	// Labels
	Labels map[string]string

	// Failures (task-level errors)
	Failures []Failure

	// SubWorkflow
	SubWorkflowID       string
	SubWorkflowMetadata *WorkflowMetadata

	// Cache for expensive calculations
	EfficiencyReport *monitoring.EfficiencyReport
}

CallDetails contains detailed information about a call/task.

type DebugInfo

type DebugInfo struct {
	Metadata   *WorkflowMetadata
	Root       *TreeNode
	Visible    []*TreeNode
	Preemption *WorkflowPreemptionSummary
}

DebugInfo is a high-level composite used by UI layers to render debug views.

type ExecutionEvent

type ExecutionEvent struct {
	Description string
	Start       time.Time
	End         time.Time
}

ExecutionEvent represents a single execution event in the timeline.

type Failure

type Failure struct {
	Message  string
	CausedBy []Failure
}

Failure represents a workflow or task failure with its cause chain.

type NodeType

type NodeType int

NodeType represents the type of node in the call tree.

const (
	NodeTypeWorkflow NodeType = iota
	NodeTypeCall
	NodeTypeSubWorkflow
	NodeTypeShard
)

type PreemptionStats

type PreemptionStats struct {
	TotalAttempts   int     // Total number of attempts for this task/shard
	PreemptedCount  int     // Number of times preempted (attempts - 1)
	IsPreemptible   bool    // Whether the task was configured as preemptible
	EfficiencyScore float64 // 1.0 = first try success, lower = more preemptions
	MaxPreemptible  int     // Max preemptible attempts from config
}

PreemptionStats holds preemption efficiency data for a task.

type ProblematicTask

type ProblematicTask struct {
	Name            string
	ShardCount      int     // Number of shards (0 or 1 means non-scattered)
	Attempts        int     // Total attempts across all shards
	Preemptions     int     // Total preemptions across all shards
	EfficiencyScore float64 // Average efficiency across all shards

	// Cost-weighted metrics
	TotalCost      float64 // Total cost across all shards (resource-hours)
	WastedCost     float64 // Cost of failed attempts (resource-hours)
	CostEfficiency float64 // 1 - (WastedCost / TotalCost)
	ImpactPercent  float64 // WastedCost / WorkflowTotalWastedCost × 100
}

ProblematicTask represents a task with poor preemption efficiency.

type TreeNode

type TreeNode struct {
	ID            string
	Name          string
	Type          NodeType
	Status        string
	Duration      time.Duration
	Start         time.Time
	End           time.Time
	Expanded      bool
	Children      []*TreeNode
	Parent        *TreeNode
	CallData      *CallDetails
	SubWorkflowID string
	Depth         int
}

TreeNode represents a node in the workflow call tree.

func BuildTree

func BuildTree(wm *WorkflowMetadata) *TreeNode

BuildTree builds a tree structure from WorkflowMetadata.

func GetVisibleNodes

func GetVisibleNodes(root *TreeNode) []*TreeNode

GetVisibleNodes returns a flat list of visible nodes for rendering.

type Usecase

type Usecase interface {
	ParseMetadata(data []byte) (*WorkflowMetadata, error)
	BuildTree(wm *WorkflowMetadata) *TreeNode
	GetVisibleNodes(root *TreeNode) []*TreeNode
	AddSubWorkflowChildren(node *TreeNode, subWM *WorkflowMetadata, baseDepth int)
	CalculateWorkflowPreemptionSummary(workflowID, workflowName string, calls map[string][]CallDetails) *WorkflowPreemptionSummary
	// High-level orchestration: parse metadata, build tree, visible nodes, and preemption summary
	GetDebugInfo(data []byte) (*DebugInfo, error)
}

Usecase defines the public operations the UI or other parts of the application use for debugging workflows.

func NewUsecase

func NewUsecase(analyzer *preemption.Analyzer) Usecase

NewUsecase creates a new Usecase instance.

type WorkflowMetadata

type WorkflowMetadata struct {
	// Basic info
	ID           string
	Name         string
	Status       string
	Start        time.Time
	End          time.Time
	WorkflowRoot string
	WorkflowLog  string

	// Submitted files
	SubmittedWorkflow string
	SubmittedInputs   string
	SubmittedOptions  string

	// Language
	WorkflowLanguage        string
	WorkflowLanguageVersion string

	// Calls (task name -> list of call attempts/shards)
	Calls map[string][]CallDetails

	// Outputs
	Outputs map[string]interface{}

	// Inputs
	Inputs map[string]interface{}

	// Labels
	Labels map[string]string

	// Failures (workflow-level errors before calls execute)
	Failures []Failure
}

WorkflowMetadata contains the full workflow metadata.

func ParseMetadata

func ParseMetadata(data []byte) (*WorkflowMetadata, error)

ParseMetadata parses raw JSON metadata into WorkflowMetadata.

type WorkflowPreemptionSummary

type WorkflowPreemptionSummary struct {
	TotalTasks        int               // Total number of tasks/shards
	PreemptibleTasks  int               // Number of preemptible tasks
	TotalAttempts     int               // Total attempts across all tasks
	TotalPreemptions  int               // Total preemptions across all tasks
	OverallEfficiency float64           // Average efficiency (0-1)
	ProblematicTasks  []ProblematicTask // Tasks with low efficiency

	// Cost-weighted metrics
	TotalCost      float64 // Total cost of all attempts (resource-hours)
	WastedCost     float64 // Cost of failed attempts (resource-hours)
	CostEfficiency float64 // 1 - (WastedCost / TotalCost)
	CostUnit       string  // Unit for cost display (e.g., "resource-hours")
}

WorkflowPreemptionSummary holds aggregated preemption stats for a workflow.

func CalculateWorkflowPreemptionSummary

func CalculateWorkflowPreemptionSummary(workflowID, workflowName string, calls map[string][]CallDetails) *WorkflowPreemptionSummary

CalculateWorkflowPreemptionSummary aggregates preemption stats across all calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL