-
Notifications
You must be signed in to change notification settings - Fork 659
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
[Core Feature] Local logs for local container task executions. #5436
Comments
To enable local logs for local container task executions in Flyte, you can propose adding a Here's a conceptual example of how this could be implemented:
Example code snippet: from flytekit import ContainerTask, workflow
import docker
class CustomContainerTask(ContainerTask):
def __init__(self, *args, local_logs=False, **kwargs):
super().__init__(*args, **kwargs)
self.local_logs = local_logs
def execute(self, **kwargs):
client = docker.from_env()
container = client.containers.run(self.image, self.command, detach=True)
if self.local_logs:
for log in container.logs(stream=True):
print(log.strip())
container.wait()
return container
echo_container_task = CustomContainerTask(
name="echo",
image="alpine:latest",
command=["echo", "'a test to show stdout'"],
local_logs=True,
)
@workflow
def echo_workflow() -> None:
return echo_container_task()
if __name__ == "__main__":
print(echo_workflow()) This example demonstrates how to extend the Would you like more details on any specific part of this implementation? Sources: This is an AI-generated response and your feedback is appreciated! Please leave a 👍 if this is helpful and 👎 if it is not. Mention @RunLLM to ask follow-up questions. See runllm.com for more! |
I would like to work on this issue can you assign it to me ? |
Hi @aditya7302. Of course! Thank you for taking on this issue. 🚀 🙏 |
It would be nice if we could have something like a boolean flag that controls if local container tasks output logs to the terminal.
I think think could be added somewhere around here using the
.logs()
method of the docker client shown on this page.An example of the SDK UX could be something like this:
where
local_logs
is ignored if it is a remote execution.The text was updated successfully, but these errors were encountered: