From 36f2d25ad89822965221cfae975c88a787732281 Mon Sep 17 00:00:00 2001 From: aditya7302 Date: Wed, 19 Jun 2024 22:49:43 +0530 Subject: [PATCH 1/2] Boolean flag to show local container logs to the terminal Signed-off-by: aditya7302 --- flytekit/core/container_task.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/flytekit/core/container_task.py b/flytekit/core/container_task.py index 66fe522c07..267a992e6f 100644 --- a/flytekit/core/container_task.py +++ b/flytekit/core/container_task.py @@ -59,6 +59,7 @@ def __init__( secret_requests: Optional[List[Secret]] = None, pod_template: Optional["PodTemplate"] = None, pod_template_name: Optional[str] = None, + local_logs: bool = False, **kwargs, ): sec_ctx = None @@ -93,6 +94,7 @@ def __init__( requests=requests if requests else Resources(), limits=limits if limits else Resources() ) self.pod_template = pod_template + self.local_logs = local_logs @property def resources(self) -> ResourceSpec: @@ -249,6 +251,11 @@ def execute(self, **kwargs) -> LiteralMap: ) # Wait for the container to finish the task # TODO: Add a 'timeout' parameter to control the max wait time for the container to finish the task. + + if self.local_logs: + for log in container.logs(stream=True): + print(f"[Local Container] {log.strip()}") + container.wait() output_dict = self._get_output_dict(output_directory) From ed643ace634079c3201cc1212779ddb0cf9c7db9 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 29 Jul 2024 09:05:17 -0700 Subject: [PATCH 2/2] lint Signed-off-by: Kevin Su --- flytekit/core/container_task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flytekit/core/container_task.py b/flytekit/core/container_task.py index 267a992e6f..ce5863114f 100644 --- a/flytekit/core/container_task.py +++ b/flytekit/core/container_task.py @@ -255,7 +255,7 @@ def execute(self, **kwargs) -> LiteralMap: if self.local_logs: for log in container.logs(stream=True): print(f"[Local Container] {log.strip()}") - + container.wait() output_dict = self._get_output_dict(output_directory)