job

package
v0.3.27 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: Apache-2.0 Imports: 14 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 ComputeVerifiedSummary

func ComputeVerifiedSummary(j *model.JobWithInfo) string

func ConstructDockerJob

func ConstructDockerJob(
	ctx context.Context,
	a model.APIVersion,
	e model.Engine,
	v model.Verifier,
	p model.PublisherSpec,
	cpu, memory, gpu string,
	network model.Network,
	domains []string,
	inputs []model.StorageSpec,
	outputVolumes []string,
	env []string,
	entrypoint []string,
	image string,
	concurrency int,
	confidence int,
	minBids int,
	timeout float64,
	annotations []string,
	nodeSelector string,
	workingDir string,
) (*model.Job, error)

these are util methods for the CLI to pass in the collection of CLI args as strings and have a Job struct returned

func ConstructLanguageJob

func ConstructLanguageJob(
	ctx context.Context,
	inputs []model.StorageSpec,
	outputVolumes []string,
	concurrency int,
	confidence int,
	minBids int,
	timeout float64,

	language string,
	languageVersion string,
	command string,
	programPath string,
	requirementsPath string,
	deterministic bool,
	annotations []string,
) (*model.Job, error)

func CountVerifiedExecutionStates added in v0.3.24

func CountVerifiedExecutionStates(jobState model.JobState) int

func FlattenExecutionStates

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

func GetCompletedExecutionStates added in v0.3.24

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

func GetCompletedVerifiedExecutionStates added in v0.3.24

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

return only execution states that are both complete and verified

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 GetJobConcurrency

func GetJobConcurrency(j model.Job) int

func IsSafeAnnotation

func IsSafeAnnotation(s string) bool

func ParseNodeSelector

func ParseNodeSelector(nodeSelector string) ([]model.LabelSelectorRequirement, 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 ShortID

func ShortID(id string) string

ShortID shortens a Job ID e.g. `c42603b4-b418-4827-a9ca-d5a43338f2fe` to `c42603b4`

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, or when confidence factor is lower than concurrency. 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

type ExecutionStateChecker added in v0.3.24

type ExecutionStateChecker func(
	executionStates []model.ExecutionState,
	concurrency int,
) (bool, error)

type JobLoader

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

type StateLoader

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

func NewNoopStateLoader added in v0.3.26

func NewNoopStateLoader() StateLoader

type StateResolver

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

func NewStateResolver

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

func (*StateResolver) CheckExecutionStates added in v0.3.24

func (resolver *StateResolver) CheckExecutionStates(
	ctx context.Context,
	job model.Job,
	executionStateChecker ExecutionStateChecker,
) (bool, error)

iterate each execution and pass off []model.ExecutionState to the given function every execution must return true for this function to return true this is useful for example to say "do we have enough to begin verification"

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) ResultSummary

func (resolver *StateResolver) ResultSummary(ctx context.Context, jobID string) (string, 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) VerifiedSummary

func (resolver *StateResolver) VerifiedSummary(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