remote_links
Builders for AWS console / CloudWatch deep links from remote job identifiers.
These are pure string helpers: given an external AWS Batch job id (or ARN) and,
where available, a region and log stream, they build the URLs a user can open to
inspect the job in the AWS console or its logs in CloudWatch. Everything is
None-tolerant — when there isn't enough information to build a meaningful
link (most importantly, no region), the builder returns None and the caller
simply shows the raw identifier instead.
Functions:¶
batch_console_url ¶
Build the AWS Batch console job-detail URL.
The region is taken from the explicit argument, falling back to a region embedded in the ARN. Without a region (e.g. a bare job id from the metadata DB), no console URL can be built.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
external_jobid
|
str | None
|
A Batch job ARN or bare job id. |
required |
region
|
str | None
|
Explicit region, or None to derive it from an ARN. |
None
|
Returns:
| Type | Description |
|---|---|
str | None
|
A console URL, or None if there is not enough information. |
Source code in snakesee/remote_links.py
batch_job_id_from ¶
Return the bare AWS Batch job id, extracting it from an ARN if needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
external_jobid
|
str | None
|
A Batch job ARN, a bare job id, or None. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The bare job id, or None if the input is empty. |
Source code in snakesee/remote_links.py
cloudwatch_url ¶
cloudwatch_url(log_stream: str | None, region: str | None, log_group: str = _DEFAULT_BATCH_LOG_GROUP) -> str | None
Build the CloudWatch Logs URL for a Batch job's log stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_stream
|
str | None
|
The CloudWatch log stream name (e.g. from describe_jobs). |
required |
region
|
str | None
|
The AWS region; required to build the URL. |
required |
log_group
|
str
|
The log group; defaults to the Batch default |
_DEFAULT_BATCH_LOG_GROUP
|
Returns:
| Type | Description |
|---|---|
str | None
|
A CloudWatch Logs URL, or None if region or stream are missing. |
Source code in snakesee/remote_links.py
is_spot_interruption ¶
Heuristically detect whether a failure was a Spot-instance interruption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_reason
|
str | None
|
The backend-provided status reason string, if any. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the reason looks like a Spot reclamation / interruption. |
Source code in snakesee/remote_links.py
region_from_arn ¶
Return the region embedded in a Batch ARN, or None if not an ARN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
external_jobid
|
str | None
|
A Batch job ARN, a bare job id, or None. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
The region string, or None if the input is not an ARN. |