justabill
02/03/2023, 1:17 AMPREFECT_LOGGING_ORION_WHEN_MISSING_FLOW
to allow configuration of this behavior to silence the warning or raise an error as before. This means that you can attach Prefect's logging handler to existing loggers without breaking your workflows. Check it out:
from prefect import flow
import logging
my_logger = logging.getLogger("my-logger")
<http://my_logger.info|my_logger.info>("outside the flow")
@flow
def foo():
<http://my_logger.info|my_logger.info>("inside the flow")
if __name__ == "__main__":
foo()
You can even see messages from my-logger
in the UI with PREFECT_LOGGING_EXTRA_LOGGERS
:its-beautiful::
$ PREFECT_LOGGING_EXTRA_LOGGERS="my-logger" python example.py
example.py:6: UserWarning: Logger 'my-logger' attempted to send logs to Orion without a flow run id. The Orion log handler can only send logs within flow run contexts unless the flow run id is manually provided.
<http://my_logger.info|my_logger.info>("outside the flow")
18:09:30.518 | INFO | my-logger - outside the flow
18:09:31.028 | INFO | prefect.engine - Created flow run 'elated-curassow' for flow 'foo'
18:09:31.104 | INFO | my-logger - inside the flow
18:09:31.179 | INFO | Flow run 'elated-curassow' - Finished in state Completed()
Collection updates:
• prefect-shell got a new ShellOperation
block that runs a shell operation
• prefect-census got CensusSync
block that runs a census sync
Check out the release notes for information on the other enhancements and fixers in this release.
Special thanks to Chia Berry, @Hans Lellelid, and Tomek for their contributions to this release! ⭐
Happy Engineering! :marvin: