You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🥳 FUN TICKET 🥳 Prerequisites: #1512. Based off point 3 in #1464
Let's take advantage of the nice formatting we can do with rich and make Kedro's log messages prettier.
replace backticks (`) in all log messages with quote marks (can be single or double). This will be a lot of very small changes!
edit log messages to be clearer and prettier using console markup. Note:
let's not go too crazy here. Try and restrict to sensible styles so that we have a somewhat unified appearance that we know works on a variety of background colours. Take inspiration from the styles in the picture below (e.g. [bold bright_green] is used but won't appear much by default so it's a good candidate to use)
any log messages you add markup to will need to have extra={"markup": True} in the logging call as explained in the rich docs. If we end up adding markup to loads of logging calls it might be easier to alter the kedro logger (not the root one!!) in framework logging.yml to set markup: true
start with the logging messages that are most important/frequently seen during a kedro run. Check point 3 in The road to introducing rich into Kedro natively #1464 and the associated code by @datajoely for what the "highest impact" logging calls are and some suggested ways to style them. But feel free to add markup to any other logging calls throughout kedro too - the sky's the limit here! 🚀
similarly feel free to go beyond just adding markup and change the wording/style of brackets/arrows/etc. in the log messages if you think they can be improved, as @datajoely did.
Useful context: how rich formatting works
We are using the RichHandler for logging. By default this highlights messages automatically according to the ReprHighlighter. Here's how different things get highlighted (generated using python -m rich.default_styles):
Here's an example of what this means in practice:
e.g. the numbers are styled according to repr.number. Strings are styled according to repr.str. The definition of what is interpreted as a string is given by this regex, which is complicated but the outcome is that stuff in ' or " gets highlighted as a string, but the backtick ` has no special meaning.
In the past we've tended to use backticks to highlight things like dataset and node names. To get these nicely highlighted there's a few options:
convert where we use backticks to quote marks so they get automatically highlighted
make a custom highlighter which extends ReprHighlighter and adds a regex to specially format things enclosed in backticks
instead of using backticks, come up with something our own more semantic tag like [dataset] and [node] and define a custom theme
Overall 2 and 3 would be kind of cool but seem like big overkill here, hence going for option 1.
The text was updated successfully, but these errors were encountered:
🥳 FUN TICKET 🥳 Prerequisites: #1512. Based off point 3 in #1464
Let's take advantage of the nice formatting we can do with rich and make Kedro's log messages prettier.
[bold bright_green]
is used but won't appear much by default so it's a good candidate to use)extra={"markup": True}
in the logging call as explained in the rich docs. If we end up adding markup to loads of logging calls it might be easier to alter the kedro logger (not the root one!!) in framework logging.yml to setmarkup: true
rich
into Kedro natively #1464 and the associated code by @datajoely for what the "highest impact" logging calls are and some suggested ways to style them. But feel free to add markup to any other logging calls throughout kedro too - the sky's the limit here! 🚀Useful context: how rich formatting works
We are using the
RichHandler
for logging. By default this highlights messages automatically according to theReprHighlighter
. Here's how different things get highlighted (generated usingpython -m rich.default_styles
):Here's an example of what this means in practice:
e.g. the numbers are styled according to
repr.number
. Strings are styled according torepr.str
. The definition of what is interpreted as a string is given by this regex, which is complicated but the outcome is that stuff in'
or"
gets highlighted as a string, but the backtick ` has no special meaning.In the past we've tended to use backticks to highlight things like dataset and node names. To get these nicely highlighted there's a few options:
ReprHighlighter
and adds a regex to specially format things enclosed in backticks[dataset]
and[node]
and define a custom themeOverall 2 and 3 would be kind of cool but seem like big overkill here, hence going for option 1.
The text was updated successfully, but these errors were encountered: