render_to_console
cauldron.step.render_to_console()
Renders the specified message to the console using Jinja2 template
rendering with the kwargs as render variables. The message will also
be dedented prior to rendering in the same fashion as other Cauldron
template rendering actions.
Template string to be rendered.
Variables to be used in rendering the template.
Background
This function is similar to the
cd.step.write_to_console()
but adds Jinja2 template rendering support for handling more
complicated string display manipulation.
Basic Usage
For example, we may want to track memory used by a DataFrame in the
console for reference, but not display that information within the
notebook. The same example is shown in the
cd.step.write_to_console()
documentation, but in this case we're going to take advantage of
Jinja's filesizeformat filter to display the results in a more
display friendly format, e.g. 1.0 MB instead of 1000000 bytes.
01
02
03
04
05
06
07
08
09
10
11
import cauldron as cd
import pandas as pd
import some_library
data_frame: pd.DataFrame = some_libray.load_data()
bytes_used = data_frame.memory_usage.sum()
cd.step.write_to_console(
'Loaded DataFrame using {{ bytes_used | filesizeformat(true) }}.',
bytes_used=bytes_used
)