Documentation
¶
Overview ¶
Package batch loads, resolves, and runs imagine batch files (YAML/JSON describing multiple jobs in one invocation).
Pipeline:
LoadFile → *Spec (raw entries, format-detected by extension) Resolve → []Resolved (CLI defaults + entry overrides, validated) Run → exit-code (parallel api.RunGeneration per entry)
Each phase fails fast and exhaustively at validation boundaries so users see every problem in one error rather than chasing them one at a time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBatchFile ¶
IsBatchFile reports whether path's extension marks it as a batch file (.yaml/.yml/.json). Delegates to paths.IsBatchFile so cli and batch always agree.
func Run ¶
Run fans every resolved entry out to api.RunGeneration in parallel, reports per-entry success/failure as a styled summary table, and returns a non-nil error if any image failed. maxParallel caps the total number of in-flight provider calls — across both the per-entry axis here and the per-image axis inside each orchestrator — by sharing a single semaphore through api.Params.Sem. 0 means unlimited (the original behaviour). The cap is a sliding window: the next queued goroutine starts the instant any in-flight one finishes, not in fixed waves.
Types ¶
type Entry ¶
type Entry struct {
// Key is the entry's identity in the file. Map-form: the YAML/JSON
// key (e.g. "hero_shot"). List-form: empty string.
Key string
// Index is the entry's 0-based position for ordering and error
// messages.
Index int
// Raw is every key/value pair under this entry, as decoded by the
// YAML or JSON parser. Values are scalars (string/int/float64/bool)
// or, where flagspec accepts coercion, lenient near-equivalents.
Raw map[string]any
}
Entry is one job's raw values from the batch file. Common-flag and provider-private fields aren't separated here — that happens during Resolve once the entry's effective provider is known.
type EntryResult ¶
type EntryResult struct {
Resolved Resolved
Output api.GenerationOutput
}
EntryResult is one entry's outcome after running.
type ResolveContext ¶
type ResolveContext struct {
Spec *Spec
CLIOptions *cli.Options
Cmd *cobra.Command
Config *config.Config
DefaultProvider string
}
ResolveContext is everything Resolve needs: the parsed spec, the CLI's already-bound common options, the cobra command (so the resolver can ask which flags the user *explicitly* set), the loaded config, and the resolved global default provider.
type Resolved ¶
type Resolved struct {
Key string
Index int
DisplayName string // "hero_shot" or "[2]"
Provider providers.Provider
Bundle providers.Bundle
Request providers.Request
Params api.Params
ProviderOpts any
}
Resolved is one entry with all inputs resolved against CLI defaults and ready for the orchestrator.
func Resolve ¶
func Resolve(rc ResolveContext) ([]Resolved, error)
Resolve walks every entry, fills in defaults from the CLI invocation, validates all of them up front, and returns the resolved jobs. It fails fast on parse errors at the entry level but collects the rest into a single multi-line error so users see every problem at once rather than fixing them one at a time.