Skip to content

Commit

Permalink
[bugfix] fix log group logic for Batch jobs (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 authored Jul 12, 2022
1 parent a3f54ea commit ac0d33e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pyfgaws/batch/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,20 @@ def stream(self) -> Optional[str]:

@property
def group(self) -> Optional[str]:
"""The log group for the job, if available."""
options = self.describe_job()["container"]["logConfiguration"]["options"] # type: ignore
"""The log group for the job, if available.
If the stream is not available, then None is returned. Otherwise, looks in
container.logConfiguration.options.awslogs-group, returning "/aws/batch/job" if that path
is not found.
"""
if self.stream is None:
return None
config = self.describe_job()["container"].get("logConfiguration") # type: ignore
if config is None:
return "/aws/batch/job"
options = config.get("options") # type: ignore
if options is None:
return "/aws/batch/job"
return options.get("awslogs-group") # type: ignore

def submit(self) -> SubmitJobResponseTypeDef:
Expand Down

0 comments on commit ac0d33e

Please sign in to comment.