Alex Papanicolaou
03/14/2024, 7:07 PMAlex Papanicolaou
03/14/2024, 7:07 PMmypackage
and installed in an environment
2. mypackage_cli
flow serve runs the following flow to get a deployment with .serve
3. A basic structure of what’s going on is as follows:
src/mypackage/other/flow.py:
from loguru import logger
from mypackage.other.module import function
@flow
def run_job() -> None:
enable_prefect_loguru_support()
...
logger.info("this logs correctly")
function()
src/mypackage/other/module.py
from loguru import logger
def function() -> None:
logger.info("This doesn't show in prefect logs")
And enable_prefect_loguru_support
comes from this post: Can I use loguru logs in Prefect flows?
When running this setup, I use the following environment variables:
PREFECT_LOGGING_EXTRA_LOGGERS=mypackage
PREFECT_LOGGING_MYPACKAGE_LEVEL=INFO
None of this gets the logs in the interior function to show up. Any ideas?Alex Papanicolaou
03/14/2024, 7:16 PMloguru
logger wasn't enabled so the following helps, though is maybe less than ideal.
def enable_prefect_loguru_support() -> None:
# import here for distributed execution because loguru cannot be pickled.
from loguru import logger
logger.enable("mypackage") # included this line
run_logger = get_run_logger()
...