https://prefect.io logo
Title
t

Tom Forbes

08/25/2021, 1:59 PM
Is there a simple way to disable the
Task 'xy[z]': Finished task run…
messages?
p

Pierre Monico

08/25/2021, 2:09 PM
You can simply set an environment variable as per the docs, e.g.
PREFECT__LOGGING__LEVEL=WARNING
t

Tom Forbes

08/25/2021, 2:13 PM
But doesn’t this also impact tasks? i.e:
@task()
def test():
    <http://prefect.context.logger.info|prefect.context.logger.info>("hello")
won’t work?
k

Kevin Kho

08/25/2021, 2:26 PM
I think there is no simple way but you might be able to do this with Python logging filters. For example (see :
import prefect
from prefect import task, Flow, Parameter
from prefect.triggers import all_successful, any_failed, always_run, all_failed
import logging

class MyFilter(logging.Filter):
    def filter(self,record):
        return 'Task' not in record.msg

@task()
def success_handler():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("Handled task success")

with Flow("TestFlow") as flow:
    success_handler()

# Add the filter
logging.getLogger("prefect.TaskRunner").addFilter(MyFilter())

flow.run()
But then I think you need to store your Flow as a script for this Filter to apply.
t

Tom Forbes

08/25/2021, 2:28 PM
Argh, yeah. This also won’t work if you’re using a remote Dask cluster I think.
Just an FYI, the messages are not entirely useful especially if you’re launching a large number of tasks. It makes it much harder to see errors or other conditions you care about
k

Kevin Kho

08/25/2021, 2:33 PM
Will elevate the feedback and see if something can be done around this.