{"modulePath":"github.com/flyteorg/flyte/flyteplugins","version":"v1.16.8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package awsbatch\n\nThis package deals with the communication with AWS-Batch and adopting its APIs to the flyte-plugin model.\n\n## Constants\n\n```go\nconst (\n\tPrimaryTaskQueueKey = \"primary_queue\"\n\tDynamicTaskQueueKey = \"dynamic_queue\"\n\tChildTaskQueueKey   = \"child_queue\"\n)\n```\n\n```go\nconst (\n\tLogStreamFormatter = \"https://console.aws.amazon.com/cloudwatch/home?region=%v#logEventViewer:group=/aws/batch/job;stream=%v\"\n\tArrayJobFormatter  = \"https://console.aws.amazon.com/batch/home?region=%v#/jobs/%v\"\n\tJobFormatter       = \"https://console.aws.amazon.com/batch/home?region=%v#/jobs/queue/arn:aws:batch:%v:%v:job-queue~2F%v/job/%v\"\n)\n```\n\n```go\nconst (\n\tArrayJobIndex = \"BATCH_JOB_ARRAY_INDEX_VAR_NAME\"\n)\n```\n\n## Functions\n\n```go\nfunc FlyteTaskToBatchInput(ctx context.Context, tCtx pluginCore.TaskExecutionContext, jobDefinition string, cfg *config2.Config) (\n\tbatchInput *batch.SubmitJobInput, err error)\n```\nNote that Name is not set on the result object. It's up to the caller to set the Name before creating the object in K8s.\n\n```go\nfunc GetJobTaskLog(jobSize int, accountID, region, queue, jobID string) *idlCore.TaskLog\n```\n\n```go\nfunc GetJobURI(jobSize int, accountID, region, queue, jobID string) string\n```\n\n```go\nfunc GetTaskLinks(ctx context.Context, taskMeta pluginCore.TaskExecutionMetadata, jobStore *JobStore, state *State) (\n\t[]*idlCore.TaskLog, []*pluginCore.ExternalResource, error)\n```\n\n```go\nfunc TerminateSubTasks(ctx context.Context, tCtx core.TaskExecutionContext, batchClient Client, reason string, metrics ExecutorMetrics) error\n```\nAttempts to terminate the AWS Job if one is recorded in the pluginState. This API is idempotent and should be safe to call multiple times on the same job. It'll result in multiple calls to AWS Batch in that case, however.\n\n```go\nfunc UpdateBatchInputForArray(_ context.Context, batchInput *batch.SubmitJobInput, arraySize int64) *batch.SubmitJobInput\n```\n\n## Types\n\n```go\ntype ArrayJobSummary map[JobPhaseType]int64\n```\n\n```go\ntype Attempt struct {\n\tLogStream string    `json:\"logStream,omitempty\"`\n\tStartedAt time.Time `json:\"startedAt,omitempty\"`\n\tStoppedAt time.Time `json:\"stoppedAt,omitempty\"`\n}\n```\n\n```go\ntype BatchServiceClient interface {\n\tSubmitJobWithContext(ctx a.Context, input *batch.SubmitJobInput, opts ...request.Option) (*batch.SubmitJobOutput, error)\n\tTerminateJobWithContext(ctx a.Context, input *batch.TerminateJobInput, opts ...request.Option) (*batch.TerminateJobOutput, error)\n\tDescribeJobsWithContext(ctx a.Context, input *batch.DescribeJobsInput, opts ...request.Option) (*batch.DescribeJobsOutput, error)\n\tRegisterJobDefinitionWithContext(ctx a.Context, input *batch.RegisterJobDefinitionInput, opts ...request.Option) (*batch.RegisterJobDefinitionOutput, error)\n}\n```\nBatchServiceClient is an interface on top of the native AWS Batch client to allow for mocking and alternative implementations.\n\n```go\ntype Client interface {\n\t// Submits a new job to AWS Batch and retrieves job info. Note that submitted jobs will not have status populated.\n\tSubmitJob(ctx context.Context, input *batch.SubmitJobInput) (jobID string, err error)\n\n\t// Attempts to terminate a job. If the job hasn't started yet, it'll just get deleted.\n\tTerminateJob(ctx context.Context, jobID JobID, reason string) error\n\n\t// Retrieves jobs' details from AWS Batch.\n\tGetJobDetailsBatch(ctx context.Context, ids []JobID) ([]*batch.JobDetail, error)\n\n\t// Registers a new Job Definition with AWS Batch provided a name, image and role.\n\tRegisterJobDefinition(ctx context.Context, name, image, role string, platformCapabilities string) (arn string, err error)\n\n\t// Gets the single region this client interacts with.\n\tGetRegion() string\n\n\tGetAccountID() string\n}\n```\nAWS Batch Client interface.\n\n```go\nfunc NewBatchClient(awsClient aws.Client,\n\tgetRateLimiter utils.RateLimiter,\n\tdefaultRateLimiter utils.RateLimiter) Client\n```\nInitializes a new Batch Client that can be used to interact with AWS Batch.\n\n```go\nfunc NewCustomBatchClient(batchClient BatchServiceClient, accountID, region string,\n\tgetRateLimiter utils.RateLimiter,\n\tdefaultRateLimiter utils.RateLimiter) Client\n```\n\n```go\ntype Event struct {\n\tOldJob *Job\n\tNewJob *Job\n}\n```\n\n```go\ntype EventHandler struct {\n\tUpdated func(ctx context.Context, event Event)\n}\n```\n\n```go\ntype Executor struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewExecutor(ctx context.Context, awsClient aws.Client, cfg *batchConfig.Config,\n\tenqueueOwner core.EnqueueOwner, scope promutils.Scope) (Executor, error)\n```\n\n```go\nfunc (e Executor) Abort(ctx context.Context, tCtx core.TaskExecutionContext) error\n```\n\n```go\nfunc (e Executor) Finalize(ctx context.Context, tCtx core.TaskExecutionContext) error\n```\n\n```go\nfunc (e Executor) GetID() string\n```\n\n```go\nfunc (e Executor) GetProperties() core.PluginProperties\n```\n\n```go\nfunc (e Executor) Handle(ctx context.Context, tCtx core.TaskExecutionContext) (core.Transition, error)\n```\n\n```go\nfunc (e Executor) Start(ctx context.Context) error\n```\n\n```go\ntype ExecutorMetrics struct {\n\tScope              promutils.Scope\n\tSubTasksSubmitted  labeled.Counter\n\tSubTasksSucceeded  labeled.Counter\n\tSubTasksFailed     labeled.Counter\n\tSubTasksQueued     labeled.Counter\n\tBatchJobTerminated labeled.Counter\n}\n```\n\n```go\ntype Job struct {\n\tID             JobID                `json:\"id,omitempty\"`\n\tOwnerReference types.NamespacedName `json:\"owner.omitempty\"`\n\tAttempts       []Attempt            `json:\"attempts,omitempty\"`\n\tStatus         JobStatus            `json:\"status,omitempty\"`\n\tSubJobs        []*Job               `json:\"array,omitempty\"`\n}\n```\n\n```go\nfunc (j Job) IsTerminal() bool\n```\n\n```go\nfunc (j Job) String() string\n```\n\n```go\ntype JobConfig struct {\n\tPrimaryTaskQueue string `json:\"primary_queue\"`\n\tDynamicTaskQueue string `json:\"dynamic_queue\"`\n}\n```\n\n```go\nfunc (j *JobConfig) MergeFromConfigMap(configMap *v1.ConfigMap) *JobConfig\n```\n\n```go\nfunc (j *JobConfig) MergeFromKeyValuePairs(pairs []*core.KeyValuePair) *JobConfig\n```\n\n```go\ntype JobID = string\n```\n\n```go\nfunc GetJobID(id JobID, index int) JobID\n```\n\n```go\ntype JobName = string\n```\n\n```go\ntype JobPhaseType = core.Phase\n```\n\n```go\ntype JobStatus struct {\n\tPhase   JobPhaseType `json:\"phase,omitempty\"`\n\tMessage string       `json:\"msg,omitempty\"`\n}\n```\n\n```go\ntype JobStore struct {\n\tClient\n\tcache.AutoRefresh\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewJobStore(ctx context.Context, batchClient Client, cfg config.JobStoreConfig,\n\thandler EventHandler, scope promutils.Scope) (JobStore, error)\n```\nConstructs a new in-memory store.\n\n```go\nfunc (s JobStore) Get(jobName string) *Job\n```\n\n```go\nfunc (s JobStore) GetOrCreate(jobName string, job *Job) (*Job, error)\n```\n\n```go\nfunc (s JobStore) IsStarted() bool\n```\n\n```go\nfunc (s *JobStore) Start(ctx context.Context) error\n```\n\n```go\nfunc (s JobStore) SubmitJob(ctx context.Context, input *batch.SubmitJobInput) (jobID string, err error)\n```\nSubmits a new job to AWS Batch and retrieves job info. Note that submitted jobs will not have status populated.\n\n```go\ntype State struct {\n\t*core.State\n\n\tExternalJobID    *string `json:\"externalJobID\"`\n\tJobDefinitionArn definition.JobDefinitionArn\n}\n```\n\n```go\nfunc CheckSubTasksState(ctx context.Context, tCtx core.TaskExecutionContext, jobStore *JobStore,\n\tcfg *config.Config, currentState *State, metrics ExecutorMetrics) (newState *State, err error)\n```\n\n```go\nfunc EnsureJobDefinition(ctx context.Context, tCtx pluginCore.TaskExecutionContext, cfg *config.Config, client Client,\n\tdefinitionCache definition.Cache, currentState *State, terminalVersion uint32) (nextState *State, err error)\n```\n\n```go\nfunc LaunchSubTasks(ctx context.Context, tCtx core.TaskExecutionContext, batchClient Client, pluginConfig *config.Config,\n\tcurrentState *State, metrics ExecutorMetrics, terminalVersion uint32) (nextState *State, err error)\n```\n\n```go\nfunc (s State) GetExternalJobID() *string\n```\n\n```go\nfunc (s State) GetJobDefinitionArn() definition.JobDefinitionArn\n```\n\n```go\nfunc (s *State) SetExternalJobID(jobID string) *State\n```\n\n```go\nfunc (s *State) SetJobDefinitionArn(arn definition.JobDefinitionArn) *State\n```\n\n","path":"github.com/flyteorg/flyte/flyteplugins/go/tasks/plugins/array/awsbatch","name":"awsbatch","synopsis":"This package deals with the communication with AWS-Batch and adopting its APIs to the flyte-plugin model.","isRedistributable":true}
