localrun

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package localrun executes job DAGs locally without a running server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenEphemeralDB

func OpenEphemeralDB() (*gorm.DB, func(), error)

OpenEphemeralDB creates an in-memory SQLite database with all models migrated. The returned cleanup function closes the database.

Types

type Config

type Config struct {
	MaxParallel int
	TaskTimeout time.Duration
	RunTimeout  time.Duration
	Env         map[string]string // extra env vars injected into every task
	OnPrepared  func(store *run.Store, db *gorm.DB, jobModel *models.Job) error
	// EngineFactory overrides EVERY engine kind (docker, kubernetes, podman)
	// job.New dispatches steps through — a step's declared `engine:` picks
	// which of job.WithDockerEngineFactory/WithKubernetesEngineFactory/
	// WithPodmanEngineFactory job.New actually calls, and this field is wired
	// into all three identically, so a test fixture is never silently routed
	// to a real runtime just because a step used `engine: podman` or
	// `engine: kubernetes` instead of the (default) docker. nil (the default)
	// leaves job.New's own defaults in place, which drive real container
	// runtimes. Tests that need a hermetic run inject a fake engine here (see
	// internal/localrun/runner_test.go).
	EngineFactory func(context.Context) atom.Engine
}

Config controls local runner behaviour.

type Display

type Display struct {
	Writer io.Writer
}

Display renders task progress to a terminal.

func (*Display) RenderHeader

func (d *Display) RenderHeader(alias string, path string)

RenderHeader prints a header line for a dev run.

func (*Display) RenderProgress

func (d *Display) RenderProgress(tasks []TaskProgress)

RenderProgress prints a simple task status table.

type RunResult

type RunResult struct {
	RunID  uuid.UUID
	JobID  uuid.UUID
	Alias  string
	Status string
	Error  string
	Tasks  []TaskResult
}

RunResult captures the persisted outcome of a local run for harness assertions.

type Runner

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

Runner executes a job definition against an ephemeral in-memory database and the local container runtime.

func New

func New(cfg Config) *Runner

New creates a Runner with the given configuration.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, def *schema.Definition) error

Run parses, imports, and executes the definition.

func (*Runner) RunWithResult

func (r *Runner) RunWithResult(ctx context.Context, def *schema.Definition) (*RunResult, error)

RunWithResult parses, imports, executes, and returns the persisted run result.

type TaskProgress

type TaskProgress struct {
	Name     string
	Status   string // pending, running, succeeded, failed, skipped
	Duration time.Duration
	Error    string
}

TaskProgress represents the status of a single task during a local run.

type TaskResult

type TaskResult struct {
	TaskID uuid.UUID
	Name   string
	// Partition is set for each materialized instance of a fanned step (one
	// TaskResult per partition, Name rendered as "step[partition]"); empty for
	// unfanned steps.
	Partition        string
	Status           string
	Output           map[string]string
	SchemaViolations []pkgtask.SchemaViolation
	LogText          string
	LogTruncated     bool
	CacheHit         bool
	Error            string
}

TaskResult captures the persisted outcome of one task execution.

Jump to

Keyboard shortcuts

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