visible
cauldron.step.visible
Whether or not this step will be visible in the display after it
has finished running. Steps are always visible while running or
if they fail to run due to an error. However, if this is set to
False, once the step completes successfully it will no longer be
visible in the display.
Background
There are times when it's useful to hide a notebook step from the final
output. It may be a case where not information is always useful, or to
create a debug versus production form of output. Whatever the case, this
property is how a step can be hidden from the notebook display.
Basic Usage
The property can be set on the step at any point in the step code. In
this example it's set at the beginning of the step. While the step is
running, the user will see the output. After the step completes the
entire step will disappear from the notebook:
01
02
03
04
05
06
07
08
09
10
11
12
13
import cauldron as cd
import time
cd.step.visible = False
print('You will not see this output once the step finishes running.')
count = 10
for i in range(count):
print(f'Sleeping {i + 1} of {count} seconds')
time.sleep(1)
print('Sleeping complete. I am going to disappear now.')
The setting can just as easily be set at the end of the step, which might
be useful for conditional visibility. In this example, the step will be
visible only if there are new big spenders found during filtering within
the step:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
import cauldron as cd
import pandas as pd
customers: pd.DataFrame = cd.shared.customers
volume_threshold = (
(customers['units_sold'] > 100)
& (customers['months_old'] < 12)
)
new_big_spenders = customers[volume_threshold]
cd.display.header('Recent Big Spending Customers')
cd.display.table(new_big_spenders)
cd.step.visible = len(new_big_spenders.index) > 0