Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean flag to show local container logs to the terminal #2521

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions flytekit/core/container_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
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
Expand Down Expand Up @@ -93,6 +94,7 @@
requests=requests if requests else Resources(), limits=limits if limits else Resources()
)
self.pod_template = pod_template
self.local_logs = local_logs

Check warning on line 97 in flytekit/core/container_task.py

View check run for this annotation

Codecov / codecov/patch

flytekit/core/container_task.py#L97

Added line #L97 was not covered by tests

@property
def resources(self) -> ResourceSpec:
Expand Down Expand Up @@ -249,6 +251,11 @@
)
# 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:
pingsutw marked this conversation as resolved.
Show resolved Hide resolved
for log in container.logs(stream=True):
print(f"[Local Container] {log.strip()}")

Check warning on line 257 in flytekit/core/container_task.py

View check run for this annotation

Codecov / codecov/patch

flytekit/core/container_task.py#L257

Added line #L257 was not covered by tests

container.wait()

output_dict = self._get_output_dict(output_directory)
Expand Down
Loading