progress

package
v6.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

OrderedPhases defines the progression order (including completed terminal for simplicity).

Functions

func ForceMetricsSave

func ForceMetricsSave()

ForceMetricsSave forces metrics write (for tests).

func MarshalProgressReport

func MarshalProgressReport(pr *ProgressReport) []byte

MarshalProgressReport pretty prints a report.

func ResetMetricsForTest

func ResetMetricsForTest()

ResetMetricsForTest clears metrics (for tests).

Types

type Phase

type Phase string

Phase represents a canonical generation phase.

const (
	PhaseSetup         Phase = "setup"
	PhaseBasePrompts   Phase = "base_prompts"
	PhaseEnhance       Phase = "enhance_prompt"
	PhaseImagePrep     Phase = "image_prep"
	PhaseImageWait     Phase = "image_wait"
	PhaseImageDownload Phase = "image_download"
	PhaseAnnotate      Phase = "annotate"
	PhaseFailed        Phase = "failed"
	PhaseCompleted     Phase = "completed"
)

type PhaseTiming

type PhaseTiming struct {
	Name      Phase  `json:"name"`
	StartedNs int64  `json:"startedNs"`
	EndedNs   int64  `json:"endedNs"`
	Skipped   bool   `json:"skipped"`
	Error     string `json:"error"`
}

PhaseTiming captures timing and status per phase.

type ProgressManager

type ProgressManager struct {
	// contains filtered or unexported fields
}

ProgressManager manages concurrent runs and global averages.

func GetProgressManager

func GetProgressManager() *ProgressManager

func (*ProgressManager) Complete

func (pm *ProgressManager) Complete(series, addr string)

Complete finalizes the run.

func (*ProgressManager) Fail

func (pm *ProgressManager) Fail(series, addr string, err error)

Fail marks an error completion.

func (*ProgressManager) GetReport

func (pm *ProgressManager) GetReport(series, addr string) *ProgressReport

GetReport returns a snapshot; discards run if done.

func (*ProgressManager) MarkCacheHit

func (pm *ProgressManager) MarkCacheHit(series, addr string)

MarkCacheHit notes a cache hit.

func (*ProgressManager) Skip

func (pm *ProgressManager) Skip(series, addr string, ph Phase)

Skip marks a phase skipped.

func (*ProgressManager) StartRun

func (pm *ProgressManager) StartRun(series, addr string, dress *model.DalleDress)

StartRun initializes a run if not present.

func (*ProgressManager) Transition

func (pm *ProgressManager) Transition(series, addr string, ph Phase)

Transition ends current phase and starts the next.

func (*ProgressManager) UpdateDress

func (pm *ProgressManager) UpdateDress(series, addr string, fn func(*model.DalleDress))

UpdateDress mutates the underlying DalleDress for a run under the manager lock. Use for progress-relevant field changes to reduce race potential when reusing the pointer.

type ProgressReport

type ProgressReport struct {
	Series        string                  `json:"series"`
	Address       string                  `json:"address"`
	Current       Phase                   `json:"currentPhase"`
	StartedNs     int64                   `json:"startedNs"`
	Percent       float64                 `json:"percent"`
	ETASeconds    float64                 `json:"etaSeconds"`
	Done          bool                    `json:"done"`
	Error         string                  `json:"error"`
	CacheHit      bool                    `json:"cacheHit"`
	Phases        []*PhaseTiming          `json:"phases"`
	DalleDress    *model.DalleDress       `json:"dalleDress"`
	PhaseAverages map[Phase]time.Duration `json:"phaseAverages"`
}

ProgressReport is a snapshot of a run.

func ActiveProgressReports

func ActiveProgressReports() []*ProgressReport

ActiveProgressReports returns a slice of snapshots for all in-progress (non-completed) runs. Completed runs are pruned (same behavior as GetReport) and are not returned. This enables callers (e.g. a status printer goroutine) to periodically inspect active work without mutating phase timing state beyond pruning finished runs.

func GetProgress

func GetProgress(series, addr string) *ProgressReport

GetProgress returns the current progress report (public helper).

Jump to

Keyboard shortcuts

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