e

    Evan Brown

    1 year ago
    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?
    Kevin Kho

    Kevin Kho

    1 year ago
    Hey @Evan Brown, could you show me how you set up the shell task?
    e

    Evan Brown

    1 year ago
    This is what I currently have.
    And in my test.py I just have some print statements.
    Kevin Kho

    Kevin Kho

    1 year ago
    Can you try adding
    log_stdout=True
    to
    ShellTask
    ? It inherits from Task so it can take all of the kwargs.
    e

    Evan Brown

    1 year ago
    It didn't work 🙁. Any other ideas?
    Kevin Kho

    Kevin Kho

    1 year ago
    Do you get no logs from this whatsoever?
    Add
    stream_output=True
    like this:
    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()
    e

    Evan Brown

    1 year ago
    That works!
    Kevin Kho

    Kevin Kho

    1 year ago
    Awesome!
    e

    Evan Brown

    1 year ago
    Do you know if the output can be viewed in prefect cloud?
    Ideally I would like to see it in the logs if possible
    Kevin Kho

    Kevin Kho

    1 year ago
    I think it should be. I’ve done it before.
    Just tested and yes I see it
    e

    Evan Brown

    1 year ago
    Yes I did as well. Thanks so much for the help!