tdnb.exit() - Teradata VantageCloud Lake

Lake - Analyze Your Data with ClearScape Analytics™

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2026-02-20
dita:mapPath
tcl1683670667798.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
tcl1683670667798

Use the tdnb.exit() function to exit a notebook with a message.

As touch based in the previous section, tdnb.exit() is a utility which has power to stop the execution of notebook when run from another notebook and has ability to send a message to its caller notebook. So, caller notebook effectively makes use of the message and take decisions appropriately.

Required Parameters

message
Specifies the message to be returned from the executed notebook to the executor notebook.

Example 1

Consider the same example used for tdnb.run_notebook(). However, in this example, check whether logger is executed or not from notebook1.ipynb1 using tdnb.exit().

content of logger_notebook.ipynb

import logging
logger = logging.getLogger('LoggerNotebook')
logging.getLogger().setLevel(logging.INFO)
from teradatamlwidgets import tdnb
tdnb.text('log message', 'message', 'LogMessage:'
logger.warning(tdnb.get('log_message'))
tdnb.exit("logged")

tdnb utility - tdnb.exit() function example logger_notebook output

content of notebook1.ipynb

from teradatamlwidgets import tdnb
tdnb.run_notebook('logger_notbook.ipynb', arguments={'log_message': 'Message1'})

tdnb utility - tdnb.exit() function example notebook1 output

Example 2

Design two notebooks:
  • Design a notebook with name test_even_odd.ipynb to look for a number, decide whether it is even or odd and exist with message as EVEN or ODD.
  • Design another notebook notebook1.ipynb to pass a number to test_even_odd.ipynb and retrieve message from it.

Content of test_even_odd.iypnb

from teradatamlwidgets import tdnb
tdnb.text('number', '0', 'Number'
# Retrieve the value. Parse the value to int 
# text field always stores in string format
num = int(tdnb.get('number'))
if num%2 == 0
   tdnb.exit('EVEN')
else:
   tdnb.exit('ODD')

tdnb utility - tdnb.exit() function example test_even_odd output

Content of notebook1.iypnb

from teradatamlwidgets import tdnb
tdnb.runbook('test_even_odd.ipynb', arguments={'number': '5'})
tdnb.runbook('test_even_odd.ipynb', arguments={'number': '4'})

tdnb utility - tdnb.exit() function example notebook1 output