web

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package web builds Web-facing projections of Rotari state.

It loads persisted model and state data into JSON-ready structures for the Web UI, including runs, jobs, attempts, timelines, origins, and display times. It should present state for the UI without changing queue or run semantics.

Index

Constants

View Source
const (
	HistorySearchProject     = "project"
	HistorySearchRun         = "run"
	HistorySearchJob         = "job"
	HistorySearchPageSize    = 50
	HistorySearchMaxPageSize = 200
)

Variables

This section is empty.

Functions

func FormatQueueDisplayTimes

func FormatQueueDisplayTimes(state *QueueState)

func ValidateHistorySearchRequest

func ValidateHistorySearchRequest(request HistorySearchRequest) error

Types

type Attempt

type Attempt struct {
	ID              string           `json:"id"`
	Result          *model.JobResult `json:"result,omitempty"`
	ExecutionStatus string           `json:"execution_status"`
	SubmittedAt     string           `json:"submitted_at,omitempty"`
	FinishedAt      string           `json:"finished_at,omitempty"`
	Elapsed         string           `json:"elapsed,omitempty"`
	SchedulerState  string           `json:"scheduler_state,omitempty"`
}

type ConfigFile

type ConfigFile struct {
	Scope   string `json:"scope,omitempty"`
	Path    string `json:"path"`
	Content string `json:"content"`
}

type EnvironmentDefinition

type EnvironmentDefinition struct {
	Name        string `json:"name"`
	Value       string `json:"value,omitempty"`
	Set         bool   `json:"set,omitempty"`
	CLIDefault  bool   `json:"cli_default"`
	Job         bool   `json:"job"`
	Array       bool   `json:"array"`
	Description string `json:"description"`
}

type HistorySearchFilter

type HistorySearchFilter struct {
	Target string `json:"target"`
	Field  string `json:"field"`
	Word   string `json:"word"`
	Join   string `json:"join,omitempty"`
}

type HistorySearchRecord

type HistorySearchRecord struct {
	BaseDirID           string
	BaseDirPath         string
	ProjectName         string
	RunID               string
	RunName             string
	RunStatus           string
	RunExitCode         *int
	RunStarted          string
	RunFinished         string
	RunHost             string
	RunWorkingDirectory string
	JobID               string
	JobName             string
	JobStatus           string
	JobStage            string
	Command             string
	Host                string
	WorkingDirectory    string
	Diagnosis           string
	Executor            string
	AttemptID           string
	JobExitCode         *int
	Timestamp           string
}

type HistorySearchRequest

type HistorySearchRequest struct {
	Target        string                `json:"target,omitempty"`
	CaseSensitive bool                  `json:"case_sensitive,omitempty"`
	Fuzzy         bool                  `json:"fuzzy,omitempty"`
	Filters       []HistorySearchFilter `json:"filters"`
	From          string                `json:"from,omitempty"`
	To            string                `json:"to,omitempty"`
	Offset        int                   `json:"offset,omitempty"`
	Limit         int                   `json:"limit,omitempty"`
}

type HistorySearchResponse

type HistorySearchResponse struct {
	Rows   []HistorySearchRow `json:"rows"`
	Total  int                `json:"total"`
	Offset int                `json:"offset"`
	Limit  int                `json:"limit"`
}

func SearchHistory

func SearchHistory(records []HistorySearchRecord, request HistorySearchRequest) (HistorySearchResponse, error)

SearchHistory evaluates conditions against the selected hierarchy level. When conditions target multiple levels, results use the most specific level; parent-level conditions are evaluated against each result's ancestors.

type HistorySearchRow

type HistorySearchRow struct {
	Target      string `json:"target"`
	BaseDirID   string `json:"basedir_id"`
	BaseDirPath string `json:"basedir_path"`
	ProjectName string `json:"project_name"`
	RunID       string `json:"run_id,omitempty"`
	RunName     string `json:"run_name,omitempty"`
	RunStatus   string `json:"run_status,omitempty"`
	JobID       string `json:"job_id,omitempty"`
	JobName     string `json:"job_name,omitempty"`
	JobStatus   string `json:"job_status,omitempty"`
	Command     string `json:"command,omitempty"`
	Timestamp   string `json:"timestamp,omitempty"`
}

