view_log() | Teradata Package for Python - view_log() - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Use the view_log() function to view script, apply or byom logs on Vantage.

  • Logs files are downloaded based on log_dir.
  • teradataml creates a subdirectory with the name as query_id and downloads the logs to the subdirectory.
  • It takes few seconds to generate files from query_id. Teradata recommends providing query_id to function view_log() after few seconds; otherwise, it will return empty subdirectory.
Optional arguments:
  • log_type specifies the log to view.
    Permitted values:
    • 'script', script logs are pulled from 'scriptlog' file on database node.

      This is useful when Script.execute() is executed to run user scripts in Vantage.

    • 'byom', byom log is pulled from 'byom.log' file on database node.
    • 'apply', logs are pulled from kubernetes container, function downloads the log file to a folder.

    Default value is 'script'.

  • num_lines specifies the number of lines to be read and displayed from log.
    This argument is applicable only when log_type is 'script'. Otherwise, it is ignored.

    The default value is 1000.

  • query_id: Specifies the id of the query for which logs are to be retrieved. This query id is part of the error message received when Apply class or DataFrame apply method calls fail to execute the Apply table operator query.
    This argument is required only when log_type is 'apply'. Otherwise, it is ignored.
  • log_dir: Specifies the directory path to store all the log files for query_id.
    This argument is applicable only when log_type is 'apply'. Otherwise, it is ignored.

    When this argument is not provided, function creates a temporary folder and store the log files in this temp folder.

The return of this function depends on the log_type:
  • When log_type is 'apply', it returns log file;
  • For other types of logs, it returns teradataml DataFrame.

Example 1: View script log

view_log(log_type="script", num_lines=200)

Example 2: View byom log

view_log(log_type="byom", num_lines=200)

Example 3: Download the Apply query logs to a default temp folder

This example uses query id from the error messages returned by Apply class.

view_log(log_type="apply", query_id='307161028465226056')
Logs for query_id "307191028465562578" is stored at "C:\\local_repo\\AppData\\Local\\Temp\\tmp00kuxlgu\\307161028465226056"

Example 4: Download the Apply query logs to a specific folder

This example uses query id from the error messages returned by Apply class.

view_log(log_type="apply", query_id='307161028465226056',log_dir='C:\\local_repo\\workspace')
Logs for query_id "307191028465562578" is stored at "C:\\local_repo\\workspace\\307161028465226056"