legacyjob

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

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

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

func GetExecutionStateTotals

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

func GetFilteredExecutionStates

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

func GetIPFSPublishedStorageSpec

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

func IsSafeAnnotation

func IsSafeAnnotation(s string) bool

func MakeDockerSpec

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

func MakeSpec

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

func MakeWasmSpec

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

func ParseStorageString

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

func PublisherStringToPublisherSpec

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

func RawPublisherStringToPublisherSpec

func RawPublisherStringToPublisherSpec(publisher string) (model.PublisherSpec, error)

RawPublisherStringToPublisherSpec is a legacy function for converting a raw string into a model.PublisherSpec.

func SafeAnnotationRegex

func SafeAnnotationRegex() *regexp.Regexp

func SafeStringStripper

func SafeStringStripper(s string) string

func ValidateWorkingDir

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

cspell:ignore Dont 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

func WaitForUnsuccessfulCompletion() CheckStatesFunction

type JobLoader

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

type SpecOpt

type SpecOpt func(s *model.Spec) error

func WithAnnotations

func WithAnnotations(annotations ...string) SpecOpt

func WithDeal

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

func WithDockerEngine

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

func WithEngineSpec

func WithEngineSpec(e model.EngineSpec) SpecOpt

func WithInputs

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

func WithNetwork

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

func WithNodeSelector

func WithNodeSelector(selector []model.LabelSelectorRequirement) SpecOpt

func WithOutputs

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

func WithPublisher

func WithPublisher(p model.PublisherSpec) SpecOpt

func WithResources

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

func WithTimeout

func WithTimeout(t int64) SpecOpt

func WithWasmEngine

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

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