https://prefect.io logo
e

Evan Brown

09/01/2021, 2:23 PM
Hey there! I am having trouble logging standard out with shelltasks like you would with the task decorator. Does anyone know how you would do this?
k

Kevin Kho

09/01/2021, 2:24 PM
Hey @Evan Brown, could you show me how you set up the shell task?
e

Evan Brown

09/01/2021, 2:36 PM
This is what I currently have.
And in my test.py I just have some print statements.
k

Kevin Kho

09/01/2021, 2:41 PM
Can you try adding
log_stdout=True
to
ShellTask
? It inherits from Task so it can take all of the kwargs.
👀 1
e

Evan Brown

09/01/2021, 2:55 PM
It didn't work 🙁. Any other ideas?
k

Kevin Kho

09/01/2021, 2:57 PM
Do you get no logs from this whatsoever?
Add
stream_output=True
like this:
Copy code
from os import path
from prefect import Flow
from prefect.tasks.shell import ShellTask

shelltask = ShellTask(
    name="shell_task",
    log_stderr=True,
    return_all=True,
    stream_output=True
)

with Flow("shelltest") as flow:
    shelltask(command="echo 'test'")

flow.run()
👀 1
e

Evan Brown

09/01/2021, 3:15 PM
That works!
k

Kevin Kho

09/01/2021, 3:15 PM
Awesome!
e

Evan Brown

09/01/2021, 3:15 PM
Do you know if the output can be viewed in prefect cloud?
Ideally I would like to see it in the logs if possible
k

Kevin Kho

09/01/2021, 3:16 PM
I think it should be. I’ve done it before.
Just tested and yes I see it
🙌 1
e

Evan Brown

09/01/2021, 3:18 PM
Yes I did as well. Thanks so much for the help!