type HistorySearchScope

type HistorySearchScope struct {
	BaseDirID   string `json:"basedir_id"`
	ProjectName string `json:"project_name,omitempty"`
	RunID       string `json:"run_id,omitempty"`
}

type Job

type Job struct {
	ID                string    `json:"id"`
	AttemptID         string    `json:"attempt_id,omitempty"`
	Attempts          []Attempt `json:"attempts,omitempty"`
	ArrayTaskID       *int      `json:"array_task_id,omitempty"`
	ArrayFirst        int       `json:"array_first,omitempty"`
	ArrayLast         int       `json:"array_last,omitempty"`
	Name              string    `json:"name,omitempty"`
	Stage             string    `json:"stage,omitempty"`
	Command           []string  `json:"command"`
	WorkingDirectory  string    `json:"working_directory,omitempty"`
	Executor          string    `json:"executor,omitempty"`
	ExecutorOptions   []string  `json:"executor_options,omitempty"`
	LogMode           string    `json:"log_mode,omitempty"`
	DependsOn         []string  `json:"depends_on,omitempty"`
	DependsOnFinished []string  `json:"depends_on_finished,omitempty"`
	// Matrix places a matrix member in its group's grid.
	Matrix          *Matrix          `json:"matrix,omitempty"`
	Result          *model.JobResult `json:"result,omitempty"`
	Origin          *model.JobOrigin `json:"origin,omitempty"`
	Carried         bool             `json:"carried,omitempty"`
	ExecutionStatus string           `json:"execution_status"`
	AttemptDir      string           `json:"-"`
	// Environment is the job's own NAME=VALUE environment, matrix values
	// included, for the run report. The Web API leaves it out: values given
	// with --env may be secrets.
	Environment []string `json:"-"`
	SubmittedAt string   `json:"submitted_at,omitempty"`
	FinishedAt  string   `json:"finished_at,omitempty"`
	// Elapsed is how long the job ran, as `rotari jobs` shows it ("3m 05s");
	// set with the display times.
	Elapsed        string `json:"elapsed,omitempty"`
	SchedulerState string `json:"scheduler_state,omitempty"`
	Final          bool   `json:"final,omitempty"`
	// DiagnosisOutdated reports that Result's saved rule-based analysis was
	// produced by earlier diagnosis rules.
	DiagnosisOutdated bool `json:"diagnosis_outdated,omitempty"`
	// NoteLabels are the run's notes on this job, oldest first, each as
	// model.FormatRunNote describes it without the job, naming the attempt
	// when it is not the job's latest.
	NoteLabels []string `json:"note_labels,omitempty"`
	// contains filtered or unexported fields
}

func LoadJobs

func LoadJobs(store state.Store, runDir string, files state.RunSnapshot, selectedAttemptID string) ([]Job, error)

LoadJobs projects a run's jobs for the Web UI. Each job's result follows the shared jobstatus fallback chain. A non-empty selectedAttemptID shows that attempt, instead of the latest one, for its job.

func LoadRunJobs

func LoadRunJobs(store state.Store, runDir string, selectedAttemptID string) ([]Job, error)

LoadRunJobs reads runDir's run files and projects its jobs with LoadJobs.

type JobLane

type JobLane struct {
	JobID   string `json:"job_id"`
	Start   string `json:"start,omitempty"`
	End     string `json:"end,omitempty"`
	Carried bool   `json:"carried,omitempty"`
}

JobLane is one job's span on the run page's job timeline, in RFC 3339: from its submission to its finish, by the same rules as BuildTimeline. Start is empty for a job not yet submitted and End for one still running. A carried job ran in an earlier run, so it has no span here.

func BuildJobLanes

func BuildJobLanes(runFinishedAt string, jobs []JobTimelineInput) []JobLane

BuildJobLanes returns one lane per job, in the jobs' order.

type JobTimelineInput

type JobTimelineInput struct {
	JobID       string
	Finished    bool
	Carried     bool
	SubmittedAt string
	FinishedAt  string
	Success     bool
}

type Matrix

type Matrix struct {
	GroupID    string                  `json:"group_id"`
	BaseName   string                  `json:"base_name,omitempty"`
	Dimensions []model.MatrixDimension `json:"dimensions"`
	Values     []model.MatrixValue     `json:"values"`
}

