Skip to content

Commit ac0d33e

Browse files
authored
[bugfix] fix log group logic for Batch jobs (#22)
1 parent a3f54ea commit ac0d33e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

pyfgaws/batch/api.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,20 @@ def stream(self) -> Optional[str]:
265265

266266
@property
267267
def group(self) -> Optional[str]:
268-
"""The log group for the job, if available."""
269-
options = self.describe_job()["container"]["logConfiguration"]["options"] # type: ignore
268+
"""The log group for the job, if available.
269+
270+
If the stream is not available, then None is returned. Otherwise, looks in
271+
container.logConfiguration.options.awslogs-group, returning "/aws/batch/job" if that path
272+
is not found.
273+
"""
274+
if self.stream is None:
275+
return None
276+
config = self.describe_job()["container"].get("logConfiguration") # type: ignore
277+
if config is None:
278+
return "/aws/batch/job"
279+
options = config.get("options") # type: ignore
280+
if options is None:
281+
return "/aws/batch/job"
270282
return options.get("awslogs-group") # type: ignore
271283

272284
def submit(self) -> SubmitJobResponseTypeDef:

0 commit comments

Comments
 (0)