pendant.aws.batch module

class pendant.aws.batch.JobDefinition[source]

Bases: object

A Batch job definition.

name

Return the name of the job definition.

parameters

Return the parameters of the job definition.

revision

Return the revision of the job definition.

validate() → None[source]

Validate this job definition after initialization.

at_revision(revision: str) → pendant.aws.batch.JobDefinition[source]

Set this job definition to a specific revision.

make_job_name(moment: Optional[datetime.datetime] = None) → str[source]

Format a Batch job name from this definition.

to_dict() → Dict[str, str][source]

Return a dictionary of all parameters and their values as strings.

class pendant.aws.batch.BatchJob(definition: pendant.aws.batch.JobDefinition)[source]

Bases: object

An AWS Batch job.

A Batch job can be instantiated and then submitted against the Batch service. After submission, the job’s status can be queried, the job’s logs can be read, and other methods can be called to understand the state of the job.

Parameters:definition – A Batch job definition.
container_overrides

Return container overriding parameters.

job_id

Return the job ID.

queue

Return the job queue.

static describe_job(job_id: str) → Dict[source]

Describe this job.

static describe_jobs(job_ids: List[str]) → List[Dict][source]

Describe a Batch job by job ID.

status() → str[source]

Return the job status.

cancel(reason: str) → Dict[source]

Cancel this job.

Parameters:reason – The reason why the job must be canceled.
Returns:The service response to job cancellation.
terminate(reason: str) → Dict[source]

Terminate this job.

Jobs that are in the STARTING or RUNNING state are terminated, which causes them to transition to FAILED. Jobs that have not progressed to the STARTING state are cancelled.

Parameters:reason – The reason why the job must be terminated.
Returns:The service response to job termination.
is_running() → bool[source]

Return if this job’s state is RUNNING or not.

is_runnable() → bool[source]

Return if this job’s state is RUNNABLE or not.

is_submitted() → bool[source]

Return if this job has been submitted to Batch.

submit(queue: str, container_overrides: Optional[Mapping] = None) → pendant.aws.response.SubmitJobResponse[source]

Submit this job to Batch.

Parameters:
  • queue – The Batch job queue to use.
  • container_overrides – The values to override in the spawned container.
Returns:

The service response to job submission.

log_stream_name() → str[source]

Return the Batch log stream name for this job.

log_stream_events() → List[pendant.aws.logs.LogEvent][source]

Return all log events for this job.

Returns:events – All log events, to date.