Matrix is the part of a job's matrix provenance the Web UI needs to draw a grid. It omits the base environment, which may hold secrets.

type QueueLoader

type QueueLoader struct {
	ProjectName string
	Paths       state.ProjectPaths
	Queue       func() (model.Queue, error)
	Lock        func() (model.LockInfo, error)
	Runs        func() ([]string, error)
	Summary     func(runID string) (model.RunSummary, error)
	Jobs        func(runID string, summary model.RunSummary) ([]Job, error)
	Context     func(runID string) (model.RunContext, error)
	Sources     func(runID string) (model.RunSources, bool, error)
	Notes       func(runID string) ([]model.RunNote, error)
	Samples     func(runID string) []model.LoadSample
}

type QueueState

type QueueState struct {
	QueueName       string               `json:"project_name"`
	ConfigPath      string               `json:"config_path,omitempty"`
	ConfigSources   []model.ConfigSource `json:"config_sources,omitempty"`
	Queue           model.Queue          `json:"queue"`
	Runs            []Run                `json:"runs"`
	RunCount        int                  `json:"run_count"`
	Revision        string               `json:"revision,omitempty"`
	RunnerPID       int                  `json:"runner_pid,omitempty"`
	RunningRunID    string               `json:"running_run_id,omitempty"`
	RunnerHost      string               `json:"runner_host,omitempty"`
	RunnerStartedAt string               `json:"runner_started_at,omitempty"`
	// Server is the persisted record of the project's supervisor, which
	// exists only while a run is starting or active.
	Server ServerState `json:"server"`
}

func LoadQueueState

func LoadQueueState(loader QueueLoader) (QueueState, error)

type Run

type Run struct {
	model.RunSummary
	LineageSummary runlineage.RunSummary `json:"lineage_summary,omitempty"`
	Jobs           []Job                 `json:"jobs"`
	Lifecycle      string                `json:"lifecycle,omitempty"`
	ClientStatus   model.RunClientStatus `json:"client_status"`
	ClientLabel    string                `json:"client_label,omitempty"`
	CWD            string                `json:"cwd,omitempty"`
	Context        model.RunContext      `json:"context,omitempty"`
	// Sources is the code the run's executed jobs ran from, and SourceLabels
	// each as model.SourceLabel describes it for `show`.
	Sources      []model.SourceRevision `json:"sources,omitempty"`
	SourceLabels []string               `json:"source_labels,omitempty"`
	// Notes are the run's notes, oldest first, including those on its jobs.
	// The run page shows the run's own notes in its report, and a job's
	// behind the job's Notes button, from Job.NoteLabels.
	Notes    []model.RunNote `json:"notes,omitempty"`
	Timeline []TimelinePoint `json:"timeline,omitempty"`
	// Lanes are the jobs' spans for the run page's job timeline.
	Lanes   []JobLane `json:"lanes,omitempty"`
	Running bool      `json:"running"`
	// Unreadable, when set, is why the run's files cannot be read: they come
	// from a newer rotari. The run then has status "unreadable" and no jobs.
	Unreadable string `json:"unreadable,omitempty"`
}

type ServerState

type ServerState struct {
	PID           int  `json:"pid,omitempty"`
	PIDFileExists bool `json:"pid_file_exists"`
}

type State

type State struct {
	BaseDir       string                  `json:"base_dir"`
	ConfigPath    string                  `json:"config_path,omitempty"`
	ConfigSources []model.ConfigSource    `json:"config_sources,omitempty"`
	Queues        []QueueState            `json:"projects"`
	Environments  []EnvironmentDefinition `json:"environments"`
	UpdatedAt     string                  `json:"updated_at"`
}

type TimelinePoint

type TimelinePoint struct {
	At       string `json:"at"`
	Pending  int    `json:"pending"`
	Running  int    `json:"running"`
	Finished int    `json:"finished"`
	Success  int    `json:"success"`
	Failed   int    `json:"failed"`
}

func BuildTimeline

func BuildTimeline(startedAt, runFinishedAt string, jobs []JobTimelineInput) []TimelinePoint

Jump to

Keyboard shortcuts

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