runner

package
v0.0.0-...-90deddd Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	pool.Pool

	// Allocate reserves an alloc of at least min, and at most max resources.
	// The cluster may scale elastically in order to meet this demand.
	// Labels are passed down to the underlying pool.
	Allocate(ctx context.Context, req reflow.Requirements, labels pool.Labels) (pool.Alloc, error)

	// CanAllocate returns whether this cluster can allocate the given amount of resources.
	CanAllocate(reflow.Resources) (bool, error)

	// MaxAlloc returns the max resources which can be obtained in a single alloc from this cluster.
	MaxAlloc() reflow.Resources

	// GetName returns the name of the cluster
	GetName() string
}

Cluster is a kind of pool.Pool that also allows the user to directly reserve an alloc. This way, the cluster can be responsive to demand.

type Phase

type Phase int

Phase enumerates the possible phases of a run.

const (
	// Init indicates the run is needs initialization.
	Init Phase = iota
	// Eval indicates the run needs evaluation.
	Eval
	// Retry indicates the run needs to be considered for retrying.
	Retry
	// Done indicates the run is complete.
	Done

	// MaxPhase is the maximum value of Phase.
	MaxPhase
)

func (Phase) String

func (i Phase) String() string

type Runner

type Runner struct {
	// State contains the state of the run. The user can serialize
	// this in order to resume runs.
	State

	flow.EvalConfig

	// Flow is the flow to be evaluated.
	Flow *flow.Flow

	// Type is the type of output. When Type is nil, it is taken to be
	// (legacy) reflow.Fileset.
	Type *types.T

	// Transferer is the transfer manager used for node-to-node data
	// transfers.
	Transferer reflow.Transferer

	// Labels are the set of labels affiliated with this run.
	Labels pool.Labels

	// Cmdline is a debug string with program name, params and args.
	Cmdline string
}

A Runner is responsible for evaluating a flow.Flow on a cluster.

func (*Runner) Do

func (r *Runner) Do(ctx context.Context) bool

Do steps the runner state machine. Do returns true whenever it can make more progress, thus a caller should call Do in a loop:

for r.Do(ctx) {
	// report progress, save state, etc.
}

func (*Runner) Eval

func (r *Runner) Eval(ctx context.Context) (string, error)

Eval evaluates the flow, returning the resulting Value.

type State

type State struct {
	// ID is this run's global ID.
	ID taskdb.RunID
	// Program stores the reflow program name.
	Program string
	// Params is the run parameters
	Params map[string]string
	// Args stores the run arguments
	Args []string
	// Phase holds the current phase of the run.
	Phase Phase
	// Value contains the result of the evaluation,
	// rendered as a string.
	// TODO(marius): serialize the value into JSON.
	Result string
	// Err contains runtime errors.
	Err *errors.Error
	// AttemptNumber is the evaluation attempt number.
	AttemptNumber int
	// LastTry is the timestamp of the last evaluation attempt.
	LastTry time.Time
	// Created is the time of the run's creation.
	Created time.Time
	// Completion is the time of the run's completion.
	Completion time.Time

	// TotalResources stores the total amount of resources used
	// by this run. Note that the resources are in resource-minutes.
	TotalResources reflow.Resources
}

State contains the full state of a run. A State can be serialized and later recovered in order to resume a run.

func (*State) Reset

func (s *State) Reset()

Reset resets the state so that it will reinitialize if run. Run metadata (including its name) are preserved.

func (State) String

func (s State) String() string

String returns a string representation of the state.

type TracingCluster

type TracingCluster struct {
	Cluster
}

TracingCluster is a cluster that traces the actions of an underlying cluster manager.

Jump to

Keyboard shortcuts

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