Is there a way to call `.fn` and ignore `get_run_logger()`?

I want to call test_task as a normal function:

from prefect import task, get_run_logger

@task
def test_task():
    logger = get_run_logger()
    logger.info("ignore this!")
    return 42

def test_normal_fn():
    return test_task.fn()

However, this raises:


File ~/Applications/python/prefect/src/prefect/logging/loggers.py:96, in get_run_logger(context, **kwargs)
     92     logger = flow_run_logger(
     93         flow_run=flow_run_context.flow_run, flow=flow_run_context.flow, **kwargs
     94     )
     95 else:
---> 96     raise RuntimeError("There is no active flow or task run context.")
     98 return logger

RuntimeError: There is no active flow or task run context.

Is there a way to ignore get run logger’s error?

1 Like

I asked Michael, but this is related: