job

package
v1.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const RegexString = "A-Za-z0-9._~!:@,;+-"

Variables

This section is empty.

Functions

func ComputeResultsSummary

func ComputeResultsSummary(j *model.JobWithInfo) string

func ComputeStateSummary

func ComputeStateSummary(j model.JobState) string

func FlattenExecutionStates

func FlattenExecutionStates(jobState model.JobState) []model.ExecutionState

func GetCompletedExecutionStates added in v0.3.24

func GetCompletedExecutionStates(jobState model.JobState) []model.ExecutionState

func GetExecutionStateTotals added in v0.3.24

func GetExecutionStateTotals(executionStates []model.ExecutionState) map[model.ExecutionStateType]int

func GetFilteredExecutionStates added in v0.3.24

func GetFilteredExecutionStates(jobState model.JobState, filterState model.ExecutionStateType) []model.ExecutionState

func GetIPFSPublishedStorageSpec added in v0.3.26

func GetIPFSPublishedStorageSpec(executionID string, job model.Job, storageType model.StorageSourceType, cid string) model.StorageSpec

func IsSafeAnnotation

func IsSafeAnnotation(s string) bool

func MakeDockerSpec added in v1.0.4

func MakeDockerSpec(
	image, workingdir string, entrypoint, envvar, parameters []string,
	opts ...SpecOpt,
) (model.Spec, error)

func MakeSpec added in v1.0.4

func MakeSpec(opts ...SpecOpt) (model.Spec, error)

func MakeWasmSpec added in v1.0.4

func MakeWasmSpec(
	entryModule model.StorageSpec, entrypoint string, parameters []string, envvar map[string]string, importModules []model.StorageSpec,
	opts ...SpecOpt,
) (model.Spec, error)

func ParsePublisherString added in v0.3.26

func ParsePublisherString(destinationURI string, options map[string]interface{}) (model.PublisherSpec, error)

func ParseStorageString added in v0.3.26

func ParseStorageString(sourceURI, destinationPath string, options map[string]string) (model.StorageSpec, error)

func SafeAnnotationRegex

func SafeAnnotationRegex() *regexp.Regexp

func SafeStringStripper

func SafeStringStripper(s string) string

func ValidateWorkingDir added in v1.0.4

func ValidateWorkingDir(jobWorkingDir string) error

Function for validating the workdir of a docker command.

func VerifyJob

func VerifyJob(ctx context.Context, j *model.Job) error

VerifyJob verifies that job object passed is valid.

func VerifyJobCreatePayload

func VerifyJobCreatePayload(ctx context.Context, jc *model.JobCreatePayload) error

VerifyJobCreatePayload verifies the values in a job creation request are legal.

Types

type CheckStatesFunction

type CheckStatesFunction func(model.JobState) (bool, error)

a function that is given a map of nodeid -> job states and will throw an error if anything about that is wrong

func WaitDontExceedCount

func WaitDontExceedCount(count int) CheckStatesFunction

if there are > X states then error

func WaitExecutionsThrowErrors

func WaitExecutionsThrowErrors(errorStates []model.ExecutionStateType) CheckStatesFunction

error if there are any errors in any of the states

func WaitForExecutionStates

func WaitForExecutionStates(requiredStateCounts map[model.ExecutionStateType]int) CheckStatesFunction

wait for the given number of different states to occur

func WaitForSuccessfulCompletion

func WaitForSuccessfulCompletion() CheckStatesFunction

func WaitForTerminalStates

func WaitForTerminalStates() CheckStatesFunction

WaitForTerminalStates it is possible that a job is in a terminal state, but some executions are still running, such as when one node publishes the result before others. for that reason, we consider a job to be in a terminal state when: - all executions are in a terminal state - the job is in a terminal state to account for possible retries

func WaitForUnsuccessfulCompletion added in v1.0.4

func WaitForUnsuccessfulCompletion() CheckStatesFunction

type JobLoader

type JobLoader func(ctx context.Context, id string) (model.Job, error)

type SpecOpt added in v1.0.4

type SpecOpt func(s *model.Spec) error

func WithAnnotations added in v1.0.4

func WithAnnotations(annotations ...string) SpecOpt

func WithDeal added in v1.0.4

func WithDeal(targeting model.TargetingMode, concurrency int) SpecOpt

func WithDockerEngine added in v1.0.4

func WithDockerEngine(image, workdir string, entrypoint, envvar, parameters []string) SpecOpt

func WithEngineSpec added in v1.0.4

func WithEngineSpec(e model.EngineSpec) SpecOpt

func WithInputs added in v1.0.4

func WithInputs(inputs ...model.StorageSpec) SpecOpt

func WithNetwork added in v1.0.4

func WithNetwork(network model.Network, domains []string) SpecOpt

func WithNodeSelector added in v1.0.4

func WithNodeSelector(selector []model.LabelSelectorRequirement) SpecOpt

func WithOutputs added in v1.0.4

func WithOutputs(outputs ...model.StorageSpec) SpecOpt

func WithPublisher added in v1.0.4

func WithPublisher(p model.PublisherSpec) SpecOpt

func WithResources added in v1.0.4

func WithResources(cpu, memory, disk, gpu string) SpecOpt

func WithTimeout added in v1.0.4

func WithTimeout(t int64) SpecOpt

func WithWasmEngine added in v1.0.4

func WithWasmEngine(
	entryModule model.StorageSpec,
	entrypoint string,
	parameters []string,
	envvar map[string]string,
	importModules []model.StorageSpec,
) SpecOpt

type StateLoader

type StateLoader func(ctx context.Context, id string) (model.JobState, error)

type StateResolver

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

func NewStateResolver

func NewStateResolver(
	jobLoader JobLoader,
	stateLoader StateLoader,
) *StateResolver

func (*StateResolver) GetExecutions added in v0.3.24

func (resolver *StateResolver) GetExecutions(ctx context.Context, jobID string) ([]model.ExecutionState, error)

func (*StateResolver) GetJob

func (resolver *StateResolver) GetJob(ctx context.Context, id string) (model.Job, error)

func (*StateResolver) GetJobState

func (resolver *StateResolver) GetJobState(ctx context.Context, id string) (model.JobState, error)

func (*StateResolver) GetResults

func (resolver *StateResolver) GetResults(ctx context.Context, jobID string) ([]model.PublishedResult, error)

func (*StateResolver) SetWaitTime

func (resolver *StateResolver) SetWaitTime(maxWaitAttempts int, delay time.Duration)

func (*StateResolver) StateSummary

func (resolver *StateResolver) StateSummary(ctx context.Context, jobID string) (string, error)

func (*StateResolver) Wait

func (resolver *StateResolver) Wait(
	ctx context.Context,
	jobID string,
	checkJobStateFunctions ...CheckStatesFunction,
) error

func (*StateResolver) WaitUntilComplete

func (resolver *StateResolver) WaitUntilComplete(ctx context.Context, jobID string) error

this is an auto wait where we auto calculate how many execution states we expect to see and we use that to pass to WaitForExecutionStates

func (*StateResolver) WaitWithOptions

func (resolver *StateResolver) WaitWithOptions(
	ctx context.Context,
	options WaitOptions,
	checkJobStateFunctions ...CheckStatesFunction,
) error

type WaitOptions

type WaitOptions struct {
	// the job we are waiting for
	JobID string
	// in some cases we are actually waiting for an error state
	// this switch makes that OK (i.e. we don't try to return early)
	AllowAllTerminal bool
}

Jump to

Keyboard shortcuts

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